$sql = 'SELECT * FROM `bgpPeers` AS B LEFT JOIN `bgpPeers-state` AS S ON B.bgpPeer_id = S.bgpPeer_id WHERE `device_id` = ? ' . $where . ' ORDER BY `bgpPeerRemoteAs`, `bgpPeerRemoteAddr`'; foreach (dbFetchRows($sql, array($device['device_id'])) as $peer) { $peer['bgpLocalAs'] = $device['bgpLocalAs']; humanize_bgp($peer); $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM mac_accounting AS M\n LEFT JOIN `ip_mac` AS I ON M.mac = I.mac_address\n WHERE I.ip_address = ?", array($peer['bgpPeerRemoteAddr'])); unset($peerhost, $peername); $ip_version = strstr($peer['bgpPeerRemoteAddr'], ':') ? 'ipv6' : 'ipv4'; $peerhost = dbFetchRow('SELECT * FROM ' . $ip_version . '_addresses AS A LEFT JOIN ports AS I ON A.port_id = I.port_id LEFT JOIN devices AS D ON I.device_id = D.device_id WHERE A.' . $ip_version . '_address = ?', array($peer['bgpPeerRemoteAddr'])); if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname']), array('tab' => 'routing', 'proto' => 'bgp')); } else { unset($peername); } unset($sep); foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerRemoteAddr = ?", array($device['device_id'], $peer['bgpPeerRemoteAddr'])) as $afisafi) { $afi = $afisafi['afi']; $safi = $afisafi['safi']; $this_afisafi = $afi . $safi; $peer['afi'] .= $sep . $afi . "." . $safi; $sep = "<br />"; $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer } $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";
$serviceLabelOld = 'availability-map-oldview-box-down'; $serviceState = "down"; $service_down_count++; } } } if ($config['webui']['availability_map_compact'] == 0) { if ($directpage == "yes") { $deviceIcon = getImage($service); $temp_output[] = ' <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"> <div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_direct_tile_size'] . 'px;"> <span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span> <span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span> <span class="device-icon">' . $deviceIcon . '</span><br> <span class="small">' . shorthost(ip_to_sysname($service, $service['hostname'])) . '</span> </div> </a>'; } else { $temp_output[] = ' <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"> <span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $service['service_type'] . ' - ' . $serviceState . '</span> </a>'; } } else { $temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"><div class="' . $serviceLabelOld . '" style="width:' . $compact_tile . 'px;"></div></a>'; } } } else { $temp_output[] = ''; }
} $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_ident . '</a></span>'; echo '<tr class="bgp"' . ($peer['alert'] ? ' bordercolor="#cc0000"' : '') . ($peer['disabled'] ? ' bordercolor="#cccccc"' : '') . '>'; unset($sep); foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { $afi = $afisafi['afi']; $safi = $afisafi['safi']; $this_afisafi = $afi . $safi; $peer['afi'] .= $sep . $afi . '.' . $safi; $sep = '<br />'; $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer } unset($sep); echo ' <td></td> <td width=150>' . $localaddresslink . '<br />' . generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')) . '</td> <td width=30><b>»</b></td> <td width=150>' . $peeraddresslink . "</td>\n <td width=50><b>{$peer_type}</b></td>\n <td width=50>" . $peer['afi'] . '</td> <td><strong>AS' . $peer['bgpPeerRemoteAs'] . '</strong><br />' . $peer['astext'] . "</td>\n <td><strong><span style='color: {$admin_col};'>" . $peer['bgpPeerAdminStatus'] . "</span><br /><span style='color: {$col};'>" . $peer['bgpPeerState'] . '</span></strong></td> <td>' . formatUptime($peer['bgpPeerFsmEstablishedTime']) . "<br />\n Updates <img src='images/16/arrow_down.png' align=absmiddle /> " . format_si($peer['bgpPeerInUpdates']) . "\n <img src='images/16/arrow_up.png' align=absmiddle /> " . format_si($peer['bgpPeerOutUpdates']) . '</td></tr>'; unset($invalid); switch ($vars['graph']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': list(, $afisafi) = explode('_', $vars['graph']); if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; }
foreach (dbFetchRows($sql, $param) as $alertlog) { $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); $alert_state = $alertlog['state']; if ($alert_state == '0') { $fa_icon = 'check'; $fa_color = 'success'; $text = 'Ok'; } elseif ($alert_state == '1') { $fa_icon = 'times'; $fa_color = 'danger'; $text = 'Alert'; } elseif ($alert_state == '2') { $fa_icon = 'info-circle'; $fa_color = 'muted'; $text = 'Ack'; } elseif ($alert_state == '3') { $fa_icon = 'arrow-down'; $fa_color = 'warning'; $text = 'Worse'; } elseif ($alert_state == '4') { $fa_icon = 'arrow-up'; $fa_color = 'info'; $text = 'Better'; } //end if $response[] = array('id' => $rulei++, 'time_logged' => $alertlog['humandate'], 'details' => '<a class="fa fa-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident' . $rulei . '" data-parent="#alerts"></a>', 'hostname' => '<div class="incident">' . generate_device_link($dev, shorthost($dev['hostname'])) . '<div id="incident' . $rulei . '" class="collapse">' . $fault_detail . '</div></div>', 'alert' => htmlspecialchars($alertlog['alert']), 'status' => "<b><i class='fa fa-" . $fa_icon . " text-" . $fa_color . "'></i> {$text}</b>"); } //end foreach $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
<?php $hostname = gethostbyid($entry['host']); unset($icon); $icon = geteventicon($entry['message']); if ($icon) { $icon = '<img src="images/16/' . $icon . '" />'; } echo '<tr> <td> ' . $entry['datetime'] . ' </td>'; if (!isset($vars['device'])) { $dev = device_by_id_cache($entry['host']); echo '<td> ' . generate_device_link($dev, shorthost($dev['hostname'])) . ' </td>'; } if ($entry['type'] == 'interface') { $this_if = ifLabel(getifbyid($entry['reference'])); $entry['link'] = '<b>' . generate_port_link($this_if, makeshortif(strtolower($this_if['label']))) . '</b>'; } else { $entry['link'] = 'System'; } echo '<td>' . $entry['link'] . '</td>'; echo '<td>' . $entry['message'] . '</td> </tr>';
} if ($int_links_v4[$int_link]) { echo " <b style='color: #00a100'>v4</b>"; } $br = "<br />"; } } # unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br); } if ($port_details && $config['enable_port_relationship'] === TRUE) { foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) { #`port_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid` $pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id'])); $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, pseudowires AS P WHERE I.device_id = ? AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pseudowire['peer_device_id'], $pseudowire['cpwVcID'])); $pw_peer_int = ifNameDescr($pw_peer_int); echo "{$br}<img src='images/16/arrow_switch.png' align=absmiddle><b> " . generate_port_link($pw_peer_int, makeshortif($pw_peer_int['label'])) . " on " . generate_device_link($pw_peer_dev, shorthost($pw_peer_dev['hostname'])) . "</b>"; $br = "<br />"; } foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) { echo "{$br}<img src='images/16/brick_link.png' align=absmiddle> <strong>" . generate_port_link($member) . " (PAgP)</strong>"; $br = "<br />"; } if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) { $parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($port['pagpGroupIfIndex'], $device['device_id'])); echo "{$br}<img src='images/16/bricks.png' align=absmiddle> <strong>" . generate_port_link($parent) . " (PAgP)</strong>"; $br = "<br />"; } foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) { if ($higher_if['port_id_high']) { $this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']); echo "{$br}<img src='images/16/arrow_divide.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>";
<?php /* * LibreNMS front page top devices graph * - Find most utilised devices that have been polled in the last N minutes * * Author: Paul Gear * Copyright (c) 2013 Gear Consulting Pty Ltd <http://libertysys.com.au/> * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ $minutes = 15; $seconds = $minutes * 60; $top = $config['front_page_settings']['top']['devices']; if (is_admin() === true || is_read() === true) { $query = "\n SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total\n FROM ports as p, devices as d\n WHERE d.device_id = p.device_id\n AND unix_timestamp() - p.poll_time < {$seconds}\n AND ( p.ifInOctets_rate > 0\n OR p.ifOutOctets_rate > 0 )\n GROUP BY d.device_id\n ORDER BY total desc\n LIMIT {$top}\n "; } else { $query = "\n SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total\n FROM ports as p, devices as d, `devices_perms` AS `P`\n WHERE `P`.`user_id` = ? AND `P`.`device_id` = `d`.`device_id` AND\n d.device_id = p.device_id\n AND unix_timestamp() - p.poll_time < {$seconds}\n AND ( p.ifInOctets_rate > 0\n OR p.ifOutOctets_rate > 0 )\n GROUP BY d.device_id\n ORDER BY total desc\n LIMIT {$top}\n "; $param[] = array($_SESSION['user_id']); } //end if echo "<strong>Top {$top} devices (last {$minutes} minutes)</strong>\n"; echo "<table class='simple'>\n"; foreach (dbFetchRows($query, $param) as $result) { echo '<tr class=top10>' . '<td class=top10>' . generate_device_link($result, shorthost($result['hostname'])) . '</td>' . '<td class=top10>' . generate_device_link($result, generate_minigraph_image($result, $config['time']['day'], $config['time']['now'], 'device_bits', 'no', 150, 21, '&', 'top10'), array(), 0, 0, 0) . '</td>' . "</tr>\n"; } echo "</table>\n";
$sql = 'FROM syslog AS S'; $sql .= ' WHERE ' . $where; } else { $sql = 'FROM syslog AS S, devices_perms AS P '; $sql .= 'WHERE S.device_id = P.device_id AND P.user_id = ? AND '; $sql .= $where; $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) {$sql}"; $total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } if (!isset($sort) || empty($sort)) { $sort = 'timestamp DESC'; } $sql .= " ORDER BY {$sort}"; if (isset($current)) { $limit_low = $current * $rowCount - $rowCount; $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT {$limit_low},{$limit_high}"; } $sql = "SELECT S.*, DATE_FORMAT(timestamp, '" . $config['dateformat']['mysql']['compact'] . "') AS date {$sql}"; foreach (dbFetchRows($sql, $param) as $syslog) { $dev = device_by_id_cache($syslog['device_id']); $response[] = array('priority' => generate_priority_icon($syslog['priority']), 'timestamp' => '<div style="white-space:nowrap;">' . $syslog['date'] . '</div>', 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), 'program' => $syslog['program'], 'msg' => htmlspecialchars($syslog['msg'])); } $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"> <div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_box_size'] . 'px;"> <span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span> <span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span> <span class="device-icon">' . $deviceIcon . '</span><br> <span class="small">' . shorthost(ip_to_sysname($service, $service['hostname'])) . '</span> </div> </a>'; } else { $serviceText = $service['service_type'] . ' - ' . $serviceState; if ($widget_settings['color_only_select'] == 1) { $serviceText = ' '; $serviceLabel .= ' widget-availability-fixed'; } $temp_output[] = ' <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . shorthost(ip_to_sysname($device, $device['hostname'])) . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"> <span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $serviceText . '</span> </a>'; } } else { $temp_output[] = "<a href='" . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . "' title='{$service['hostname']} - {$service['service_type']} - {$service['service_desc']}'><div class='" . $serviceLabelOld . "' style='width:{$compact_tile}px;height:{$compact_tile}px;'></div></a>"; } } } else { $temp_output[] = ''; } } if ($directpage == "yes") { $temp_header[] = ' <div class="page-availability-title-left"> <span class="page-availability-title">Availability map for</span>
<?php /* * LibreNMS front page top devices graph * - Find most utilised devices that have been polled in the last N minutes * * Copyright (c) 2013 Gear Consulting Pty Ltd <http://libertysys.com.au/> * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ $minutes = 15; $seconds = $minutes * 60; $top = $config['front_page_settings']['top']['devices']; $query = "\n SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total\n FROM ports as p, devices as d\n WHERE d.device_id = p.device_id\n AND unix_timestamp() - p.poll_time < {$seconds}\n AND ( p.ifInOctets_rate > 0\n OR p.ifOutOctets_rate > 0 )\n GROUP BY d.device_id\n ORDER BY total desc\n LIMIT {$top}\n"; echo "<strong>Top {$top} devices (last {$minutes} minutes)</strong>\n"; echo "<table class='simple'>\n"; foreach (dbFetchRows($query) as $result) { echo "<tr class=top10>" . "<td class=top10>" . generate_device_link($result, shorthost($result['hostname'])) . "</td>" . "<td class=top10>" . generate_device_link($result, generate_minigraph_image($result, $config['time']['day'], $config['time']['now'], "device_bits", "no", 150, 21, '&', "top10"), array(), 0, 0, 0) . "</td>" . "</tr>\n"; } echo "</table>\n";
$port = get_port_by_id($_GET['id']); $device = device_by_id_cache($port['device_id']); $title = generate_device_link($device); $title .= " :: Port " . generate_port_link($port); $auth = TRUE; } else { echo "Unauthenticad"; die; } header("Content-type: image/svg+xml"); /********** HTTP GET Based Conf ***********/ $ifnum = @$port['ifIndex']; // BSD / SNMP interface name / number $ifname = @$port['ifDescr']; //Interface name that will be showed on top right of graph $hostname = shorthost($device['hostname']); if ($_GET['title']) { $ifname = $_GET['title']; } /********* Other conf *******/ $scale_type = "follow"; //Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas $nb_plot = 240; //NB plot in graph if (is_numeric($_GET['interval'])) { $time_interval = $_GET['interval']; } else { $time_interval = 1; //Refresh time Interval } $fetch_link = "data.php?id=" . $_GET['id'];
<?php $graph_array['height'] = "100"; $graph_array['width'] = "220"; $graph_array['to'] = $config['time']['now']; $graph_array['from'] = $config['time']['day']; $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; $graph_array['legend'] = "no"; echo '<h2>' . nicecase($vars['app']) . '</h2>'; echo '<table cellpadding=5 cellspacing=0 class=devicetable width=100%>'; $app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($vars['app'])); foreach ($app_devices as $app_device) { echo '<tr class="list-device">'; echo '<td class="device-head" width=300px>' . generate_device_link($app_device, shorthost($app_device['hostname']), array('tab' => 'apps', 'app' => $vars['app'])) . '</td>'; echo '<td class="device-head" width=100px>' . $app_device['app_instance'] . '</td>'; echo '<td class="device-head" width=100px>' . $app_device['app_status'] . '</td>'; echo '<td></td>'; echo '</tr>'; echo '<tr class="list-device">'; echo '<td colspan=4>'; foreach ($graphs[$vars['app']] as $graph_type) { $graph_array['type'] = "application_" . $vars['app'] . "_" . $graph_type; $graph_array['id'] = $app_device['app_id']; $graph_array_zoom['type'] = "application_" . $vars['app'] . "_" . $graph_type; $graph_array_zoom['id'] = $app_device['app_id']; $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'], 'tab' => 'apps', 'app' => $vars['app'])); echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); } echo '</td>';
<?php $hostname = gethostbyid($alert_entry['device_id']); $alert_state = $alert_entry['state']; echo '<tr> <td> ' . $alert_entry['time_logged'] . ' </td>'; if (!isset($alert_entry['device'])) { $dev = device_by_id_cache($alert_entry['device_id']); echo "<td>\n " . generate_device_link($dev, shorthost($dev['hostname'])) . "\n </td>"; } echo "<td>" . htmlspecialchars($alert_entry['name']) . "</td>"; if ($alert_state != '') { if ($alert_state == '0') { $glyph_icon = 'ok'; $glyph_color = 'green'; $text = 'Ok'; } elseif ($alert_state == '1') { $glyph_icon = 'remove'; $glyph_color = 'red'; $text = 'Alert'; } elseif ($alert_state == '2') { $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; $text = 'Ack'; } elseif ($alert_state == '3') { $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; $text = 'Worse'; } elseif ($alert_state == '4') {
} else { if ($alert_state == '1') { $glyph_icon = 'remove'; $glyph_color = 'red'; $text = 'Alert'; } else { if ($alert_state == '2') { $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; $text = 'Ack'; } else { if ($alert_state == '3') { $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; $text = 'Worse'; } else { if ($alert_state == '4') { $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; $text = 'Better'; } } } } } //end if $response[] = array('id' => $rulei++, 'time_logged' => $alertlog['humandate'], 'details' => '<a class="glyphicon glyphicon-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident' . $rulei . '" data-parent="#alerts"></a>', 'hostname' => '<div class="incident">' . generate_device_link($dev, shorthost($dev['hostname'])) . '<div id="incident' . $rulei . '" class="collapse">' . $fault_detail . '</div></div>', 'alert' => $alertlog['alert'], 'status' => "<b><span class='glyphicon glyphicon-" . $glyph_icon . "' style='color:" . $glyph_color . "'></span> {$text}</b>"); } //end foreach $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
} if ($_SESSION['userlevel'] == '10') { $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0"); } else { $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0"); } while ($peer = mysql_fetch_array($sql)) { generate_front_box("alert", "<center><strong>" . generatedevicelink($peer, shorthost($peer['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span> \n <span style='" . (strstr($peer['bgpPeerIdentifier'], ':') ? 'font-size: 10px' : '') . "'><strong>" . $peer['bgpPeerIdentifier'] . "</strong></span><br />\n <span title='" . $peer['astext'] . "' class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n </center>"); } if ($_SESSION['userlevel'] == '10') { $sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime < '84600' AND D.ignore = 0"); } else { $sql = mysql_query("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 < '84600' AND D.ignore = 0"); } while ($device = mysql_fetch_array($sql)) { generate_front_box("info", "<center><strong>" . generatedevicelink($device, shorthost($device['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />\n <span class=body-date-1>" . formatUptime($device['uptime'], 'short') . "</span>\n </center>"); } if ($config['enable_syslog']) { ## Open Syslog Div echo "<div style='margin: 4px; clear: both; padding: 5px;'> \n <h3>Recent Syslog Messages</h3>\n "; if ($_SESSION['userlevel'] == '10') { $sql = "SELECT *,DATE_FORMAT(timestamp, '%D %b %T') as date FROM `syslog` ORDER BY `timestamp` DESC LIMIT 0,15"; } else { $sql = "SELECT *,DATE_FORMAT(timestamp, '%D %b %T') as date FROM `syslog` AS E, devices_perms AS P WHERE\n E.device_id = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `timestamp` DESC LIMIT 0,15"; } $query = mysql_query($sql); echo "<table cellspacing=0 cellpadding=2 width=100%>"; while ($entry = mysql_fetch_array($query)) { $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); include "includes/print-syslog.inc"; }
<?php // Generate a list of ports and then call the multi_bits grapher to generate from the list $i = 0; if (!is_array($config['customers_descr'])) { $config['customers_descr'] = array($config['customers_descr']); } $descr_type = "'" . implode("', '", $config['customers_descr']) . "'"; foreach (dbFetchRows('SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id', array(array($descr_type), $vars['id'])) as $port) { if (is_file($config['rrd_dir'] . '/' . $port['hostname'] . '/port-' . safename($port['ifIndex'] . '.rrd'))) { $rrd_filename = $config['rrd_dir'] . '/' . $port['hostname'] . '/port-' . safename($port['ifIndex'] . '.rrd'); $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $port['hostname'] . '-' . $port['ifDescr']; $rrd_list[$i]['descr_in'] = shorthost($port['hostname']); $rrd_list[$i]['descr_out'] = makeshortif($port['ifDescr']); $i++; } } // echo($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd")); $units = 'bps'; $total_units = 'B'; $colours_in = 'greens'; $multiplier = '8'; $colours_out = 'blues'; $nototal = 1; $ds_in = 'INOCTETS'; $ds_out = 'OUTOCTETS'; require 'includes/graphs/generic_multi_bits_separated.inc.php';
$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></span>"; echo '<tr class="bgp"' . ($peer['alert'] ? ' bordercolor="#cc0000"' : '') . ($peer['disabled'] ? ' bordercolor="#cccccc"' : '') . ">"; unset($sep); foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { $afi = $afisafi['afi']; $safi = $afisafi['safi']; $this_afisafi = $afi . $safi; $peer['afi'] .= $sep . $afi . "." . $safi; $sep = "<br />"; $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer } unset($sep); echo " <td></td>\n <td width=150>" . $localaddresslink . "<br />" . generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')) . "</td>\n <td width=30><b>»</b></td>\n <td width=150>" . $peeraddresslink . "</td>\n <td width=50><b>{$peer_type}</b></td>\n <td width=50>" . $peer['afi'] . "</td>\n <td><strong>AS" . $peer['bgpPeerRemoteAs'] . "</strong><br />" . $peer['astext'] . "</td>\n <td><strong><span style='color: {$admin_col};'>" . $peer['bgpPeerAdminStatus'] . "</span><br /><span style='color: {$col};'>" . $peer['bgpPeerState'] . "</span></strong></td>\n <td>" . formatUptime($peer['bgpPeerFsmEstablishedTime']) . "<br />\n Updates <img src='images/16/arrow_down.png' align=absmiddle /> " . format_si($peer['bgpPeerInUpdates']) . "\n <img src='images/16/arrow_up.png' align=absmiddle /> " . format_si($peer['bgpPeerOutUpdates']) . "</td></tr>"; unset($invalid); switch ($vars['graph']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': list(, $afisafi) = explode("_", $vars['graph']); if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } case 'updates': $graph_array['type'] = "bgp_" . $vars['graph']; $graph_array['id'] = $peer['bgpPeer_id']; }
<?php require 'includes/graphs/device/auth.inc.php'; if ($auth && is_numeric($_GET['mod']) && is_numeric($_GET['chan'])) { $entity = dbFetchRow('SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $_GET['mod'])); $title .= ' :: ' . $entity['entPhysicalName']; $title .= ' :: Fabric ' . $_GET['chan']; $graph_title = shorthost($device['hostname']) . '::' . $entity['entPhysicalName'] . '::Fabric' . $_GET['chan']; $rrd_filename = rrd_name($device['hostname'], array('c6kxbar', $_GET['mod'], $_GET['chan'])); }
$sql .= " AND (`D`.`hostname` LIKE '%{$searchPhrase}%' OR `E`.`datetime` LIKE '%{$searchPhrase}%' OR `E`.`message` LIKE '%{$searchPhrase}%' OR `E`.`type` LIKE '%{$searchPhrase}%')"; } $count_sql = "SELECT COUNT(datetime) {$sql}"; $total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } if (!isset($sort) || empty($sort)) { $sort = 'datetime DESC'; } $sql .= " ORDER BY {$sort}"; if (isset($current)) { $limit_low = $current * $rowCount - $rowCount; $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT {$limit_low},{$limit_high}"; } $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate {$sql}"; foreach (dbFetchRows($sql, $param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); if ($eventlog['type'] == 'interface') { $this_if = ifLabel(getifbyid($eventlog['reference'])); $type = '<b>' . generate_port_link($this_if, makeshortif(strtolower($this_if['label']))) . '</b>'; } else { $type = $eventlog['type']; } $response[] = array('datetime' => $eventlog['humandate'], 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), 'type' => $type, 'message' => htmlspecialchars($eventlog['message'])); } $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
$sql = "FROM syslog AS S"; $sql .= " WHERE " . $where; } else { $sql = "FROM syslog AS S, devices_perms AS P"; $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; $sql .= $where; $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) {$sql}"; $total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } if (!isset($sort) || empty($sort)) { $sort = 'timestamp DESC'; } $sql .= " ORDER BY {$sort}"; if (isset($current)) { $limit_low = $current * $rowCount - $rowCount; $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT {$limit_low},{$limit_high}"; } $sql = "SELECT S.*, DATE_FORMAT(timestamp, '" . $config['dateformat']['mysql']['compact'] . "') AS date {$sql}"; foreach (dbFetchRows($sql, $param) as $syslog) { $dev = device_by_id_cache($syslog['device_id']); $response[] = array('timestamp' => $syslog['date'], 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), 'program' => $syslog['program'], 'msg' => htmlspecialchars($syslog['msg'])); } $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
LIMIT :count '; } $common_output[] = ' <h4>Top ' . $interface_count . ' interfaces polled within ' . $interval . ' minutes</h4> <div class="table-responsive"> <table class="table table-hover table-condensed table-striped bootgrid-table"> <thead> <tr> <th class="text-left">Device</th> <th class="text-left">Interface</th> <th class="text-left">Total traffic</a></th> </tr> </thead> <tbody> '; foreach (dbFetchRows($query, $params) as $result) { $common_output[] = ' <tr> <td class="text-left">' . generate_device_link($result, shorthost($result['hostname'])) . '</td> <td class="text-left">' . generate_port_link($result, shorten_interface_type($result['ifName'])) . '</td> <td class="text-left">' . generate_port_link($result, generate_port_thumbnail($result)) . '</td> </tr> '; } $common_output[] = ' </tbody> </table> </div> '; }
<?php if (is_numeric($vars['id']) && ($auth || port_permitted($vars['id']))) { $port = get_port_by_id($vars['id']); $device = device_by_id_cache($port['device_id']); $title = generate_device_link($device); $title .= " :: Port " . generate_port_link($port); $graph_title = shorthost($device['hostname']) . "::" . strtolower(makeshortif($port['ifDescr'])); $auth = TRUE; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"); }
<?php /* * LibreNMS front page top ports graph * - Find most utilised ports that have been polled in the last N minutes * * Author: Paul Gear * Copyright (c) 2013 Gear Consulting Pty Ltd <http://libertysys.com.au/> * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ $minutes = 15; $seconds = $minutes * 60; $top = $config['front_page_settings']['top']['ports']; if (is_admin() === true || is_read() === true) { $query = "\n SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total\n FROM ports as p, devices as d\n WHERE d.device_id = p.device_id\n AND unix_timestamp() - p.poll_time < {$seconds}\n AND ( p.ifInOctets_rate > 0\n OR p.ifOutOctets_rate > 0 )\n ORDER BY total desc\n LIMIT {$top}\n "; } else { $query = "\n SELECT *, I.ifInOctets_rate + I.ifOutOctets_rate as total\n FROM ports as I, devices as d,\n `devices_perms` AS `P`, `ports_perms` AS `PP`\n WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `d`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `d`.`device_id`)) AND\n d.device_id = I.device_id\n AND unix_timestamp() - I.poll_time < {$seconds}\n AND ( I.ifInOctets_rate > 0\n OR I.ifOutOctets_rate > 0 )\n ORDER BY total desc\n LIMIT {$top}\n "; $param[] = array($_SESSION['user_id'], $_SESSION['user_id']); } //end if echo "<strong>Top {$top} ports (last {$minutes} minutes)</strong>\n"; echo "<table class='simple'>\n"; foreach (dbFetchRows($query, $param) as $result) { echo '<tr class=top10>' . '<td class=top10>' . generate_device_link($result, shorthost($result['hostname'])) . '</td>' . '<td class=top10>' . generate_port_link($result) . '</td>' . '<td class=top10>' . generate_port_link($result, generate_port_thumbnail($result)) . '</td>' . "</tr>\n"; } echo "</table>\n";
$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; foreach ($ports as $port) { if (port_permitted($port['port_id'], $port['device_id'])) { if ($port['ifAdminStatus'] == "down") { $ports_disabled++; } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $ports_down++; } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $ports_up++; } $ports_total++; $speed = humanspeed($port['ifSpeed']); $type = humanmedia($port['ifType']); $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); if (isset($port['in_errors']) && $port['in_errors'] > 0 || isset($ports['out_errors']) && $port['out_errors'] > 0) { $error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors); } else { $error_img = ""; } $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); $port = ifLabel($port, $device); echo "<tr class='ports'>\n <td width=200 class=list-bold>" . generate_device_link($port, shorthost($port['hostname'], "20")) . "</td>\n <td width=150 class=list-bold><a class='" . $ifclass . "'href='" . generate_port_url($port) . "'>" . fixIfName($port['label']) . " {$error_img}</td>\n <td width=110 >{$speed}</td>\n <td width=100 class=green>" . $port['in_rate'] . "</td>\n <td width=100 class=blue>" . $port['out_rate'] . "</td>\n <td width=150>{$type}</td>\n <td>" . $port['ifAlias'] . "</td>\n </tr>\n"; } } echo '<tr><td colspan="7">'; echo "<strong>Matched Ports: {$ports_total} ( <span class=green>Up {$ports_up}</span> | <span class=red>Down {$ports_down}</span> | Disabled {$ports_disabled} )</strong>"; echo '</td></tr></table>';
$x = 1; foreach ($vrf_devices[$vrf['mplsVpnVrfRouteDistinguisher']] as $device) { if ($i % 2) { if ($x % 2) { $dev_colour = $list_colour_a_a; } else { $dev_colour = $list_colour_a_b; } } else { if ($x % 2) { $dev_colour = $list_colour_b_b; } else { $dev_colour = $list_colour_b_a; } } echo "<tr bgcolor='{$dev_colour}'><td width=150>" . generate_device_link($device, shorthost($device['hostname'])); if ($device['vrf_name'] != $vrf['vrf_name']) { echo "<a href='#' onmouseover=\" return overlib('Expected Name : " . $vrf['vrf_name'] . '<br />Configured : ' . $device['vrf_name'] . "', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>"; } echo '</td><td>'; unset($seperator); foreach ($ports[$device['vrf_id']][$device['device_id']] as $port) { $port = array_merge($device, $port); switch ($_GET['optc']) { case 'bits': case 'upkts': case 'nupkts': case 'errors': $port['width'] = '130'; $port['height'] = '30'; $port['from'] = $config['time']['day'];
foreach ($app_list as $app) { echo '<div style="clear: both;">'; echo '<h2>' . generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])) . '</h2>'; $app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($app['app_type'])); foreach ($app_devices as $app_device) { $graph_type = $graphs[$app['app_type']][0]; $graph_array['type'] = "application_" . $app['app_type'] . "_" . $graph_type; $graph_array['id'] = $app_device['app_id']; $graph_array_zoom['type'] = "application_" . $app['app_type'] . "_" . $graph_type; $graph_array_zoom['id'] = $app_device['app_id']; $link_array = $graph_array; $link_array['page'] = "device"; $link_array['device'] = $app_device['device_id']; $link_array['tab'] = "apps"; $link_array['app'] = $app['app_type']; unset($link_array['height'], $link_array['width']); $overlib_url = generate_url($link_array); $overlib_link = '<span style="float:left; margin-left: 10px; font-weight: bold;">' . shorthost($app_device['hostname']) . "</span>"; if (!empty($app_device['app_instance'])) { $overlib_link .= '<span style="float:right; margin-right: 10px; font-weight: bold;">' . $app_device['app_instance'] . "</span>"; $app_device['content_add'] = '(' . $app_device['app_instance'] . ')'; } $overlib_link .= "<br/>"; $overlib_link .= generate_graph_tag($graph_array); $overlib_content = generate_overlib_content($graph_array, $app_device['hostname'] . " - " . $app_device['app_type'] . $app_device['content_add']); echo "<div style='display: block; padding: 1px; padding-top: 3px; margin: 2px; min-width: " . $width_div . "px; max-width:" . $width_div . "px; min-height:165px; max-height:165px;\n text-align: center; float: left; background-color: #f5f5f5;'>"; echo overlib_link($overlib_url, $overlib_link, $overlib_content); echo "</div>"; } echo '</div>'; }
} foreach (dbFetchRows($sql) as $peer) { 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>
} $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND D.status = '1' AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); while ($interface = mysql_fetch_array($sql)) { echo "<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n <center><strong>" . generatedevicelink($interface, shorthost($interface['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span> \n <strong>" . generateiflink($interface, makeshortif($interface['ifDescr'])) . "</strong> <br />\n <span class=body-date-1>" . truncate($interface['ifAlias'], 20) . "</span>\n </center></div>"; } $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND D.status = '1' AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); while ($service = mysql_fetch_array($sql)) { echo "<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n <center><strong>" . generatedevicelink($service, shorthost($service['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span> \n <strong>" . $service['service_type'] . "</strong><br />\n <span class=body-date-1>" . truncate($interface['ifAlias'], 20) . "</span>\n </center></div>"; } $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE D.status = '1' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); while ($peer = mysql_fetch_array($sql)) { echo "<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n <center><strong>" . generatedevicelink($peer, shorthost($peer['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span> \n <strong>" . $peer['bgpPeerIdentifier'] . "</strong> <br />\n <span class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n </center></div>"; } $sql = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND `uptime` < '84600'"); while ($device = mysql_fetch_array($sql)) { echo "<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>\n <center><strong>" . generatedevicelink($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['uptime']) . "</span>\n </center></div>"; } echo "\n\n\t<div style='clear: both;'>{$errorboxes}</div> <div style='margin: 4px; clear: both;'> \n\n<h3>Recent Syslog Messages</h3>\n\n"; $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog AS S, devices AS D \n WHERE S.device_id = D.device_id ORDER BY timestamp DESC LIMIT 20"; $query = mysql_query($sql); echo "<table cellspacing=0 cellpadding=2 width=100%>"; while ($entry = mysql_fetch_array($query)) { include "includes/print-syslog.inc"; } echo "</table>"; echo "</div>\n\n </td>\n <td bgcolor=#e5e5e5 width=275 valign=top>"; /// this stuff can be customised to show whatever you want.... #if($_SESSION['userlevel'] >= '5') { echo "<a onmouseover=\"return overlib('<img src=\\'graph.php?type=bits&if=36" . "&from=" . $day . "&to=" . $now . "&width=400&height=150\\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >" . "<div style='font-size: 18px; font-weight: bold;'>Alpha Traffic</div>" . "<img src='graph.php?type=bits&if=36" . "&from=" . $day . "&to=" . $now . "&width=200&height=100'></a>"; echo "<div style='clear: both; margin-top: 10px;'></div>"; echo "<a onmouseover=\"return overlib('<img src=\\'graph.php?type=hrstorage&id=54" . "&from=" . $day . "&to=" . $now . "&width=400&height=150\\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >" . "<div style='font-size: 18px; font-weight: bold;'>Alpha Storage</div>" . "<img src='graph.php?type=hrstorage&id=54" . "&from=" . $day . "&to=" . $now . "&width=200&height=100'></a>";
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);
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT " . $config['front_page_down_box_limit']; } foreach (dbFetchRows($sql) as $peer) { 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 />\n <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 ($_SESSION['userlevel'] >= '10') { $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 />\n <span class=device-rebooted>Device Rebooted</span><br />\n <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\n 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']) { echo ' <div class="col-md-3">';