From 9c8b7f425f2ce3313805537d008e67f5e7d6d9c5 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 14 May 2012 13:27:24 +0000 Subject: [PATCH] globe map git-svn-id: http://www.observium.org/svn/observer/trunk@3181 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/front/globe.php | 198 +++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 html/pages/front/globe.php diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php new file mode 100644 index 000000000..0dd3a44ae --- /dev/null +++ b/html/pages/front/globe.php @@ -0,0 +1,198 @@ + + + + +
+ + + + + $content + "); +} + +echo("
"); + +if ($_SESSION['userlevel'] == '10') +{ +$sql = mysql_query("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'"); +} +while ($device = mysql_fetch_assoc($sql)) { + + generate_front_box("#ffaaaa", "
".generate_device_link($device, shorthost($device['hostname']))."
+ Device Down
+ ".truncate($device['location'], 20)." +
"); + +} + +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'"); +} 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'"); +} + +### 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)) + { + if (!$interface['deleted']) + { + $interface = ifNameDescr($interface); + generate_front_box("#ffdd99", "
".generate_device_link($interface, shorthost($interface['hostname']))."
+ Port Down
+ + ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
+ " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') . " +
"); + } + } +} + +/* 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)) +{ + generate_front_box("#ffaaaa", "
".generate_device_link($service, shorthost($service['hostname']))."
+ Service Down + ".$service['service_type']."
+ ".truncate($interface['ifAlias'], 20)." +
"); +} + +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"); + } 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"); + } + while ($peer = mysql_fetch_assoc($sql)) + { + generate_front_box("#ffaaaa", "
".generate_device_link($peer, shorthost($peer['hostname']))."
+ BGP Down + ".$peer['bgpPeerIdentifier']."
+ AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "")." +
"); + } +} + +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + 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"); + } 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"); + } + + while ($device = mysql_fetch_assoc($sql)) + { + generate_front_box("#aaffaa", "
".generate_device_link($device, shorthost($device['hostname']))."
+ Device
Rebooted

+ ".formatUptime($device['uptime'], 'short')." +
"); + } +} + +if ($config['enable_syslog']) +{ + ## Open Syslog Div + echo("
+

Recent Syslog Messages

+ "); + + $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $query = mysql_query($sql); + echo(""); + while ($entry = mysql_fetch_assoc($query)) + { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + + include("includes/print-syslog.inc.php"); + } + echo("
"); + + echo("
"); ## Close Syslog Div + +} else { + + ## Open eventlog Div + echo("
+

Recent Eventlog Entries

+ "); + + if ($_SESSION['userlevel'] == '10') + { + $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } else { + $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } + + $data = mysql_query($query); + + echo(''); + + while ($entry = mysql_fetch_assoc($data)) { + include("includes/print-event.inc.php"); + } + + echo("
"); + echo("
"); ## Close Syslog Div +} + +echo("
"); + +?>