From 1e7860e930314ee7b4a5f28bcdfa9a6080aa027a Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 28 Feb 2010 22:04:15 +0000 Subject: [PATCH] bit of restructuring and tiding. all hail bunny. git-svn-id: http://www.observium.org/svn/observer/trunk@977 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 2 +- discovery.php | 56 +++++-------------- includes/defaults.inc.php | 4 +- includes/discovery/arp-table.inc.php | 1 - includes/discovery/bgp-peers.inc.php | 1 - .../discovery/cisco-mac-accounting.inc.php | 9 ++- includes/discovery/cisco-pw.inc.php | 4 +- includes/discovery/cisco-vlans.inc.php | 4 ++ includes/discovery/cisco-vrf.inc.php | 7 ++- includes/discovery/functions.inc.php | 17 +++++- includes/discovery/junose-atm-vc.inc.php | 50 +++++++++++++++++ includes/functions.php | 1 + ...{functions-poller.inc.php => snmp.inc.php} | 0 includes/static-config.php | 4 +- poll-device.php | 1 - poller.php | 1 - test-discovery.php | 1 - test-poll.php | 1 - 18 files changed, 108 insertions(+), 56 deletions(-) create mode 100755 includes/discovery/junose-atm-vc.inc.php rename includes/{functions-poller.inc.php => snmp.inc.php} (100%) diff --git a/config.php.default b/config.php.default index 7e0713cc0..0a84872ef 100755 --- a/config.php.default +++ b/config.php.default @@ -93,7 +93,7 @@ $config['enable_billing'] = 0; # Enable Billing $config['enable_inventory'] = 1; # Enable Inventory $config['enable_etherlike'] = 1; # Enable Etherlike $config['enable_pseudowires'] = 1; # Enable Pseudowires - +$config['enable_ports_junoseatmvc'] = 0; # Enable JunOSe ATM VC Discovery/Poller $config['enable_ports_etherlike'] = 0; # Enable Polling EtherLike-MIB (doubles interface processing time) #$config['rancid_configs'] = '/var/lib/rancid/network/configs/'; diff --git a/discovery.php b/discovery.php index b6e8de193..ecd5eb961 100755 --- a/discovery.php +++ b/discovery.php @@ -4,7 +4,6 @@ include("includes/defaults.inc.php"); include("config.php"); include("includes/functions.php"); -include("includes/functions-poller.inc.php"); include("includes/discovery/functions.inc.php"); $start = utime(); @@ -56,7 +55,7 @@ if (file_exists('.svn')) if ($dbu_rev+0 > $db_rev) { - echo("Applying database updates to from r$db_rev to r" . trim($dbu_rev) . "...\n"); + echo("SVN revision changed.\nRunning development SQL update script from r$db_rev to r" . trim($dbu_rev) . "...\n"); shell_exec("scripts/update-sql.php database-update.sql"); if ($db_rev == 0) { @@ -86,48 +85,31 @@ while ($device = mysql_fetch_array($device_query)) echo("\n"); - ## Discover OS Changes #include("includes/discovery/os.inc.php"); - ## Discover Interfaces include("includes/discovery/ports.inc.php"); - - ## Discovery ENTITY-MIB - #include("includes/discovery/entity-physical.inc.php"); - + include("includes/discovery/entity-physical.inc.php"); include("includes/discovery/processors.inc.php"); - include("includes/discovery/mempools.inc.php"); - - ## Discover IPv4 Addresses include("includes/discovery/ipv4-addresses.inc.php"); - - ## Discovery IPv6 Addresses include("includes/discovery/ipv6-addresses.inc.php"); - - ## Discover Temperatures/Voltages/Fanspeeds include("includes/discovery/temperatures.inc.php"); include("includes/discovery/voltages.inc.php"); include("includes/discovery/fanspeeds.inc.php"); - - ## Discover Storage include("includes/discovery/storage.inc.php"); - - ## hr-device.inc.php include("includes/discovery/hr-device.inc.php"); - - ## Discovery Protocols (FDP, CDP & LLDP) include("includes/discovery/discovery-protocols.inc.php"); - - ## ARP Table include("includes/discovery/arp-table.inc.php"); - - ## BGP Peers (Quagga, Cisco, Juniper, Foundry) + include("includes/discovery/junose-atm-vc.inc.php"); include("includes/discovery/bgp-peers.inc.php"); + include("includes/discovery/q-bridge-mib.inc.php"); + + include("includes/discovery/cisco-vlans.inc.php"); + include("includes/discovery/cisco-mac-accounting.inc.php"); + include("includes/discovery/cisco-pw.inc.php"); + include("includes/discovery/cisco-vrf.inc.php"); + - if($device['os'] == "ironware") { - if ($device['type'] == "unknown") { $device['type'] = 'network'; } - } if($device['os'] == "screenos") { if ($device['type'] == "unknown") { $device['type'] = 'firewall'; } @@ -137,29 +119,16 @@ while ($device = mysql_fetch_array($device_query)) if ($device['type'] == "unknown") { $device['type'] = 'network'; } # FIXME: could also be a Netscreen... } - if($device['os'] == "junose") { - include("includes/discovery/processors-junose.inc.php"); - } - if($device['os'] == "linux") { if (($device['type'] == "unknown") && preg_match("/-server$/", $device['version'])) { $device['type'] = 'server'; } } if($device['os'] == "ios" || $device['os'] == "iosxe" || $device['os'] == "catos" || $device['os'] == "asa" || $device['os'] == "pix") { - include("includes/discovery/cisco-vlans.inc.php"); - include("includes/discovery/cisco-mac-accounting.inc.php"); - include("includes/discovery/cisco-pw.inc.php"); - include("includes/discovery/cisco-vrf.inc.php"); - #include("includes/discovery/cisco-processors.php"); - include("includes/discovery/cemp-mib.inc.php"); - include("includes/discovery/cmp-mib.inc.php"); - if ($device['type'] == "unknown") { $device['type'] = 'network'; }; } if ($device['os'] == "procurve" || $device['os'] == "powerconnect") { - include("includes/discovery/q-bridge-mib.inc.php"); if ($device['type'] == "unknown") { $device['type'] = 'network'; }; } @@ -173,6 +142,11 @@ while ($device = mysql_fetch_array($device_query)) if ($device['type'] == "unknown") { $device['type'] = 'printer'; } } + if($device['os'] == "ironware") + { + if ($device['type'] == "unknown") { $device['type'] = 'network'; } + } + $update_query = "UPDATE `devices` SET "; $update_query .= " `last_discovered` = NOW(), `type` = '" . $device['type'] . "'"; $update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'"; diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 049cec01f..55a669439 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -101,8 +101,10 @@ $config['ignore_mount_network'] = 1; # Ignore network mounted storage $config['ignore_junos_os_drives'] = array("/on: \/packages/", "/on: \/dev/", "/on: \/proc/", "/on: \/junos^/", "/on: \/junos\/dev/", "/on: \/jail\/dev/", "/^(dev|proc)fs/", "/^\/dev\/md0/"); # Ignore JunOS partitions who are always 100% $config['ignore_bsd_os_drives'] = array("/^\/dev,/", "/^\/var\/dhcpd\/dev,/", "/UMA/"); # Ignore BSD partitions who are always 100% -# Ports +# Poller/Discovery $config['enable_ports_etherlike'] = 0; # Enable EtherLike-MIB +$config['enable_ports_junoseatmvc'] = 0; # Enable JunOSe ATM VC Discovery/Poller + ?> diff --git a/includes/discovery/arp-table.inc.php b/includes/discovery/arp-table.inc.php index dbe790007..bb9813c73 100644 --- a/includes/discovery/arp-table.inc.php +++ b/includes/discovery/arp-table.inc.php @@ -63,7 +63,6 @@ } echo("\n"); - unset($mac); ?> diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index d1c0f596b..b5e9e259d 100755 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -141,4 +141,3 @@ unset($peerlist); echo("\n"); ?> - diff --git a/includes/discovery/cisco-mac-accounting.inc.php b/includes/discovery/cisco-mac-accounting.inc.php index d883d10d7..9f2b94416 100755 --- a/includes/discovery/cisco-mac-accounting.inc.php +++ b/includes/discovery/cisco-mac-accounting.inc.php @@ -1,6 +1,9 @@ diff --git a/includes/discovery/cisco-pw.inc.php b/includes/discovery/cisco-pw.inc.php index 02856f8b7..8a994a20f 100755 --- a/includes/discovery/cisco-pw.inc.php +++ b/includes/discovery/cisco-pw.inc.php @@ -1,11 +1,11 @@ diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 3d923938f..bd857c7a9 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -1,9 +1,24 @@ -M mibs/junose/ -m Juniper-UNI-ATM-MIB juniAtmVpStatsEntry + +## JunOSe ATM VCs +if($device['os'] == "junose" && $config['enable_ports_junoseatmvc']) +{ + echo("JunOSe ATM VCs : "); + $vc_array = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInCells", $vc_array, "Juniper-UNI-ATM-MIB" , "+".$config['install_dir']."/mibs/junose"); + $valid_vc = array(); + if($debug) { print_r($vc_array); } + + if(is_array($vc_array[$device['device_id']])) { + foreach($vc_array[$device['device_id']] as $index => $entry) { + + list($interface_id,$vp_id)= explode('.', $index); + + if(is_numeric($interface_id) && is_numeric($vp_id)) { + discover_juniAtmVp($valid_vc, $interface_id, $vp_id, NULL); + } + } ## End Foreach + } ## End if array +} ## End JUNOS vc + + unset ($vc_array); + +### Remove ATM VCs which weren't redetected here + +$sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.interface_id = P.interface_id"; +$query = mysql_query($sql); + +if($debug) { print_r ($valid_vc); } + +while ($test = mysql_fetch_array($query)) { + $interface_id = $test['interface_id']; + $vc_id = $test['vc_id']; + if($debug) { echo($interface_id . " -> " . $vc_id . "\n"); } + if(!$valid_vc[$interface_id][$vc_id]) { + echo("-"); + mysql_query("DELETE FROM `juniAtmVp` WHERE `juniAtmVp` = '" . $test['juniAtmVp'] . "'"); + } + unset($interface_id); unset($vc_id); +} + +unset($valid_vc); +echo("\n"); + +?> diff --git a/includes/functions.php b/includes/functions.php index ac9703bf6..ba489d3b1 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -17,6 +17,7 @@ include_once($config['install_dir'] . "/includes/billing.php"); include_once($config['install_dir'] . "/includes/cisco-entities.php"); include_once($config['install_dir'] . "/includes/syslog.php"); include_once($config['install_dir'] . "/includes/rewrites.php"); +include_once($config['install_dir'] . "/includes/snmp.inc.php"); ## CollectD diff --git a/includes/functions-poller.inc.php b/includes/snmp.inc.php similarity index 100% rename from includes/functions-poller.inc.php rename to includes/snmp.inc.php diff --git a/includes/static-config.php b/includes/static-config.php index e0086ff63..7cc671f09 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -56,8 +56,8 @@ $os_text['solaris'] = "Sun Solaris"; $os_text['opensolaris'] = "OpenSolaris"; $os_text['powerconnect'] = "Dell PowerConnect"; $os_text['windows'] = "Microsoft Windows"; -$os_text['junos'] = "Juniper JUNOS"; -$os_text['junose'] = "Juniper JUNOSe"; +$os_text['junos'] = "Juniper JunOS"; +$os_text['junose'] = "Juniper JunOSe"; $os_text['procurve'] = "HP ProCurve"; $os_text['speedtouch'] = "Thomson Speedtouch"; $os_text['dell-laser'] = "Dell Laser Printer"; diff --git a/poll-device.php b/poll-device.php index 0ac96ff5d..1d6c87746 100755 --- a/poll-device.php +++ b/poll-device.php @@ -4,7 +4,6 @@ include("includes/defaults.inc.php"); include("config.php"); include("includes/functions.php"); -include("includes/functions-poller.inc.php"); $poller_start = utime(); echo("Observer Poller v".$config['version']."\n\n"); diff --git a/poller.php b/poller.php index 00e4b3dca..b70e8a9da 100755 --- a/poller.php +++ b/poller.php @@ -7,7 +7,6 @@ include("config.php"); echo("Observer Poller v".$config['version']."\n\n"); include("includes/functions.php"); -include("includes/functions-poller.inc.php"); $poller_start = utime(); diff --git a/test-discovery.php b/test-discovery.php index 0cb7b4513..9ce535494 100755 --- a/test-discovery.php +++ b/test-discovery.php @@ -5,7 +5,6 @@ include("includes/defaults.inc.php"); include("config.php"); include("includes/functions.php"); -include("includes/functions-poller.inc.php"); include("includes/discovery/functions.inc.php"); $start = utime(); diff --git a/test-poll.php b/test-poll.php index 886253138..da6090710 100755 --- a/test-poll.php +++ b/test-poll.php @@ -4,7 +4,6 @@ include("includes/defaults.inc.php"); include("config.php"); include("includes/functions.php"); -include("includes/functions-poller.inc.php"); $poller_start = utime();