本文整理汇总了PHP中formatUptime函数的典型用法代码示例。如果您正苦于以下问题:PHP formatUptime函数的具体用法?PHP formatUptime怎么用?PHP formatUptime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatUptime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: deviceUptime
function deviceUptime($device, $format = "long")
{
if ($device['status'] == 0) {
$since = time() - strtotime($device['last_polled']);
return "Down " . formatUptime($since, $format);
} else {
return formatUptime($device['uptime'], $format);
}
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:9,代码来源:common.php
示例2: nl2br
echo $service['service_id'];
?>
' name='edit-service'><i class='fa fa-pencil' aria-hidden='true'></i></button>
<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-service_id='<?php
echo $service['service_id'];
?>
' name='delete-service'><i class='fa fa-trash' aria-hidden='true'></i></button>
</div>
</div>
<div class="col-sm-12">
<div class="col-sm-8"><?php
echo nl2br(trim($service['service_message']));
?>
</div>
<div class="col-sm-4"><?php
echo formatUptime(time() - $service['service_changed']);
?>
</div>
</div>
<?php
if ($vars['view'] == 'details') {
// if we have a script for this check, use it.
$check_script = $config['install_dir'] . '/includes/services/check_' . strtolower($service['service_type']) . '.inc.php';
if (is_file($check_script)) {
include $check_script;
// If we have a replacement DS use it.
if (isset($check_ds)) {
$service['service_ds'] = $check_ds;
}
}
$graphs = json_decode($service['service_ds'], true);
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:services.inc.php
示例3: foreach
foreach (dbFetchRows($sql) as $service) {
if (device_permitted($service['device_id'])) {
echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n <strong>" . generate_device_link($service, shorthost($service['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />\n <strong>" . $service['service_type'] . "</strong><br />\n <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n </center></div>";
}
}
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id";
foreach (dbFetchRows($sql) as $peer) {
if (device_permitted($peer['device_id'])) {
echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n <strong>" . generate_device_link($peer, shorthost($peer['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />\n <strong>" . $peer['bgpPeerIdentifier'] . "</strong><br />\n <span class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n </div>";
}
}
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
$sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'";
foreach (dbFetchRows($sql) as $device) {
if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") {
echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>\n <strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />\n <span class=body-date-1>" . formatUptime($device['attrib_value']) . "</span>\n </div>";
}
}
}
echo "\n\n <div style='clear: both;'>{$errorboxes}</div> <div style='margin: 0px; clear: both;'>\n\n<h3>Recent Syslog Messages</h3>\n\n";
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
echo "<table cellspacing=0 cellpadding=2 width=100%>";
foreach (dbFetchRows($sql) as $entry) {
include "includes/print-syslog.inc.php";
}
echo "</table>";
echo "</div>\n\n </td>\n <td bgcolor=#e5e5e5 width=470 valign=top>";
// this stuff can be customised to show whatever you want....
if ($_SESSION['userlevel'] >= '5') {
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
unset($seperator);
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:31,代码来源:jt.php
示例4: generate_front_box
generate_front_box('bgp-down', generate_device_link($peer, shorthost($peer['hostname'])) . "<br />\n <span class=bgp-down>BGP Down</span>\n <span class='" . (strstr($peer['bgpPeerIdentifier'], ':') ? 'front-page-bgp-small' : 'front-page-bgp-normal') . "'>" . $peer['bgpPeerIdentifier'] . '</span><br />
<span class=body-date-1>AS' . truncate($peer['bgpPeerRemoteAs'] . ' ' . $peer['astext'], 14, '') . '</span>');
++$count_boxes;
}
}
// Device rebooted boxes
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) {
if (is_admin() === true || is_read() === true) {
$sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
} else {
$sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
}
foreach (dbFetchRows($sql) as $device) {
generate_front_box('device-rebooted', generate_device_link($device, shorthost($device['hostname'])) . '<br />
<span class=device-rebooted>Device Rebooted</span><br />
<span class=body-date-1>' . formatUptime($device['uptime'], 'short') . '</span>');
++$count_boxes;
}
}
if ($count_boxes == 0) {
echo "<h5>Nothing here yet</h5><p class=welcome>This is where status notifications about devices and services would normally go. You might have none\n because you run such a great network, or perhaps you've just started using " . $config['project_name'] . ". If you're new to " . $config['project_name'] . ', you might
want to start by adding one or more devices in the Devices menu.</p>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '
</div>
</div>
';
if ($config['vertical_summary']) {
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:default.php
示例5: generate_url
$temp_output[] = '
<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '">
<div class="device-availability ' . $deviceState . '" style="width:' . $config['webui']['availability_map_direct_tile_size'] . 'px;">
<span class="availability-label label ' . $deviceLabel . ' label-font-border">' . $deviceState . '</span>
<span class="device-icon">' . $deviceIcon . '</span><br>
<span class="small">' . shorthost(ip_to_sysname($device, $device['hostname'])) . '</span>
</div>
</a>';
} else {
$temp_output[] = '
<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '">
<span class="label ' . $deviceLabel . ' widget-availability label-font-border">' . $deviceState . '</span>
</a>';
}
} else {
$temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '"><div class="' . $deviceLabelOld . '" style="width:' . $compact_tile . 'px;"></div></a>';
}
}
}
if (($mode == 1 || $mode == 2) && $config['show_services'] != 0) {
$service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `S`.`service_ignore`, `S`.`service.disabled`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id` ORDER BY ' . $serviceOrderBy . ';';
$services = dbFetchRows($service_query);
if (count($services) > 0) {
foreach ($services as $service) {
if ($service['service_disabled'] == '1') {
$serviceState = "disabled";
$serviceLabel = "blackbg";
$serviceDisabledCount++;
} else {
if ($service['service_ignore'] == '1') {
$serviceState = "ignored";
开发者ID:ekoyle,项目名称:librenms,代码行数:31,代码来源:availability-map.inc.php
示例6: print_debug
}
}
print_debug("{$uptime_msg} ({$uptime} seconds)");
if (is_numeric($uptime)) {
// Notify only if current uptime less than one month (eg if changed from sysUpTime to snmpEngineTime)
if ($uptime < $device['uptime'] && $uptime < 2628000) {
notify($device, "Device rebooted: " . $device['hostname'], "Device Rebooted : " . $device['hostname'] . " " . formatUptime($uptime) . " ago.");
log_event('Device rebooted after ' . formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
}
$uptime_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd";
if (!is_file($uptime_rrd)) {
rrdtool_create($uptime_rrd, "DS:uptime:GAUGE:600:0:U ");
}
rrdtool_update($uptime_rrd, "N:" . $uptime);
$graphs['uptime'] = TRUE;
print_message("Uptime: " . formatUptime($uptime));
$update_array['uptime'] = $uptime;
$cache['devices']['uptime'][$device['device_id']]['uptime'] = $uptime;
$cache['devices']['uptime'][$device['device_id']]['polled'] = $polled;
}
$poll_device['sysLocation'] = str_replace("\"", "", $poll_device['sysLocation']);
// Rewrite sysLocation if there is a mapping array (database too?)
if (!empty($poll_device['sysLocation'])) {
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace("\"", "", $poll_device['sysContact']);
if ($poll_device['sysLocation'] == "not set") {
$poll_device['sysLocation'] = "";
}
if ($poll_device['sysContact'] == "not set") {
$poll_device['sysContact'] = "";
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:system.inc.php
示例7: format_timestamp
</td>
<td style="width: 7%">
' . $row['last_polled_timetaken'] . 's
</td>
<td>' . format_timestamp($row['last_polled']) . ' </td>
<td>' . formatUptime($config['time']['now'] - strtotime($row['last_polled']), 'shorter') . ' ago</td>';
// Discovery times
echo '
<td style="width: 12%;">
<div class="progress progress-' . $proc['color']['discovery'] . ' active" style="margin-bottom: 5px;"><div class="bar" style="text-align: right; width: ' . $proc['time']['discovery'] . '%;"></div></div>
</td>
<td style="width: 7%">
' . $row['last_discovered_timetaken'] . 's
</td>
<td>' . format_timestamp($row['last_discovered']) . '</td>
<td>' . formatUptime($config['time']['now'] - strtotime($row['last_discovered']), 'shorter') . ' ago</td>
</tr>
';
}
// Calculate root mean square
$proc['avg2']['poller'] = sqrt($proc['avg2']['poller'] / $devices['count']);
$proc['avg2']['poller'] = round($proc['avg2']['poller'], 2);
$proc['avg2']['discovery'] = sqrt($proc['avg2']['discovery'] / $devices['count']);
$proc['avg2']['discovery'] = round($proc['avg2']['discovery'], 2);
echo ' <tr>
<th colspan="4" style="text-align: right;">所有设备的总时间(平均每设备):</th>
<th colspan="3" style="text-align: left;">' . $cache['devices']['timers']['polling'] . 's (' . $proc['avg2']['poller'] . 's)</th>
<th></th>
<th colspan="3" style="text-align: left;">' . $cache['devices']['timers']['discovery'] . 's (' . $proc['avg2']['discovery'] . 's)</th>
</tr>
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:pollerlog.inc.php
示例8: snmp_get
$snmpEngineTime = (int) snmp_get($device, "snmpEngineTime.0", "-OUqv", "SNMP-FRAMEWORK-MIB");
if (!is_numeric($snmpEngineTime)) {
$snmpEngineTime = 0;
}
if (is_numeric($uptime)) {
if ($uptime < $device['uptime'] && $uptime >= $snmpEngineTime) {
notify($device, "Device rebooted: " . $device['hostname'], "Device Rebooted : " . $device['hostname'] . " " . formatUptime($uptime) . " ago.");
log_event('Device rebooted after ' . formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
}
$uptime_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd";
if (!is_file($uptime_rrd)) {
rrdtool_create($uptime_rrd, "DS:uptime:GAUGE:600:0:U " . $config['rrd_rra']);
}
rrdtool_update($uptime_rrd, "N:" . $uptime);
$graphs['uptime'] = TRUE;
echo "Uptime: " . formatUptime($uptime) . "\n";
$update_array['uptime'] = $uptime;
}
$poll_device['sysLocation'] = str_replace("\"", "", $poll_device['sysLocation']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysLocation'] = trim($poll_device['sysLocation'], "\\");
// Rewrite sysLocation if there is a mapping array (database too?)
if (!empty($poll_device['sysLocation']) && is_array($config['location_map'])) {
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace("\"", "", $poll_device['sysContact']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysContact'] = trim($poll_device['sysContact'], "\\");
if ($poll_device['sysLocation'] == "not set") {
$poll_device['sysLocation'] = "";
}
开发者ID:REAP720801,项目名称:librenms,代码行数:31,代码来源:system.inc.php
示例9: process_alerts
/**
* Check all alerts for a device to see if they should be notified or not
*
* @param array device
* @return NULL
*/
function process_alerts($device)
{
global $config, $alert_rules, $alert_assoc;
echo "Processing alerts for " . $device['hostname'] . PHP_EOL;
$alert_table = cache_device_alert_table($device['device_id']);
$sql = "SELECT * FROM `alert_table`";
$sql .= " LEFT JOIN `alert_table-state` ON `alert_table`.`alert_table_id` = `alert_table-state`.`alert_table_id`";
$sql .= " WHERE `device_id` = ?";
foreach (dbFetchRows($sql, array($device['device_id'])) as $entry) {
echo 'Alert: ' . $entry['alert_table_id'] . ' Status: ' . $entry['alert_status'] . ' ';
// If the alerter is now OK and has previously alerted, send an recovery notice.
if ($entry['alert_status'] == '1' && $entry['has_alerted'] == '1') {
$alert = $alert_rules[$entry['alert_test_id']];
$state = json_decode($entry['state'], TRUE);
$conditions = json_decode($alert['conditions'], TRUE);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$graphs = "";
$metric_text = "";
foreach ($state['metrics'] as $metric => $value) {
$metric_text .= $metric . " = " . $value . PHP_EOL . "<br />";
}
// FIXME De-dup this shit soon.
// - adama
$message = '
<head>
<title>Observium Alert</title>
<style>
.observium{ width:100%; max-width: 500px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:1px solid #DDDDDD; background-color:#FAFAFA;
font-size: 13px; color: #777777; }
.header{ font-weight: bold; font-size: 16px; padding: 5px; color: #555555; }
.red { color: #cc0000; }
#deviceinfo tr:nth-child(odd) { background: #ffffff; }
</style>
<style type="text/css"></style></head>
<body>
<table class="observium">
<tbody>
<tr>
<td>
<table class="observium" id="deviceinfo">
<tbody>
<tr><td class="header">RECOVERY</td><td><a style="float: right;" href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $entry['alert_table_id'])) . '">Modify</a></td></tr>
<tr><td><b>Alert</b></font></td><td class="red">' . $alert['alert_message'] . '</font></td></tr>
<tr><td><b>Entity</b></font></td><td>' . generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']) . '</font></td></tr>';
if (strlen($entity['entity_descr']) > 0) {
$message .= '<tr><td><b>Descr</b></font></td><td>' . $entity['entity_descr'] . '</font>';
}
$message .= '
<tr><td><b>Metrics</b></font></td><td>' . $metric_text . '</font></td></tr>
<tr><td><b>Duration</b></font></td><td>' . formatUptime(time() - $entry['last_failed']) . '</font></td></tr>
<tr><td colspan="2" class="header">Device</td></tr>
<tr><td><b>Device</b></font></td><td>' . generate_device_link($device) . '</font></td></tr>
<tr><td><b>Hardware</b></font></td><td>' . $device['hardware'] . '</font></td></tr>
<tr><td><b>Operating System</b></font></td><td>' . $device['os_text'] . ' ' . $device['version'] . ' ' . $device['features'] . '</font></td></tr>
<tr><td><b>Location</b></font></td><td>' . htmlspecialchars($device['location']) . '</font></td></tr>
<tr><td><b>Uptime</b></font></td><td>' . deviceUptime($device) . '</font></td></tr>
</tbody></table>
</td></tr>
<tr><td>
<center>' . $graphs . '</center></td></tr>
</tbody></table>
</body>
</html>';
alert_notify($device, "RECOVER: [" . $device['hostname'] . "] [" . $alert['entity_type'] . "] [" . $entity['entity_name'] . "] " . $alert['alert_message'], $message);
$update_array['last_recovered'] = time();
$update_array['has_alerted'] = 0;
dbUpdate($update_array, 'alert_table-state', '`alert_table_id` = ?', array($entry['alert_table_id']));
}
if ($entry['alert_status'] == '0') {
echo 'Alert tripped. ';
// Has this been alerted more frequently than the alert interval in the config?
/// FIXME -- this should be configurable per-entity or per-checker
if (time() - $entry['last_alerted'] < $config['alerts']['interval'] && !isset($GLOBALS['spam'])) {
$entry['suppress_alert'] = TRUE;
}
// Check if alert has ignore_until set.
if (is_numeric($entry['ignore_until']) && $entry['ignore_until'] > time()) {
$entry['suppress_alert'] = TRUE;
}
if ($entry['suppress_alert'] != TRUE) {
echo 'Requires notification. ';
$alert = $alert_rules[$entry['alert_test_id']];
$state = json_decode($entry['state'], TRUE);
$conditions = json_decode($alert['conditions'], TRUE);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$condition_text = "";
foreach ($state['failed'] as $failed) {
$condition_text .= $failed['metric'] . " " . $failed['condition'] . " " . $failed['value'] . " (" . $state['metrics'][$failed['metric']] . ")<br />";
}
$graphs = "";
$metric_text = "";
foreach ($state['metrics'] as $metric => $value) {
$metric_text .= $metric . " = " . $value . PHP_EOL . "<br />";
}
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:alerts.inc.php
示例10: print_debug
$vendor_oid = $vendor_oids[$device['os']][str_replace('bgp', 'vendor_', $bgp_oid)];
${$bgp_oid} = $vendor_peers[$peer_ip][$vendor_oid];
}
print_debug("Peer: {$peer_ip} (State = {$bgpPeerState} AdminStatus = {$bgpPeerAdminStatus})");
}
// FIXME I left the eventlog code for now, as soon as alerts send an entry to the eventlog this can go.
if ($bgpPeerFsmEstablishedTime) {
if (!(is_array($config['alerts']['bgp']['whitelist']) && !in_array($peer['bgpPeerRemoteAs'], $config['alerts']['bgp']['whitelist'])) && ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])) {
if ($peer['bgpPeerState'] == $bgpPeerState) {
log_event('BGP Session flapped: ' . $remote_ip . ' (AS' . $peer['bgpPeerRemoteAs'] . '), time ' . formatUptime($bgpPeerFsmEstablishedTime) . ' ago', $device, 'bgpPeer', $peer['bgpPeer_id']);
} else {
if ($bgpPeerState == "established") {
log_event('BGP Session Up: ' . $remote_ip . ' (AS' . $peer['bgpPeerRemoteAs'] . '), time ' . formatUptime($bgpPeerFsmEstablishedTime) . ' ago', $device, 'bgpPeer', $peer['bgpPeer_id']);
} else {
if ($peer['bgpPeerState'] == "established") {
log_event('BGP Session Down: ' . $remote_ip . ' (AS' . $peer['bgpPeerRemoteAs'] . '), time ' . formatUptime($bgpPeerFsmEstablishedTime) . ' ago.', $device, 'bgpPeer', $peer['bgpPeer_id']);
}
}
}
}
}
check_entity('bgp_peer', $peer, array('bgpPeerState' => $bgpPeerState, 'bgpPeerAdminStatus' => $bgpPeerAdminStatus, 'bgpPeerFsmEstablishedTime' => $bgpPeerFsmEstablishedTime));
$polled = time();
$polled_period = $polled - $peer['bgpPeer_polled'];
if ($debug) {
echo "[ polled {$polled} -> period {$polled_period} ]";
}
$peer_rrd = 'bgp-' . $peer_ip . '.rrd';
$create_rrd = "DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \\\n DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \\\n DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \\\n DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \\\n DS:bgpPeerEstablished:GAUGE:600:0:U ";
rrdtool_create($device, $peer_rrd, $create_rrd);
rrdtool_update($device, "{$peer_rrd}", "N:{$bgpPeerOutUpdates}:{$bgpPeerInUpdates}:{$bgpPeerOutTotalMessages}:{$bgpPeerInTotalMessages}:{$bgpPeerFsmEstablishedTime}");
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:bgp-peers.inc.php
示例11: generate_device_link
$hostname = generate_device_link($device);
if (extension_loaded('mbstring')) {
$location = mb_substr($device['location'], 0, 32, 'utf8');
} else {
$location = substr($device['location'], 0, 32);
}
if ($subformat == 'detail') {
$platform = $device['hardware'] . '<br>' . $device['features'];
$os = $device['os_text'] . '<br>' . $device['version'];
$uptime = formatUptime($device['uptime'], 'short');
$hostname .= '<br>' . $device['sysName'];
if (empty($port_count)) {
$port_count = 0;
$col_port = '';
}
if ($port_count) {
$col_port = '<img src="images/icons/port.png" align="absmiddle"> ' . $port_count . '<br>';
}
if ($sensor_count) {
$col_port .= '<img src="images/icons/sensors.png" align="absmiddle"> ' . $sensor_count;
}
} else {
$platform = $device['hardware'];
$os = $device['os_text'] . ' ' . $device['version'];
$uptime = formatUptime($device['uptime'], 'short');
}
$response[] = array('extra' => $extra, 'msg' => $msg, 'list_type' => $subformat, 'icon' => $image, 'hostname' => $hostname, 'ports' => $col_port, 'hardware' => $platform, 'os' => $os, 'uptime' => $uptime, 'location' => $location, 'actions' => $actions);
}
//end foreach
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
开发者ID:Rosiak,项目名称:librenms,代码行数:31,代码来源:devices.inc.php
示例12: print_success
// Reset RSS/Atom key
if ($vars['atom_key'] == "toggle") {
if (set_user_pref($user_id, 'atom_key', md5(strgen()))) {
print_success('RSS/Atom key updated.');
$prefs = get_user_prefs($user_id);
} else {
print_error('Error generating RSS/Atom key.');
}
}
// Reset API key
if ($vars['api_key'] == "toggle") {
if (set_user_pref($user_id, 'api_key', md5(strgen()))) {
print_success('API key updated.');
$prefs = get_user_prefs($user_id);
} else {
print_error('Error generating API key.');
}
}
}
$atom_key_updated = isset($prefs['atom_key']['updated']) ? formatUptime(time() - strtotime($prefs['atom_key']['updated']), 'shorter') . ' ago' : 'Never';
$api_key_updated = isset($prefs['api_key']['updated']) ? formatUptime(time() - strtotime($prefs['api_key']['updated']), 'shorter') . ' ago' : 'Never';
$filename = $config['html_dir'] . '/pages/preferences/' . $vars['section'] . '.inc.php';
if (is_file($filename)) {
$vars = get_vars('POST');
// Note, on edit pages use only method POST!
include $filename;
} else {
print_error('<h4>Page does not exist</h4>
The requested page does not exist. Please correct the URL and try again.');
}
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:preferences.inc.php
示例13: get_status_array
function get_status_array($status)
{
// Mike: I know that there are duplicated variables, but later will remove global
global $config, $cache;
$max_interval = filter_var($status['max']['interval'], FILTER_VALIDATE_INT, array('options' => array('default' => 24, 'min_range' => 1)));
$max_count = filter_var($status['max']['count'], FILTER_VALIDATE_INT, array('options' => array('default' => 200, 'min_range' => 1)));
$query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D', 'hide_ignored' => TRUE));
$query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I', 'hide_ignored' => TRUE));
// Show Device Status
if ($status['devices']) {
$query = 'SELECT * FROM `devices` AS D ';
$query .= 'WHERE D.`status` = 0' . $query_device_permitted;
$query .= 'ORDER BY D.`hostname` ASC';
$entries = dbFetchRows($query);
foreach ($entries as $device) {
$boxes[] = array('sev' => 100, 'class' => 'Device', 'event' => 'Down', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'));
}
}
// Uptime
if ($status['uptime']) {
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
$query = 'SELECT * FROM `devices` AS D ';
// Since reboot event more complicated than just device uptime less than some time
//$query .= ' WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`uptime` < ' . $config['uptime_warning'];
$query .= ' WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`last_rebooted` > ?';
$query .= $query_device_permitted;
$query .= 'ORDER BY D.`hostname` ASC';
$entries = dbFetchRows($query, array($config['time']['now'] - $config['uptime_warning'] - 10));
foreach ($entries as $device) {
$boxes[] = array('sev' => 10, 'class' => 'Device', 'event' => 'Rebooted', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'), 'location' => $device['location']);
}
}
}
// Ports Down
if ($status['ports'] || $status['neighbours']) {
$status['neighbours'] = $status['neighbours'] && !$status['ports'];
// Disable 'neighbours' if 'ports' already enabled
$query = 'SELECT * FROM `ports` AS I ';
if ($status['neighbours']) {
$query .= 'INNER JOIN `neighbours` as L ON I.`port_id` = L.`port_id` ';
}
$query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
$query .= "WHERE D.`status` = 1 AND D.ignore = 0 AND I.ignore = 0 AND I.deleted = 0 AND I.`ifAdminStatus` = 'up' AND (I.`ifOperStatus` = 'lowerLayerDown' OR I.`ifOperStatus` = 'down') ";
if ($status['neighbours']) {
$query .= ' AND L.`active` = 1 ';
}
$query .= $query_port_permitted;
$query .= ' AND I.`ifLastChange` >= DATE_SUB(NOW(), INTERVAL ' . $max_interval . ' HOUR) ';
if ($status['neighbours']) {
$query .= 'GROUP BY L.`port_id` ';
}
$query .= 'ORDER BY I.`ifLastChange` DESC, D.`hostname` ASC, I.`ifDescr` * 1 ASC ';
$entries = dbFetchRows($query);
$i = 1;
foreach ($entries as $port) {
if ($i > $max_count) {
// Limit to 200 ports on overview page
break;
}
humanize_port($port);
$boxes[] = array('sev' => 50, 'class' => 'Port', 'event' => 'Down', 'device_link' => generate_device_link($port, short_hostname($port['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['port_label'], 13)), 'time' => formatUptime($config['time']['now'] - strtotime($port['ifLastChange'])), 'location' => $device['location']);
}
}
// Ports Errors (only deltas)
if ($status['errors']) {
foreach ($cache['ports']['errored'] as $port_id) {
if (in_array($port_id, $cache['ports']['ignored'])) {
continue;
}
// Skip ignored ports
$port = get_port_by_id($port_id);
$device = device_by_id_cache($port['device_id']);
humanize_port($port);
if ($port['ifInErrors_delta']) {
$port['string'] .= 'Rx: ' . format_number($port['ifInErrors_delta']);
}
if ($port['ifInErrors_delta'] && $port['ifOutErrors_delta']) {
$port['string'] .= ', ';
}
if ($port['ifOutErrors_delta']) {
$port['string'] .= 'Tx: ' . format_number($port['ifOutErrors_delta']);
}
$boxes[] = array('sev' => 75, 'class' => 'Port', 'event' => 'Errors', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['port_label'], 13)), 'time' => $port['string'], 'location' => $device['location']);
}
}
// Services
if ($status['services']) {
$query = 'SELECT * FROM `services` AS S ';
$query .= 'LEFT JOIN `devices` AS D ON S.`device_id` = D.`device_id` ';
$query .= "WHERE S.`service_status` = 'down' AND S.`service_ignore` = 0";
$query .= $query_device_permitted;
$query .= 'ORDER BY D.`hostname` ASC';
$entries = dbFetchRows($query);
foreach ($entries as $service) {
$boxes[] = array('sev' => 50, 'class' => 'Service', 'event' => 'Down', 'device_link' => generate_device_link($service, short_hostname($service['hostname'])), 'entity_link' => $service['service_type'], 'time' => formatUptime($config['time']['now'] - strtotime($service['service_changed']), 'short'), 'location' => $device['location']);
}
}
// BGP
if ($status['bgp']) {
if (isset($config['enable_bgp']) && $config['enable_bgp']) {
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:status.inc.php
示例14: print_events
/**
* Display events.
*
* Display pages with device/port/system events on some formats.
* Examples:
* print_events() - display last 10 events from all devices
* print_events(array('pagesize' => 99)) - display last 99 events from all device
* print_events(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 events from page 3 with pagination header
* print_events(array('pagesize' => 10, 'device' = 4)) - display last 10 events for device_id 4
* print_events(array('short' => TRUE)) - show small block with last events
*
* @param array $vars
* @return none
*
*/
function print_events($vars)
{
// Get events array
$events = get_events_array($vars);
if (!$events['count']) {
// There have been no entries returned. Print the warning.
print_warning('<h4>No eventlog entries found!</h4>');
} else {
// Entries have been returned. Print the table.
$list = array('device' => FALSE, 'port' => FALSE);
if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'eventlog') {
$list['device'] = TRUE;
}
if ($events['short'] || !isset($vars['port']) || empty($vars['port'])) {
$list['port'] = TRUE;
}
$string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
if (!$events['short']) {
$string .= ' <thead>' . PHP_EOL;
$string .= ' <tr>' . PHP_EOL;
$string .= ' <th>Date</th>' . PHP_EOL;
if ($list['device']) {
$string .= ' <th>Device</th>' . PHP_EOL;
}
if ($list['port']) {
$string .= ' <th>Entity</th>' . PHP_EOL;
}
$string .= ' <th>Message</th>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
$string .= ' </thead>' . PHP_EOL;
}
$string .= ' <tbody>' . PHP_EOL;
foreach ($events['entries'] as $entry) {
$icon = geteventicon($entry['message']);
if ($icon) {
$icon = '<img src="images/16/' . $icon . '" />';
}
$string .= ' <tr>' . PHP_EOL;
if ($events['short']) {
$string .= ' <td class="syslog" style="white-space: nowrap">';
$timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
$string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
} else {
$string .= ' <td style="width: 160px">';
$string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
}
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
$string .= ' <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
}
if ($list['port']) {
if ($entry['type'] == 'port') {
$this_if = get_port_by_id_cache($entry['reference']);
$entry['link'] = '<span class="entity">' . generate_port_link($this_if, short_ifname($this_if['label'])) . '</span>';
} else {
$entry['link'] = ucfirst($entry['type']);
}
if (!$events['short']) {
$string .= ' <td>' . $entry['link'] . '</td>' . PHP_EOL;
}
}
if ($events['short']) {
$string .= ' <td class="syslog">' . $entry['link'] . ' ';
} else {
$string .= ' <td>';
}
$string .= htmlspecialchars($entry['message']) . '</td>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
}
$string .= ' </tbody>' . PHP_EOL;
$string .= '</table>';
// Print pagination header
if ($events['pagination_html']) {
$string = $events['pagination_html'] . $string . $events['pagination_html'];
}
// Print events
echo $string;
}
}
开发者ID:skive,项目名称:observium,代码行数:95,代码来源:events.inc.php
示例15: snmp_get_multi
$data = snmp_get_multi($device, $oids, "-OQUst", "SNMPv2-MIB:CISCO-CONFIG-MAN-MIB", mib_dirs(array("cisco")));
$config_age = $data[0];
foreach ($config_age as $key => $val) {
$config_age[$key] = $val / 100;
}
$RunningLastChanged = $config_age['sysUpTime'] - $config_age['ccmHistoryRunningLastChanged'];
$RunningLastChangedTS = time() - $RunningLastChanged;
$RunningLastSaved = $config_age['sysUpTime'] - $config_age['ccmHistoryRunningLastSaved'];
$RunningLastSavedTS = time() - $RunningLastSaved;
$StartupLastChanged = $config_age['sysUpTime'] - $config_age['ccmHistoryStartupLastChanged'];
$StartupLastChangedTS = time() - $StartupLastChanged;
$sysUptimeTS = time() - $config_age['sysUpTime'];
echo 'sysUptime : ' . format_unixtime($sysUptimeTS) . ' | ' . formatUptime($config_age['sysUpTime']) . PHP_EOL;
echo 'Running : ' . format_unixtime($RunningLastChangedTS) . ' | ' . formatUptime($RunningLastChanged) . PHP_EOL;
echo 'Saved : ' . format_unixtime($RunningLastSavedTS) . ' | ' . formatUptime($RunningLastSaved) . PHP_EOL;
echo 'Startup : ' . format_unixtime($StartupLastChangedTS) . ' | ' . formatUptime($StartupLastChanged) . PHP_EOL;
# 7200 and IOS-XE (ASR1k)
if (preg_match('/^Cisco IOS Software, .+? Software \\([^\\-]+-([^\\-]+)-\\w\\),.+?Version ([^, ]+)/', $poll_device['sysDescr'], $regexp_result)) {
$features = $regexp_result[1];
$version = $regexp_result[2];
} elseif (preg_match('/Cisco Internetwork Operating System Software\\s+IOS \\(tm\\) [^ ]+ Software \\([^\\-]+-([^\\-]+)-\\w\\),.+?Version ([^, ]+)/', $poll_device['sysDescr'], $regexp_result)) {
$features = $regexp_result[1];
$version = $regexp_result[2];
} elseif (is_array($entPhysical)) {
if ($entPhysical['entPhysicalContainedIn'] === '0') {
if (!empty($entPhysical['entPhysicalSoftwareRev'])) {
$version = $entPhysical['entPhysicalSoftwareRev'];
}
if (!empty($entPhysical['entPhysicalModelName'])) {
$hardware = $entPhysical['entPhysicalModelName'];
} else {
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:ios.inc.php
示例16: overlib
$graph_type = "bgp_updates";
$peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=" . $config['time']['day'] . "&to=" . $config['time']['now'] . "&width=500&height=150";
$peeraddresslink = "<span class=list-large><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\\'{$peer_daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . "</a></sp
|
请发表评论