if ($_POST['hardware']) { $where .= " AND hardware = '" . $_POST['hardware'] . "'"; } if ($_POST['features']) { $where .= " AND features = '" . $_POST['features'] . "'"; } if ($_POST['location']) { $where .= " AND location = '" . $_POST['location'] . "'"; } if ($_GET['location'] && !isset($_POST['location'])) { $where .= " AND location = '" . $_GET['location'] . "'"; } if ($_GET['type']) { $where = "AND type = '{$_GET['type']}'"; } if ($_GET['location'] == "Unset") { $where .= " AND location = ''"; } $sql = "SELECT * FROM devices WHERE 1 {$where} ORDER BY `ignore`, `status`, `hostname`"; if ($_GET['status'] == "alerted") { $sql = "SELECT * FROM devices " . $device_alert_sql . " GROUP BY `device_id` ORDER BY `ignore`, `status`, `os`, `hostname`"; } echo '<table cellpadding="7" cellspacing="0" class="devicetable" width="100%"> <tr class="tablehead"><th></th><th>Device</th><th>Operating System</th><th>Platform</th><th>Uptime</th></tr>'; $device_query = mysql_query($sql); while ($device = mysql_fetch_array($device_query)) { if (devicepermitted($device['device_id'])) { include "includes/hostbox.inc"; } } echo "</table>";
} $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); while ($service = mysql_fetch_array($sql)) { if (devicepermitted($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>" . generatedevicelink($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 = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); while ($peer = mysql_fetch_array($sql)) { if (devicepermitted($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>" . generatedevicelink($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>"; } } $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); while ($device = mysql_fetch_array($sql)) { if (devicepermitted($device['device_id']) && $device['attrib_value'] < "84600" && $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>" . 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['attrib_value']) . "</span>\n </div>"; } } echo "\n\n\t<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"; $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=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";
function interfacepermitted($interface_id) { global $_SESSION; if ($_SESSION['userlevel'] >= "5") { $allowed = TRUE; } elseif (devicepermitted(mysql_result(mysql_query("SELECT `device_id` FROM `ports` WHERE `interface_id` = '{$interface_id}'"), 0))) { $allowed = TRUE; } elseif (@mysql_result(mysql_query("SELECT `interface_id` FROM `ports_perms` WHERE `user_id` = '" . $_SESSION['user_id'] . "' AND `interface_id` = {$interface_id}"), 0)) { $allowed = TRUE; } else { $allowed = FALSE; } return $allowed; }
<?php if ($_GET['id']) { $_GET['id'] = mres($_GET['id']); } if (devicepermitted($_GET['id'])) { $selected['iface'] = "selected"; if (!$_GET['section']) { $_GET['section'] = "overview"; } $section = mres($_GET['section']); $section = str_replace(".", "", $section); $select[$section] = "selected"; $device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $_GET['id'] . "'"); while ($device = mysql_fetch_array($device_query)) { echo '<table cellpadding="15" cellspacing="0" class="devicetable" width="100%">'; include "includes/device-header.inc.php"; echo "</table>"; echo "<div class=mainpane>"; echo '<ul id="maintab" class="shadetabs">'; if ($config['show_overview_tab']) { echo "\n<li class=" . $select['overview'] . ">\n <a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/overview/'>\n <img src='images/16/server_lightning.png' align=absmiddle border=0> Overview\n </a>\n</li>"; } echo '<li class="' . $select['graphs'] . '"> <a href="' . $config['base_url'] . '/device/' . $device['device_id'] . '/graphs/"> <img src="images/16/server_chart.png" align="absmiddle" border="0"> Graphs </a> </li>'; $health = mysql_result(mysql_query("select count(*) from storage WHERE device_id = '" . $device['device_id'] . "'"), 0) + mysql_result(mysql_query("select count(temp_id) from temperature WHERE device_id = '" . $device['device_id'] . "'"), 0) + mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0) + mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0) + mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0); if ($health) { echo '<li class="' . $select['health'] . '">