updates, including fixed procurve support! :)

git-svn-id: http://www.observium.org/svn/observer/trunk@530 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-11-24 23:58:56 +00:00
parent cd7452c698
commit bea6a0667f
14 changed files with 160 additions and 132 deletions
+3 -1
View File
@@ -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");
@@ -0,0 +1,25 @@
<?php
$unit_text = "Load %";
$units='%';
$total_units='%';
$colours='mixed';
$scale_min = "0";
$scale_max = "100";
$nototal = 1;
include("common.inc.php");
$database = $config['rrd_dir'] . "/" . $hostname . "/procurve-cpu.rrd";
$rrd_options .= " DEF:load=$database:LOAD:AVERAGE";
$rrd_options .= " DEF:load_max=$database:LOAD:MAX";
$rrd_options .= " DEF:load_min=$database:LOAD:MIN";
$rrd_options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n";
$rrd_options .= " AREA:load#ffee99: LINE1.25:load#aa2200:Load\ %";
$rrd_options .= " GPRINT:load:LAST:%6.2lf\ GPRINT:load_min:AVERAGE:%6.2lf\ ";
$rrd_options .= " GPRINT:load_max:MAX:%6.2lf\ GPRINT:load:AVERAGE:%6.2lf\\\\n";
?>
@@ -0,0 +1,25 @@
<?php
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/procurve-mem.rrd";
$rrd_options .= " -b 1024";
$rrd_options .= " DEF:TOTAL=$rrd_filename:TOTAL:AVERAGE";
$rrd_options .= " DEF:FREE=$rrd_filename:FREE:AVERAGE";
$rrd_options .= " DEF:USED=$rrd_filename:USED:AVERAGE";
$rrd_options .= " COMMENT:'Bytes Current Average Maximum\\n'";
$rrd_options .= " LINE1:USED#d0b080:";
$rrd_options .= " AREA:USED#f0e0a0:used";
$rrd_options .= " GPRINT:USED:LAST:\ \ \ %7.2lf%sB";
$rrd_options .= " GPRINT:USED:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:USED:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " AREA:FREE#e5e5e5:free:STACK";
$rrd_options .= " GPRINT:FREE:LAST:\ \ \ %7.2lf%sB";
$rrd_options .= " GPRINT:FREE:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:FREE:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " LINE1:TOTAL#e5e5e5:";
?>
+1 -1
View File
@@ -71,7 +71,7 @@ while($device = mysql_fetch_array($device_query)) {
break;
case "ProCurve":
case "procurve":
echo("<div class=graphhead>Processor Utilisation</div>");
$graph_type = "device_cpu"; include ("includes/print-device-graph.php");
echo("<br />");
@@ -1,3 +1,10 @@
<?php
if(!$os) {
if(strstr($sysDescr, "ProCurve")) { $os = "procurve"; }
}
?>
+10 -5
View File
@@ -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;
+2 -2
View File
@@ -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");
+34 -10
View File
@@ -1,15 +1,17 @@
<?php
$cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd";
$memrrd = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd";
list($hardware, $features, $version) = explode(",", str_replace(", ", ",", $sysDescr));
list($version) = explode("(", $version);
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0";
$cpu = `$cpu_cmd`;
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/procurve-cpu.rrd";
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/procurve-mem.rrd";
$cpu_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0";
$cpu = shell_exec($cpu_cmd);
$mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$mem_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$mem_cmd .= " 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.5.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.6.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.7.1";
$mem = `$mem_cmd`;
$mem = shell_exec($mem_cmd);
list ($memtotal, $memfree, $memused) = explode("\n", $mem);
@@ -18,13 +20,35 @@ $memfree = $memfree + 0;
$memtotal = $memtotal + 0;
if (!is_file($cpurrd)) {
$rrdcreate = `rrdtool create $cpurrd --step 300 DS:LOAD:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200`;
$rrdcreate = shell_exec($config['rrdtool'] ." create $cpurrd --step 300 DS:LOAD:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200 RRA:AVERAGE:0.5:1:2000 \
RRA:AVERAGE:0.5:6:2000 \
RRA:AVERAGE:0.5:24:2000 \
RRA:AVERAGE:0.5:288:2000 \
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000 \
RRA:MIN:0.5:1:2000 \
RRA:MIN:0.5:6:2000 \
RRA:MIN:0.5:24:2000 \
RRA:MIN:0.5:288:2000");
}
if (!is_file($memrrd)) {
$rrdcreate = `rrdtool create $memrrd --step 300 DS:TOTAL:GAUGE:600:0:500000000 DS:FREE:GAUGE:600:-1:500000000 DS:USED:GAUGE:600:0:500000000 RRA:AVERAGE:0.5:1:1200`;
$rrdcreate = shell_exec($config['rrdtool'] ." create $memrrd --step 300 DS:TOTAL:GAUGE:600:0:500000000 DS:FREE:GAUGE:600:-1:500000000 DS:USED:GAUGE:600:0:500000000 RRA:AVERAGE:0.5:1:1200 RRA:AVERAGE:0.5:1:2000 \
RRA:AVERAGE:0.5:6:2000 \
RRA:AVERAGE:0.5:24:2000 \
RRA:AVERAGE:0.5:288:2000 \
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000 \
RRA:MIN:0.5:1:2000 \
RRA:MIN:0.5:6:2000 \
RRA:MIN:0.5:24:2000 \
RRA:MIN:0.5:288:2000");
}
`rrdtool update $cpurrd N:$cpu`;
`rrdtool update $memrrd N:$memtotal:$memfree:$memused`;
rrdtool_update($cpurrd, "N:$cpu");
rrdtool_update($memrrd, "N:$memtotal:$memfree:$memused");
?>
+32
View File
@@ -0,0 +1,32 @@
<?php
if($array[$device[device_id]][$port[ifIndex]] && $port['ifType'] == "ethernetCsmacd") { // 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);
echo("EtherLike ");
}
?>
-67
View File
@@ -1,67 +0,0 @@
<?php
unset($ports);
$ports = snmp_cache_ifIndex($device); // Cache Port List
// Build SNMP Cache Array
$etherlike_oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames',
'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions',
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
'dot3StatsSymbolErrors');
if(count($etherlike_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($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");
}
?>
+8 -16
View File
@@ -15,7 +15,7 @@
$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++;
+2 -19
View File
@@ -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'");
+7 -7
View File
@@ -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)