From bea6a0667f883049bbdf4f7c4a8f8ac5f0339292 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 24 Nov 2009 23:58:56 +0000 Subject: [PATCH] updates, including fixed procurve support! :) git-svn-id: http://www.observium.org/svn/observer/trunk@530 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 4 +- .../graphs/device_cpu_procurve.inc.php | 25 +++++++ .../graphs/device_memory_procurve.inc.php | 25 +++++++ html/pages/device/graphs.inc.php | 2 +- ...o-physical.php => entity-physical.inc.php} | 0 includes/osdiscovery/discover-procurve.php | 7 ++ includes/polling/device-ios.inc.php | 15 +++-- includes/polling/device-junos.inc.php | 8 +-- includes/polling/device-procurve.inc.php | 44 +++++++++--- includes/polling/port-etherlike.inc.php | 32 +++++++++ includes/polling/ports-etherlike.inc.php | 67 ------------------- includes/polling/ports.inc.php | 28 +++----- poll-device.php | 21 +----- process-syslog.php | 14 ++-- 14 files changed, 160 insertions(+), 132 deletions(-) create mode 100644 html/includes/graphs/device_cpu_procurve.inc.php create mode 100644 html/includes/graphs/device_memory_procurve.inc.php rename includes/discovery/{cisco-physical.php => entity-physical.inc.php} (100%) create mode 100755 includes/polling/port-etherlike.inc.php delete mode 100755 includes/polling/ports-etherlike.inc.php diff --git a/discovery.php b/discovery.php index 855d926708..8375e2ad61 100755 --- a/discovery.php +++ b/discovery.php @@ -51,6 +51,9 @@ while ($device = mysql_fetch_array($device_query)) { ## Discover Interfaces include("includes/discovery/interfaces.php"); + ## Discovery ENTITY-MIB + include("includes/discovery/entity-physical.inc.php"); + ## Discover IPv4 Addresses include("includes/discovery/ipv4-addresses.php"); @@ -73,7 +76,6 @@ while ($device = mysql_fetch_array($device_query)) { if($device['os'] == "IOS" || $device['os'] == "IOS XE" || $device['os'] == "CatOS" || $device['os'] == "ASA") { include("includes/discovery/cisco-vlans.php"); - include("includes/discovery/cisco-physical.php"); include("includes/discovery/bgp-peers.php"); include("includes/discovery/cisco-mac-accounting.php"); include("includes/discovery/cisco-pw.php"); diff --git a/html/includes/graphs/device_cpu_procurve.inc.php b/html/includes/graphs/device_cpu_procurve.inc.php new file mode 100644 index 0000000000..6e8ea566ca --- /dev/null +++ b/html/includes/graphs/device_cpu_procurve.inc.php @@ -0,0 +1,25 @@ + diff --git a/html/includes/graphs/device_memory_procurve.inc.php b/html/includes/graphs/device_memory_procurve.inc.php new file mode 100644 index 0000000000..5565029b6f --- /dev/null +++ b/html/includes/graphs/device_memory_procurve.inc.php @@ -0,0 +1,25 @@ + diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 342db7e964..3010bd909d 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -71,7 +71,7 @@ while($device = mysql_fetch_array($device_query)) { break; - case "ProCurve": + case "procurve": echo("
Processor Utilisation
"); $graph_type = "device_cpu"; include ("includes/print-device-graph.php"); echo("
"); diff --git a/includes/discovery/cisco-physical.php b/includes/discovery/entity-physical.inc.php similarity index 100% rename from includes/discovery/cisco-physical.php rename to includes/discovery/entity-physical.inc.php diff --git a/includes/osdiscovery/discover-procurve.php b/includes/osdiscovery/discover-procurve.php index 62a2de0c86..d72de9fc91 100755 --- a/includes/osdiscovery/discover-procurve.php +++ b/includes/osdiscovery/discover-procurve.php @@ -1,3 +1,10 @@ diff --git a/includes/polling/device-ios.inc.php b/includes/polling/device-ios.inc.php index 18506277f0..4b5ac1b8ff 100755 --- a/includes/polling/device-ios.inc.php +++ b/includes/polling/device-ios.inc.php @@ -9,17 +9,22 @@ $cpurrd = $config['rrd_dir'] . "/" . $hostname . "/ios-cpu.rrd"; $memrrd = $config['rrd_dir'] . "/" . $hostname . "/ios-mem.rrd"; - if(strstr($ciscomodel, "OID")){ unset($ciscomodel); } - if(!strstr($ciscomodel, " ") && strlen($ciscomodel) >= '3') { - $hardware = $ciscomodel; - } - $sysDescr = str_replace("IOS (tm)", "IOS (tm),", $sysDescr); list(,$features,$version) = explode(",", $sysDescr); $version = str_replace(" Version ", "", $version); list(,$features) = explode("(", $features); list(,$features) = explode("-", $features); + $snmp_cmdb = $config['snmpget'] . " -m ENTITY-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . + $device['hostname'].":".$device['port']; + $snmp_cmdb .= " .1.3.6.1.2.1.47.1.1.1.1.13.1 .1.3.6.1.2.1.47.1.1.1.1.4.1 .1.3.6.1.2.1.47.1.1.1.1.7.1 .1.3.6.1.2.1.47.1.1.1.1.10.1"; + $snmp_cmdb .= " .1.3.6.1.2.1.47.1.1.1.1.13.1001 .1.3.6.1.2.1.47.1.1.1.1.4.1001"; + list($a,$b,$c,$d,$e,$f) = explode("\n", shell_exec($snmp_cmdb)); + if($b == "0" || $c == "Chassis") { $ciscomodel = $a; list($version) = explode(",",$d); } + if($f == "0") { $ciscomodel = $d; } + $ciscomodel = str_replace("\"","",$ciscomodel); + if($ciscomodel) { $hardware = $ciscomodel; } + $cpu5m = shell_exec($config['snmpget'] . " -m OLD-CISCO-CPU-MIB -O qv -$snmpver -c $community $hostname:$port avgBusy5.0"); $cpu5m = $cpu5m + 0; diff --git a/includes/polling/device-junos.inc.php b/includes/polling/device-junos.inc.php index 6671b6288a..a1ae955526 100644 --- a/includes/polling/device-junos.inc.php +++ b/includes/polling/device-junos.inc.php @@ -2,9 +2,9 @@ echo("Doing Juniper JunOS"); -$jun_ver = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.25.6.3.1.2.2"))); +$jun_ver = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.25.6.3.1.2.2"))); $hardware = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m JUNIPER-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2636.3.1.2.0"))); -$serial = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m JUNIPER-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2636.3.1.3.0"))); +$serial = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m JUNIPER-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2636.3.1.3.0"))); list($version) = explode("]", $jun_ver); list(,$version) = explode("[", $version); @@ -19,7 +19,7 @@ $cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0"; $cpu_usage = trim(shell_exec($cpu_cmd)); if (!is_file($cpurrd)) { - `rrdtool create $cpurrd \ + shell_exec($config['rrdtool'] . " create $cpurrd \ --step 300 \ DS:cpu:GAUGE:600:0:100 \ RRA:AVERAGE:0.5:1:800 \ @@ -29,7 +29,7 @@ if (!is_file($cpurrd)) { RRA:MAX:0.5:1:800 \ RRA:MAX:0.5:6:800 \ RRA:MAX:0.5:24:800 \ - RRA:MAX:0.5:288:800`; + RRA:MAX:0.5:288:800"); } shell_exec($config['rrdtool'] . " update $cpurrd N:$cpu_usage"); diff --git a/includes/polling/device-procurve.inc.php b/includes/polling/device-procurve.inc.php index cc1c19cf21..b3ceb19161 100755 --- a/includes/polling/device-procurve.inc.php +++ b/includes/polling/device-procurve.inc.php @@ -1,15 +1,17 @@ diff --git a/includes/polling/port-etherlike.inc.php b/includes/polling/port-etherlike.inc.php new file mode 100755 index 0000000000..eaa8547f7e --- /dev/null +++ b/includes/polling/port-etherlike.inc.php @@ -0,0 +1,32 @@ + diff --git a/includes/polling/ports-etherlike.inc.php b/includes/polling/ports-etherlike.inc.php deleted file mode 100755 index 850a12d4d7..0000000000 --- a/includes/polling/ports-etherlike.inc.php +++ /dev/null @@ -1,67 +0,0 @@ - (count($ports)*2.5)) { /// If there are 2.5x more interfaces than OIDs, do per-OID - $sub_start = utime(); - echo("Caching Ports: "); - foreach($ports as $port) { echo("$port "); $array = snmp_cache_port_oids($etherlike_oids, $port, $device, $array, "EtherLike-MIB"); } - $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); - echo("\n$proctime secs\n"); - } else { - $sub_start = utime(); - echo("Caching Oids: "); - foreach ($etherlike_oids as $oid) { echo("$oid "); $array = snmp_cache_oid($oid, $device, $array, "EtherLike-MIB"); } - $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); - echo("\n$proctime secs\n"); - } - - $polled = time(); - - /// Loop interfaces in the DB and update where necessary - $port_query = mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '".$device['device_id']."'"); - while ($port = mysql_fetch_array($port_query)) { - - echo(" --> " . $port['ifDescr'] . " "); - if($array[$device[device_id]][$port[ifIndex]]) { // Check to make sure Port data is cached. - - $this_port = &$array[$device[device_id]][$port[ifIndex]]; - - $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-".$port['ifIndex'].".rrd"; - - $rrd_create = $config['rrdtool'] . " create $rrdfile "; - $rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797"; - - if(!file_exists($rrdfile)) { - foreach($etherlike_oids as $oid){ - $oid = truncate(str_replace("dot3Stats", "", $oid), 19, ''); - $rrd_create .= " DS:$oid:COUNTER:600:U:100000000000"; - } - shell_exec($rrd_create); - } - - $rrdupdate = "N"; - foreach($etherlike_oids as $oid) { - $data = $this_port[$oid] + 0; - $rrdupdate .= ":$data"; - } - rrdtool_update($rrdfile, $rrdupdate); - - #AlignmentErrors|FCSErrors|SingleCollisionFram|MultipleCollisionFr|SQETestErrors|DeferredTransmissio|LateCollisions|ExcessiveCollisions - #InternalMacTransmit|CarrierSenseErrors|FrameTooLongs|InternalMacReceiveE|SymbolErrors - - } else { - echo("Port Deleted?"); // Port missing from SNMP cache? - } - echo("\n"); - } - -?> diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 5a5a5572b6..f4532e2fa1 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -12,10 +12,10 @@ $stat_oids_db = array('ifInOctets', 'ifOutOctets', 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts'); // From above for DB - $etherlike_oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames', - 'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions', + $etherlike_oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames', + 'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions', 'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors', - 'dot3StatsSymbolErrors', 'dot3StatsDuplexStatus'); + 'dot3StatsSymbolErrors'); $cisco_oids = array('locIfHardType', 'locIfInRunts', 'locIfInGiants', 'locIfInCRC', 'locIfInFrame', 'locIfInOverrun', 'locIfInIgnored', 'locIfInAbort', 'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops'); @@ -25,24 +25,13 @@ $ifmib_oids = array_merge($data_oids, $stat_oids); -# if(count($ifmib_oids) > (count($ports)*2.5)) { /// If there are 2.5x more interfaces than OIDs, do per-OID -# $sub_start = utime(); -# echo("Caching Ports: "); -# foreach($ports as $port) { echo("$port "); $array = snmp_cache_port_oids($ifmib_oids, $port, $device, $array, "IF-MIB"); } -# $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); -# #echo("\n$proctime secs\n"); -# } else { -# $sub_start = utime(); -# echo("Caching Oids: "); -# foreach ($ifmib_oids as $oid) { echo("$oid "); $array = snmp_cache_oid($oid, $device, $array, "IF-MIB"); } -# $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); -# #echo("\n$proctime secs\n"); -# } - - $ifmib_oids = array('ifentry', 'ifxentry'); + $ifmib_oids = array('ifEntry', 'ifXEntry'); echo("Caching Oids: "); foreach ($ifmib_oids as $oid) { echo("$oid "); $array = snmp_cache_oid($oid, $device, $array, "IF-MIB");} + + if($config['enable_etherlike']) { echo("dot3Stats "); $array = snmp_cache_oid("dot3StatsEntry", $device, $array, "EtherLike-MIB"); } + echo("\n"); #foreach ($etherlike_oids as $oid) { $array = snmp_cache_oid($oid, $device, $array, "EtherLike-MIB"); } @@ -156,6 +145,9 @@ } // End Update PAgP + /// Do EtherLike-MIB + if($config['enable_etherlike']) { include("port-etherlike.inc.php"); } + if ($update) { /// Do Updates $update_query = "UPDATE `interfaces` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'"; @mysql_query($update_query); $mysql++; diff --git a/poll-device.php b/poll-device.php index c3ae2a0f9a..2e0648fb12 100755 --- a/poll-device.php +++ b/poll-device.php @@ -43,7 +43,7 @@ $i = 0; $device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' $where ORDER BY `device_id` ASC"); while ($device = mysql_fetch_array($device_query)) { - echo("Polling " . $device['hostname'] . " ( device_id ".$device['device_id']." )\n\n"); + echo($device['hostname'] . " ".$device['device_id']." ".$device['os']."\n"); unset($update); unset($update_query); unset($seperator); unset($version); unset($uptime); unset($features); unset($sysLocation); unset($hardware); unset($sysDescr); unset($sysContact); unset($sysName); @@ -70,16 +70,6 @@ while ($device = mysql_fetch_array($device_query)) { $status = '1'; $snmp_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_cmd .= " sysUptime.0 sysLocation.0 sysContact.0 sysName.0"; - #$snmp_cmd .= " | grep -v 'Cisco Internetwork Operating System Software'"; - if($device['os'] == "IOS" || $device['os'] == "IOS XE") { - $snmp_cmdb = $config['snmpget'] . " -m ENTITY-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; - $snmp_cmdb .= " .1.3.6.1.2.1.47.1.1.1.1.13.1 .1.3.6.1.2.1.47.1.1.1.1.4.1 .1.3.6.1.2.1.47.1.1.1.1.13.1001 .1.3.6.1.2.1.47.1.1.1.1.4.1001"; - list($a,$b,$c,$d) = explode("\n", shell_exec($snmp_cmdb)); - if($b == "0") { $ciscomodel = $a; } - if($d == "0") { $ciscomodel = $c; } - $ciscomodel = str_replace("\"","",$ciscomodel); - } else { unset($ciscomodel); } - $snmpdata = shell_exec($snmp_cmd); #$snmpdata = preg_replace("/^.*IOS/","", $snmpdata); $snmpdata = trim($snmpdata); @@ -133,13 +123,7 @@ while ($device = mysql_fetch_array($device_query)) { include("includes/polling/device-catos.inc.php"); break; - case "ProCurve": - $sysDescr = str_replace(", ", ",", $sysDescr); - list($hardware, $features, $version) = explode(",", $sysDescr); - list($version) = explode("(", $version); - if(!strstr($ciscomodel, " ")) { - $hardware = str_replace("\"", "", $ciscomodel); - } + case "procurve": include("includes/polling/device-procurve.inc.php"); break; @@ -159,7 +143,6 @@ while ($device = mysql_fetch_array($device_query)) { include("includes/polling/temperatures.inc.php"); include("includes/polling/device-netstats.inc.php"); include("includes/polling/ports.inc.php"); - if($config['enable_etherlike']) { include("includes/polling/ports-etherlike.inc.php"); } include("includes/polling/cisco-mac-accounting.inc.php"); $update_uptime_attrib = mysql_query("UPDATE devices_attribs SET attrib_value = NOW() WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'polled'"); diff --git a/process-syslog.php b/process-syslog.php index d5836702c1..80c947aca0 100755 --- a/process-syslog.php +++ b/process-syslog.php @@ -10,17 +10,17 @@ if(!$config['enable_syslog']) { include("includes/syslog.php"); -mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%last message repeated%'"); -mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Connection from UDP: [%]:%'"); -mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Traceback%'"); -mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%PM-3-INVALID_BRIDGE_PORT%'"); -mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%RHWatchdog%'"); -mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Hardware Monitoring%'"); +#mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%last message repeated%'"); +#mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Connection from UDP: [%]:%'"); +#mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Traceback%'"); +#mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%PM-3-INVALID_BRIDGE_PORT%'"); +#mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%RHWatchdog%'"); +#mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Hardware Monitoring%'"); #mysql_query("DELETE FROM `syslog` WHERE `program` LIKE 'SNMP-3-AUTHFAIL'"); #mysql_query("DELETE FROM `syslog` WHERE `program` LIKE 'SW_MATM-4-MACFLAP_NOTIF'"); -mysql_query("DELETE FROM `syslog` WHERE `priority` = 'debug'"); +#mysql_query("DELETE FROM `syslog` WHERE `priority` = 'debug'"); ## Delete all the old old old syslogs (as per config.php variable)