mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated most files to use dbFacile
This commit is contained in:
@@ -4,7 +4,7 @@ $param = array();
|
||||
|
||||
if ($vars['action'] == "expunge" && $_SESSION['userlevel'] >= '10')
|
||||
{
|
||||
mysql_query("TRUNCATE TABLE `eventlog`");
|
||||
dbQuery("TRUNCATE TABLE `bill_history`");
|
||||
print_message("Event log truncated");
|
||||
}
|
||||
|
||||
|
@@ -23,12 +23,12 @@ $count_boxes = 0;
|
||||
// Device down boxes
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
|
||||
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `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 = '0' AND D.ignore = '0'");
|
||||
$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 = '0' AND D.ignore = '0'";
|
||||
}
|
||||
while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."<br />
|
||||
<span class=list-device-down>Device Down</span> <br />
|
||||
<span class=body-date-1>".truncate($device['location'], 20)."</span>");
|
||||
@@ -37,9 +37,9 @@ while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
|
||||
} else {
|
||||
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
|
||||
}
|
||||
|
||||
// These things need to become more generic, and more manageable across different frontpages... rewrite inc :>
|
||||
@@ -47,7 +47,7 @@ $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS
|
||||
// Port down boxes
|
||||
if ($config['warn']['ifdown'])
|
||||
{
|
||||
while ($interface = mysql_fetch_assoc($sql))
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
if (!$interface['deleted'])
|
||||
{
|
||||
@@ -64,8 +64,8 @@ if ($config['warn']['ifdown'])
|
||||
|
||||
/* FIXME service permissions? seem nonexisting now.. */
|
||||
// Service down boxes
|
||||
$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_assoc($sql))
|
||||
$sql = "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'";
|
||||
foreach (dbFetchRows($sql) as $service)
|
||||
{
|
||||
generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."<br />
|
||||
<span class=service-down>Service Down</span>
|
||||
@@ -79,11 +79,11 @@ if (isset($config['enable_bgp']) && $config['enable_bgp'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
|
||||
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND 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 bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
|
||||
$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";
|
||||
}
|
||||
while ($peer = mysql_fetch_assoc($sql))
|
||||
foreach (dbFetchRows($sql) as $peer)
|
||||
{
|
||||
generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."<br />
|
||||
<span class=bgp-down>BGP Down</span>
|
||||
@@ -98,13 +98,13 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
|
||||
{
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0");
|
||||
$sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' 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 > 0 AND D.uptime < '" .
|
||||
$config['uptime_warning'] . "' AND D.ignore = 0");
|
||||
$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";
|
||||
}
|
||||
|
||||
while ($device = mysql_fetch_assoc($sql))
|
||||
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 />
|
||||
@@ -153,7 +153,7 @@ if ($config['enable_syslog'])
|
||||
</div>
|
||||
<table class="table table-hover table-condensed table-striped">');
|
||||
|
||||
while ($entry = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows($sql) as $entry)
|
||||
{
|
||||
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||
|
||||
@@ -191,7 +191,8 @@ if ($config['enable_syslog'])
|
||||
</div>
|
||||
<table class="table table-hover table-condensed table-striped">');
|
||||
|
||||
while ($entry = mysql_fetch_assoc($data)) {
|
||||
foreach (dbFetchRows($query) as $entry)
|
||||
{
|
||||
include("includes/print-event.inc.php");
|
||||
}
|
||||
|
||||
|
@@ -65,9 +65,10 @@ echo("</tr></table>");
|
||||
|
||||
$nodes = array();
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
|
||||
$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'";
|
||||
|
||||
while ($device = mysql_fetch_array($sql)) {
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
unset($already);
|
||||
$i = 0;
|
||||
while ($i <= count($nodes)) {
|
||||
@@ -80,8 +81,9 @@ while ($device = mysql_fetch_array($sql)) {
|
||||
if (!$already) { $nodes[] = $device['device_id']; }
|
||||
}
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
|
||||
while ($device = mysql_fetch_array($sql)) {
|
||||
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'";
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
if (device_permitted($device['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: #ffbbbb;'>
|
||||
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
|
||||
@@ -93,8 +95,8 @@ while ($device = mysql_fetch_array($sql)) {
|
||||
|
||||
if ($config['warn']['ifdown'])
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||
while ($interface = mysql_fetch_array($sql))
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
if (port_permitted($interface['port_id']))
|
||||
{
|
||||
@@ -108,8 +110,8 @@ if ($config['warn']['ifdown'])
|
||||
}
|
||||
}
|
||||
|
||||
$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))
|
||||
$sql = "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'";
|
||||
foreach (dbFetchRows($sql) as $service)
|
||||
{
|
||||
if (device_permitted($service['device_id']))
|
||||
{
|
||||
@@ -122,8 +124,8 @@ while ($service = mysql_fetch_array($sql))
|
||||
}
|
||||
}
|
||||
|
||||
$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))
|
||||
$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']))
|
||||
{
|
||||
@@ -138,9 +140,9 @@ while ($peer = mysql_fetch_array($sql))
|
||||
|
||||
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
|
||||
{
|
||||
$sql = mysql_query("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'");
|
||||
while ($device = mysql_fetch_array($sql))
|
||||
$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")
|
||||
{
|
||||
@@ -160,9 +162,8 @@ echo("
|
||||
");
|
||||
|
||||
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from `syslog` ORDER BY seq DESC LIMIT 20";
|
||||
$query = mysql_query($sql);
|
||||
echo("<table cellspacing=0 cellpadding=2 width=100%>");
|
||||
while ($entry = mysql_fetch_array($query))
|
||||
foreach (dbFetchRows($sql) as $entry)
|
||||
{
|
||||
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||
|
||||
|
@@ -3,15 +3,16 @@
|
||||
<tr>
|
||||
<td bgcolor=#e5e5e5 valign=top>
|
||||
<?php
|
||||
|
||||
# <table width=100% border=0><tr><td><div style="margin-bottom: 5px; font-size: 18px; font-weight: bold;">Devices with Alerts</div></td><td width=35 align=center><div class=tablehead>Host</div></td><td align=center width=35><div class=tablehead>Int</div></td><td align=center width=35><div class=tablehead>Srv</div></tr>
|
||||
?>
|
||||
<?php
|
||||
|
||||
$nodes = array();
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
|
||||
$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'";
|
||||
|
||||
while ($device = mysql_fetch_assoc($sql))
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
unset($already);
|
||||
$i = 0;
|
||||
@@ -27,9 +28,9 @@ while ($device = mysql_fetch_assoc($sql))
|
||||
if (!$already) { $nodes[] = $device['device_id']; }
|
||||
}
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
|
||||
while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'";
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>
|
||||
<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span>
|
||||
@@ -38,9 +39,9 @@ while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
}
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||
while ($interface = mysql_fetch_assoc($sql)) {
|
||||
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
|
||||
<center><strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span>
|
||||
@@ -50,9 +51,9 @@ while ($interface = mysql_fetch_assoc($sql)) {
|
||||
|
||||
}
|
||||
|
||||
$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_assoc($sql)) {
|
||||
|
||||
$sql = "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'";
|
||||
foreach (dbFetchRows($sql) as $service)
|
||||
{
|
||||
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
|
||||
<center><strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
|
||||
@@ -62,9 +63,9 @@ while ($service = mysql_fetch_assoc($sql)) {
|
||||
|
||||
}
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id");
|
||||
while ($peer = mysql_fetch_assoc($sql)) {
|
||||
|
||||
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id";
|
||||
foreach (dbFetchRows($sql) as $peer)
|
||||
{
|
||||
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
|
||||
<center><strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span>
|
||||
@@ -76,9 +77,9 @@ while ($peer = mysql_fetch_assoc($sql)) {
|
||||
|
||||
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'");
|
||||
while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
$sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'";
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>
|
||||
<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
|
||||
@@ -96,9 +97,11 @@ echo("
|
||||
");
|
||||
|
||||
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
|
||||
$query = mysql_query($sql);
|
||||
echo("<table cellspacing=0 cellpadding=2 width=100%>");
|
||||
while ($entry = mysql_fetch_assoc($query)) { include("includes/print-syslog.inc.php"); }
|
||||
foreach (dbFetchRows($sql) as $entry)
|
||||
{
|
||||
include("includes/print-syslog.inc.php");
|
||||
}
|
||||
echo("</table>");
|
||||
|
||||
echo("</div>
|
||||
@@ -110,31 +113,28 @@ echo("</div>
|
||||
|
||||
if ($_SESSION['userlevel'] >= '5')
|
||||
{
|
||||
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%";
|
||||
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%";
|
||||
$sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
|
||||
$query = mysql_query($sql);
|
||||
unset ($seperator);
|
||||
while ($interface = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['l2tp'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
}
|
||||
|
||||
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%";
|
||||
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%";
|
||||
$sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
|
||||
$query = mysql_query($sql);
|
||||
unset ($seperator);
|
||||
while ($interface = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['transit'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
}
|
||||
|
||||
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%";
|
||||
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%";
|
||||
$sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
|
||||
$query = mysql_query($sql);
|
||||
unset ($seperator);
|
||||
while ($interface = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['voip'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
|
@@ -78,12 +78,12 @@ echo("<div style='padding: 3px 10px; background: #fff;'>");
|
||||
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
|
||||
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `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 = '0' AND D.ignore = '0'");
|
||||
$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 = '0' AND D.ignore = '0'";
|
||||
}
|
||||
while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span> <br />
|
||||
<span class=body-date-1>".truncate($device['location'], 20)."</span>
|
||||
@@ -93,16 +93,16 @@ while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
|
||||
} else {
|
||||
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
|
||||
}
|
||||
|
||||
// These things need to become more generic, and more manageable across different frontpages... rewrite inc :>
|
||||
|
||||
if ($config['warn']['ifdown'])
|
||||
{
|
||||
while ($interface = mysql_fetch_assoc($sql))
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
if (!$interface['deleted'])
|
||||
{
|
||||
@@ -118,8 +118,8 @@ if ($config['warn']['ifdown'])
|
||||
}
|
||||
|
||||
/* FIXME service permissions? seem nonexisting now.. */
|
||||
$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_assoc($sql))
|
||||
$sql = "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'";
|
||||
foreach (dbFetchRows($sql) as $service)
|
||||
{
|
||||
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
|
||||
@@ -132,11 +132,11 @@ if (isset($config['enable_bgp']) && $config['enable_bgp'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
|
||||
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND 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 bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
|
||||
$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";
|
||||
}
|
||||
while ($peer = mysql_fetch_assoc($sql))
|
||||
foreach (dbFetchRows($sql) as $peer)
|
||||
{
|
||||
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span>
|
||||
@@ -150,13 +150,13 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
|
||||
{
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0");
|
||||
$sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' 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 > 0 AND D.uptime < '" .
|
||||
$config['uptime_warning'] . "' AND D.ignore = 0");
|
||||
$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";
|
||||
}
|
||||
|
||||
while ($device = mysql_fetch_assoc($sql))
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
generate_front_box("#aaffaa", "<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
|
||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />
|
||||
@@ -173,9 +173,8 @@ if ($config['enable_syslog'])
|
||||
");
|
||||
|
||||
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
|
||||
$query = mysql_query($sql);
|
||||
echo("<table cellspacing=0 cellpadding=2 width=100%>");
|
||||
while ($entry = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows($sql) as $entry)
|
||||
{
|
||||
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||
|
||||
@@ -200,11 +199,9 @@ if ($config['enable_syslog'])
|
||||
P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15";
|
||||
}
|
||||
|
||||
$data = mysql_query($query);
|
||||
|
||||
echo('<table cellspacing="0" cellpadding="1" width="100%">');
|
||||
|
||||
while ($entry = mysql_fetch_assoc($data)) {
|
||||
foreach (dbFetchRows($query) as $entry) {
|
||||
include("includes/print-event.inc.php");
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
<table border=0 cellpadding=10 cellspacing=10 width=100%>
|
||||
<tr>
|
||||
<td bgcolor=#e5e5e5 valign=top>
|
||||
@@ -12,9 +11,10 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
|
||||
$uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'";
|
||||
}
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql);
|
||||
$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql;
|
||||
|
||||
while ($device = mysql_fetch_assoc($sql)) {
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
unset($already);
|
||||
$i = 0;
|
||||
while ($i <= count($nodes)) {
|
||||
@@ -27,8 +27,9 @@ while ($device = mysql_fetch_assoc($sql)) {
|
||||
if (!$already) { $nodes[] = $device['device_id']; }
|
||||
}
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
|
||||
while ($device = mysql_fetch_assoc($sql)) {
|
||||
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'";
|
||||
foreach (dbFetchRows($sql) as $device)
|
||||
{
|
||||
if (device_permitted($device['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: #ffbbbb;'>
|
||||
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
|
||||
@@ -40,8 +41,9 @@ while ($device = mysql_fetch_assoc($sql)) {
|
||||
|
||||
if ($config['warn']['ifdown']) {
|
||||
|
||||
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||
while ($interface = mysql_fetch_assoc($sql)) {
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
if (port_permitted($interface['port_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;'>
|
||||
<strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
|
||||
@@ -54,8 +56,9 @@ while ($interface = mysql_fetch_assoc($sql)) {
|
||||
|
||||
}
|
||||
|
||||
$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_assoc($sql)) {
|
||||
$sql = "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'";
|
||||
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;'>
|
||||
<strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
|
||||
@@ -66,8 +69,9 @@ while ($service = mysql_fetch_assoc($sql)) {
|
||||
}
|
||||
}
|
||||
|
||||
$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_assoc($sql)) {
|
||||
$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;'>
|
||||
<strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
|
||||
@@ -80,8 +84,8 @@ while ($peer = mysql_fetch_assoc($sql)) {
|
||||
|
||||
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
|
||||
{
|
||||
$sql = mysql_query("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'");
|
||||
while ($device = mysql_fetch_assoc($sql)) {
|
||||
$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;'>
|
||||
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
|
||||
@@ -101,9 +105,11 @@ echo("
|
||||
");
|
||||
|
||||
$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_assoc($query)) { include("includes/print-syslog.inc.php"); }
|
||||
foreach (dbFetchRows($sql) as $entry)
|
||||
{
|
||||
include("includes/print-syslog.inc.php");
|
||||
}
|
||||
echo("</table>");
|
||||
|
||||
echo("</div>
|
||||
@@ -116,18 +122,18 @@ echo("</div>
|
||||
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";
|
||||
$query = mysql_query($sql);
|
||||
$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);
|
||||
while ($interface = mysql_fetch_assoc($query)) {
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['transit'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
}
|
||||
|
||||
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
|
||||
$query = mysql_query($sql);
|
||||
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
|
||||
unset ($seperator);
|
||||
while ($interface = mysql_fetch_assoc($query)) {
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['peering'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
}
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
<table border=0 cellpadding=10 cellspacing=10 width=100%>
|
||||
<tr>
|
||||
<td bgcolor=#e5e5e5 valign=top>
|
||||
@@ -100,9 +99,11 @@ echo("
|
||||
");
|
||||
|
||||
$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_assoc($query)) { include("includes/print-syslog.inc.php"); }
|
||||
foreach (dbFetchRows($sql) as $entry)
|
||||
{
|
||||
include("includes/print-syslog.inc.php");
|
||||
}
|
||||
echo("</table>");
|
||||
|
||||
echo("</div>
|
||||
@@ -115,26 +116,26 @@ echo("</div>
|
||||
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";
|
||||
$query = mysql_query($sql);
|
||||
$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);
|
||||
while ($interface = mysql_fetch_assoc($query)) {
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['transit'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
}
|
||||
|
||||
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
|
||||
$query = mysql_query($sql);
|
||||
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
|
||||
unset ($seperator);
|
||||
while ($interface = mysql_fetch_assoc($query)) {
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['peering'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
}
|
||||
|
||||
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
|
||||
$query = mysql_query($sql);
|
||||
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
|
||||
unset ($seperator);
|
||||
while ($interface = mysql_fetch_assoc($query)) {
|
||||
foreach (dbFetchRows($sql) as $interface)
|
||||
{
|
||||
$ports['core'] .= $seperator . $interface['port_id'];
|
||||
$seperator = ",";
|
||||
}
|
||||
|
Reference in New Issue
Block a user