From a65f5d72ea62fe14eaf9785d28b4b0a4616a3f32 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 18 Mar 2008 13:35:17 +0000 Subject: [PATCH] Tidy the things... git-svn-id: http://www.observium.org/svn/observer/trunk@169 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 22 +++++++------ discover-bgp_peers.php | 42 +++++-------------------- html/.htaccess | 11 +++++-- html/includes/print-menubar.php | 53 ++++++++++++++++---------------- html/pages/device.php | 2 +- html/pages/device/dev-bgp.inc | 22 ++++++++++--- includes/polling/bgpPeer.inc.php | 7 +++-- map.php | 13 +++++--- poll-os.php | 16 ++++------ 9 files changed, 94 insertions(+), 94 deletions(-) diff --git a/config.php.default b/config.php.default index 8be23bdd7..7229c7c3c 100755 --- a/config.php.default +++ b/config.php.default @@ -67,24 +67,28 @@ $config['email_headers'] = "From: " . $config['email_from'] . "\r\n"; ### Which interface sections should we show? -$show_if_customers = 1; -$show_if_transit = 0; -$show_if_peering = 0; -$show_if_core = 0; -$show_if_l2tp =0; -$show_locations = 1; +$config['show_if_customers'] = 1; +$config['show_if_transit'] = 0; +$config['show_if_peering'] = 0; +$config['show_if_core'] = 0; +$config['show_if_l2tp'] = 0; +$config['show_locations'] = 1; -$enable_syslog = 1; +$config['enable_syslog'] = 1; ### Interface name strings to ignore -$bif = array("null", "virtual-", "unrouted", "eobc", "mpls", "sl0", "lp0", "faith0", +$config['bif'] = array("null", "virtual-", "unrouted", "eobc", "mpls", "sl0", "lp0", "faith0", "-atm layer", "-atm subif", "-shdsl", "-adsl", "-aal5", "-atm", "async", "plip", "-physical", "-signalling", "control plane", "bri", "-bearer", "ng", "bluetooth", "isatap", "ras", "qos", "miniport"); +$bif = $config['bif'] + ### Mountpoints to ignore -$ignore_mount = array("/kern", "/mnt/cdrom", "/dev", "/dev/pts"); +$config['ignore_mount'] = array("/kern", "/mnt/cdrom", "/dev", "/dev/pts"); +$ignore_mount = $config['ignore_mount'] + ### Valis OSes $valid_os = array("IOS", "Linux", "OpenBSD", "FreeBSD", "NetBSD", "ProCurve", "m0n0wall", "pfSense", "Snom", "Voswall", "DragonFly"); diff --git a/discover-bgp_peers.php b/discover-bgp_peers.php index 3280cffb4..aafe630d0 100755 --- a/discover-bgp_peers.php +++ b/discover-bgp_peers.php @@ -3,10 +3,10 @@ include("config.php"); include("includes/functions.php"); +if(!$config['enable_bgp']) { echo("BGP Support Disabled\n"); exit; } ### Discover BGP peers on Cisco devices - $device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND os = 'IOS' ORDER BY device_id desc"); while ($device = mysql_fetch_array($device_query)) { echo("\nPolling ". $device['hostname'] . "\n"); @@ -38,41 +38,13 @@ while ($device = mysql_fetch_array($device_query)) { if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'"),0) < '1') { $add = mysql_query("INSERT INTO bgpPeers (`device_id`, `bgpPeerIdentifier`, `bgpPeerRemoteAS`) VALUES ('".$device['device_id']."','$peer_ip','$peer_as')"); if($add) { echo(" Added \n"); } else { echo(" Add failed\n"); } - } else { echo(" Exists\n"); } + } else { + #Â$peer_data = mysql_fetch_array(mysql_query("SELECT * FROM `bgpPeers``device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip' ")); + echo(" Exists\n"); + $update = mysql_query("UPDATE `bgpPeers` SET astext = '$astext' WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'"); + } - ### Poll BGP Peer - -# $peer_cmd = $config['snmpget'] . " -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'] . " "; -# $peer_cmd .= "bgpPeerState.$peer_ip bgpPeerAdminStatus.$peer_ip bgpPeerInUpdates.$peer_ip bgpPeerOutUpdates.$peer_ip bgpPeerInTotalMessages.$peer_ip "; -# $peer_cmd .= "bgpPeerOutTotalMessages.$peer_ip bgpPeerFsmEstablishedTime.$peer_ip bgpPeerInUpdateElapsedTime.$peer_ip"; -# $peer_data = trim(shell_exec($peer_cmd)); - -# $peerrrd = $rrd_dir . "/" . $device['hostname'] . "/bgp-$peer_ip.rrd"; - -# if(!is_file($peerrrd)) { -# $woo = `rrdtool create $peerrrd \ -# DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \ -# DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \ - # DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \ - # DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \ - # DS:bgpPeerEstablished:GAUGE:600:0:U \ - # RRA:AVERAGE:0.5:1:600 \ - # RRA:AVERAGE:0.5:6:700 \ - # RRA:AVERAGE:0.5:24:775 \ - # RRA:AVERAGE:0.5:288:797`; - # } - -# rrdtool_update($peerrrd, "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime"); - - # list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime) = explode("\n", $peer_data); - -# $update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', "; - # $update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', astext = '$astext'"; - # $update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'"; - -# mysql_query($update); - - } # end if $peer + } # End if } # End foreach } # End BGP check } # End While diff --git a/html/.htaccess b/html/.htaccess index d50cfe3ef..cc382a664 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -8,8 +8,15 @@ RewriteCond %{REQUEST_URI} !^(.*)\.jpg$ RewriteCond %{REQUEST_URI} !^(.*)\.gif$ RewriteCond %{REQUEST_URI} !^(.*)\.png$ -RewriteRule ^([a-z]+)$ ?page=$1 +## Rewrites for Devices -RewriteRule ^bills/([0-9]+) ?page=bills&bill=$1 +RewriteRule ^devices/location/(.+)/ ?page=devices&location=$1 +RewriteRule ^devices/alerted/ ?page=devices&status=alerted +RewriteRule ^devices/alerted/ ?page=devices&status=alerted +RewriteRule ^devices/(.+)/ ?page=devices&type=$1 + +RewriteRule ^bill/([0-9]+) ?page=bills&bill=$1 RewriteRule ^device/([0-9]+) ?page=device&id=$1 +RewriteRule ^([a-z]+)/$ ?page=$1 + diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 84d95c6d7..f0e3fb462 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -28,12 +28,12 @@
@@ -45,23 +45,23 @@