From 890bda49c30f99efca2da67e696f1db469e7af21 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 10 Nov 2009 14:15:32 +0000 Subject: [PATCH] add new mempool graphing git-svn-id: http://www.observium.org/svn/observer/trunk@507 61d68cd4-352d-0410-923a-c4978735b2b8 --- 060-to-current.sql | 3 + discovery.php | 4 +- html/includes/graphs/cmpMemPool.inc.php | 29 +++++++++ .../includes/graphs/device_memory_ios.inc.php | 50 ++++++++-------- html/pages/device/health.inc.php | 6 +- html/pages/device/health/cmp.inc.php | 55 +++++++++++++++++ .../{cisco-mempool.php => cemp-mib.php} | 2 +- includes/discovery/cisco-processors.php | 4 +- includes/discovery/cmp-mib.php | 39 ++++++++++++ includes/functions-poller.inc.php | 2 +- .../polling/cisco-enhanced-mempool.inc.php | 60 +++++++++++++++++++ includes/polling/cisco-mempool.inc.php | 35 ++++++----- includes/polling/device-ios.inc.php | 1 + 13 files changed, 238 insertions(+), 52 deletions(-) create mode 100755 html/includes/graphs/cmpMemPool.inc.php create mode 100644 html/pages/device/health/cmp.inc.php rename includes/discovery/{cisco-mempool.php => cemp-mib.php} (98%) create mode 100755 includes/discovery/cmp-mib.php create mode 100755 includes/polling/cisco-enhanced-mempool.inc.php diff --git a/060-to-current.sql b/060-to-current.sql index b6b1104a0..ce485aa96 100644 --- a/060-to-current.sql +++ b/060-to-current.sql @@ -63,3 +63,6 @@ ALTER TABLE `interfaces` DROP `in_rate`; ALTER TABLE `interfaces` DROP `out_rate`; ALTER TABLE `interfaces` DROP `in_errors`; ALTER TABLE `interfaces` DROP `out_errors`; +CREATE TABLE IF NOT EXISTS `cmpMemPool` ( `cmp_id` int(11) NOT NULL auto_increment, `Index` varchar(8) NOT NULL, `cmpName` varchar(32) NOT NULL, `cmpValid` varchar(8) NOT NULL, `device_id` int(11) NOT NULL, `cmpUsed` int(11) NOT NULL, `cmpFree` int(11) NOT NULL, `cmpLargestFree` int(11) NOT NULL, `cmpAlternate` tinyint(4) default NULL, PRIMARY KEY (`cmp_id`), KEY `device_id` (`device_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; +CREATE TABLE IF NOT EXISTS `hrDevice` ( `hrDevice_id` int(11) NOT NULL auto_increment, `device_id` int(11) NOT NULL, `hrDeviceIndex` int(11) NOT NULL, `hrDeviceDescr` text NOT NULL, `hrDeviceType` text NOT NULL, `hrDeviceErrors` int(11) NOT NULL, `hrDeviceStatus` text NOT NULL, `hrProcessorLoad` tinyint(4) default NULL, PRIMARY KEY (`hrDevice_id`), KEY `device_id` (`device_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; + diff --git a/discovery.php b/discovery.php index 56b9d0707..f13ac5773 100755 --- a/discovery.php +++ b/discovery.php @@ -78,8 +78,8 @@ while ($device = mysql_fetch_array($device_query)) { include("includes/discovery/cisco-pw.php"); include("includes/discovery/cisco-vrf.php"); include("includes/discovery/cisco-processors.php"); - include("includes/discovery/cisco-mempool.php"); - + include("includes/discovery/cemp-mib.php"); + include("includes/discovery/cmp-mib.php"); } echo("\n"); $devices_discovered++; diff --git a/html/includes/graphs/cmpMemPool.inc.php b/html/includes/graphs/cmpMemPool.inc.php new file mode 100755 index 000000000..f57526069 --- /dev/null +++ b/html/includes/graphs/cmpMemPool.inc.php @@ -0,0 +1,29 @@ + diff --git a/html/includes/graphs/device_memory_ios.inc.php b/html/includes/graphs/device_memory_ios.inc.php index 053598f33..87c8cc4a1 100644 --- a/html/includes/graphs/device_memory_ios.inc.php +++ b/html/includes/graphs/device_memory_ios.inc.php @@ -2,11 +2,9 @@ include("common.inc.php"); - $rrd_options .= " -l 0 -E -b 1024 -u 100 -r"; +$rrd_options .= " -l 0 -E -b 1024 -u 100 -r"; - $count = mysql_result(mysql_query("SELECT COUNT(*) FROM `cempMemPool` WHERE `device_id` = '$device_id'"),0); - -if($count > '0') { +if(mysql_result(mysql_query("SELECT COUNT(*) FROM `cempMemPool` WHERE `device_id` = '$device_id'"),0) > '0') { $iter = "1"; $rrd_options .= " COMMENT:' Currently Used Max\\n'"; $sql = mysql_query("SELECT * FROM `cempMemPool` where `device_id` = '$device_id'"); @@ -37,27 +35,29 @@ if($count > '0') { $iter++; } } else { - $database = $config['rrd_dir'] . "/" . $hostname . "/ios-mem.rrd"; - $rrd_options .= " DEF:MEMTOTAL=$database:MEMTOTAL:AVERAGE"; - $rrd_options .= " DEF:IOFREE=$database:IOFREE:AVERAGE"; - $rrd_options .= " DEF:IOUSED=$database:IOUSED:AVERAGE"; - $rrd_options .= " DEF:PROCFREE=$database:PROCFREE:AVERAGE"; - $rrd_options .= " DEF:PROCUSED=$database:PROCUSED:AVERAGE"; - $rrd_options .= " CDEF:FREE=IOFREE,PROCFREE,+"; - $rrd_options .= " CDEF:USED=IOUSED,PROCUSED,+"; - $rrd_options .= " COMMENT:Bytes\ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n"; - $rrd_options .= " AREA:USED#ff6060:"; - $rrd_options .= " LINE2:USED#cc0000:Used"; - $rrd_options .= " GPRINT:USED:LAST:%6.2lf%s"; - $rrd_options .= " GPRINT:USED:MIN:%6.2lf%s"; - $rrd_options .= " GPRINT:USED:MAX:%6.2lf%s"; - $rrd_options .= " GPRINT:USED:AVERAGE:%6.2lf%s\\\\l"; - $rrd_options .= " AREA:FREE#e5e5e5:Free:STACK"; - $rrd_options .= " GPRINT:FREE:LAST:%6.2lf%s"; - $rrd_options .= " GPRINT:FREE:MIN:%6.2lf%s"; - $rrd_options .= " GPRINT:FREE:MAX:%6.2lf%s"; - $rrd_options .= " GPRINT:FREE:AVERAGE:%6.2lf%s\\\\l"; - $rrd_options .= " LINE1:MEMTOTAL#000000:"; + $iter = "1"; + $rrd_options .= " COMMENT:' Currently Used Max\\n'"; + $sql = mysql_query("SELECT * FROM `cmpMemPool` where `device_id` = '$device_id'"); + while($mempool = mysql_fetch_array($sql)) { + if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; + } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; + } elseif($iter=="7") {$colour="FF0084"; unset($iter); } + $mempool['descr_fixed'] = $mempool['cmpName']; + $mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 20); + $mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,20); + $oid = $mempool['Index']; + $rrd = $config['rrd_dir'] . "/$hostname/cmp-$oid.rrd"; + $rrd_options .= " DEF:mempool" . $iter . "free=$rrd:free:AVERAGE"; + $rrd_options .= " DEF:mempool" . $iter . "used=$rrd:used:AVERAGE"; + $rrd_options .= " DEF:mempool" . $iter . "free_m=$rrd:free:MAX"; + $rrd_options .= " DEF:mempool" . $iter . "used_m=$rrd:used:MAX"; + $rrd_options .= " CDEF:mempool" . $iter . "total=mempool" . $iter . "used,mempool" . $iter . "used,mempool" . $iter . "free,+,/,100,* "; + $rrd_options .= " LINE1:mempool" . $iter . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' "; + $rrd_options .= " GPRINT:mempool" . $iter . "used:LAST:%6.2lf%s"; + $rrd_options .= " GPRINT:mempool" . $iter . "total:LAST:%3.0lf%%"; + $rrd_options .= " GPRINT:mempool" . $iter . "total:MAX:%3.0lf%%\\\\n"; + $iter++; + } } ?> diff --git a/html/pages/device/health.inc.php b/html/pages/device/health.inc.php index 85b010498..c6e08065e 100644 --- a/html/pages/device/health.inc.php +++ b/html/pages/device/health.inc.php @@ -3,6 +3,7 @@ $temp = mysql_result(mysql_query("select count(*) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0); $storage = mysql_result(mysql_query("select count(*) from storage WHERE host_id = '" . $device['device_id'] . "'"), 0); $cemp = mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0); +$cmp = mysql_result(mysql_query("select count(*) from cmpMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0); $cpm = mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0); $hrprocessor = mysql_result(mysql_query("select count(*) from hrDevice WHERE device_id = '" . $device['device_id'] . "' AND `hrDeviceType` = 'hrDeviceProcessor'"), 0); @@ -11,11 +12,12 @@ if($temp) { $datas[] = 'temp'; } if($storage) { $datas[] = 'storage'; } if($cemp) { $datas[] = 'cemp'; } if($cpm) { $datas[] = 'cpm'; } +if($cmp) { $datas[] = 'cmp'; } if($hrprocessor) { $datas[] = 'hrprocessors'; } - $type_text['temp'] = "Temperatures"; -$type_text['cemp'] = "Memory Pools"; +$type_text['cmp'] = "Memory Pools"; +$type_text['cemp'] = "Memory Enh Pools"; $type_text['cpm'] = "Processor Usage"; $type_text['storage'] = "Disk Usage"; $type_text['hrprocessors'] = "Processor Usage"; diff --git a/html/pages/device/health/cmp.inc.php b/html/pages/device/health/cmp.inc.php new file mode 100644 index 000000000..6487b1714 --- /dev/null +++ b/html/pages/device/health/cmp.inc.php @@ -0,0 +1,55 @@ +"); + echo(""); + $i = '1'; + $mempools = mysql_query("SELECT * FROM `cmpMemPool` WHERE device_id = '" . $device['device_id'] . "'"); + while($mempool = mysql_fetch_array($mempools)) { + if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + + $perc = round($mempool['cmpUsed'] / ($mempool['cmpUsed'] + $mempool['cmpFree']) * 100,2); + + $proc_url = "?page=device/".$device['device_id']."/sensors/mempools/"; + + $mempool_popup = "onmouseover=\"return overlib('
".$device['hostname']." - ".$mempool['cmpName']; + $mempool_popup .= "
"; + $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + + if($mempool['cpuCPMTotal5minRev'] > '60') { $mempool_colour='#cc0000'; } else { $mempool_colour='#0000cc'; } + echo(" + + + + "); + + echo(""); + + $i++; + } + echo("
" . $mempool['cmpName'] ."$perc%" . formatstorage($mempool['cmpFree'], 0) . "/" . formatstorage($mempool['cmpUsed'] + $mempool['cmpFree'], 0) . "
"); + + $daily_graph = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$day&to=$now&width=211&height=100"; + $daily_url = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$day&to=$now&width=400&height=150"; + + $weekly_graph = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$week&to=$now&width=211&height=100"; + $weekly_url = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$week&to=$now&width=400&height=150"; + + $monthly_graph = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$month&to=$now&width=211&height=100"; + $monthly_url = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$month&to=$now&width=400&height=150"; + + $yearly_graph = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$year&to=$now&width=211&height=100"; + $yearly_url = "graph.php?id=" . $mempool['cmp_id'] . "&type=cmpMemPool&from=$year&to=$now&width=400&height=150"; + + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("
"); + echo(""); + + +?> diff --git a/includes/discovery/cisco-mempool.php b/includes/discovery/cemp-mib.php similarity index 98% rename from includes/discovery/cisco-mempool.php rename to includes/discovery/cemp-mib.php index 0ca7f1bbc..2b6813284 100755 --- a/includes/discovery/cisco-mempool.php +++ b/includes/discovery/cemp-mib.php @@ -5,7 +5,7 @@ $snmpver = $device['snmpver']; $port = $device['port']; - echo("Cisco Enh Mempool : "); + echo("CISCO-ENHANCED-MEMORY-POOL : "); ## Cisco Enhanced Mempool if($device['os'] == "IOS" || $device['os'] == "IOS XE") { diff --git a/includes/discovery/cisco-processors.php b/includes/discovery/cisco-processors.php index 8027adef0..18174fbb6 100755 --- a/includes/discovery/cisco-processors.php +++ b/includes/discovery/cisco-processors.php @@ -5,7 +5,7 @@ $snmpver = $device['snmpver']; $port = $device['port']; - echo("Cisco Procs : "); + echo("CISCO-PROCESS-MIB : "); ## Cisco Processors if($device['os'] == "IOS" || $device['os'] == "IOS XE") { @@ -27,11 +27,9 @@ $descr = str_replace("Routing Processor", "RP", $descr); $descr = str_replace("Switching Processor", "SP", $descr); $descr = trim($descr); -# echo("[$descr ($oid)] "); if(mysql_result(mysql_query("SELECT count(cpmCPU_id) FROM `cpmCPU` WHERE `cpmCPU_oid` = '$oid' AND `device_id` = '$id'"),0) == '0') { $query = "INSERT INTO cpmCPU (`entPhysicalIndex`, `device_id`, `entPhysicalDescr`, `cpmCPU_oid`) values ('$entPhysicalIndex', '$id', '$descr', '$oid')"; mysql_query($query); -# echo("$query"); echo("+"); } else { echo("."); } $valid_cpm[$id][$oid] = 1; diff --git a/includes/discovery/cmp-mib.php b/includes/discovery/cmp-mib.php new file mode 100755 index 000000000..e93b9f05a --- /dev/null +++ b/includes/discovery/cmp-mib.php @@ -0,0 +1,39 @@ + $cmp) { + if(is_array($cmp)) { + if(mysql_result(mysql_query("SELECT count(cmp_id) FROM `cmpMemPool` WHERE `Index` = '$index' AND `device_id` = '".$device['device_id']."'"),0) == '0') { + $query = "INSERT INTO cmpMemPool (`Index`,`cmpName`,`cmpAlternate`,`cmpValid`,`cmpUsed`,`cmpFree`,`cmpLargestFree`,`device_id`) + values ('$index', '".$cmp['ciscoMemoryPoolName']."', '".$cmp['ciscoMemoryPoolAlternate']."', + '".$cmp['ciscoMemoryPoolValid']."', '".$cmp['ciscoMemoryPoolUsed']."', '".$cmp['ciscoMemoryPoolFree']."', + '".$cmp['ciscoMemoryPoolLargestFree']."', '".$device['device_id']."')"; + mysql_query($query); + echo("+"); + } else { + + } + + $valid_cmp[$index] = 1; + } +} + +$sql = "SELECT * FROM `cmpMemPool` WHERE `device_id` = '".$device['device_id']."'"; +$query = mysql_query($sql); + +while ($test_ciscoMemoryPool = mysql_fetch_array($query)) { + if(!$valid_cmp[$test_ciscoMemoryPool[Index]]) { + echo("-"); + mysql_query("DELETE FROM `ciscoMemoryPool` WHERE ciscoMemoryPool_id = '" . $test['ciscoMemoryPool_id'] . "'"); + } +} + +unset($valid_ciscoMemoryPool); +echo("\n"); + +?> diff --git a/includes/functions-poller.inc.php b/includes/functions-poller.inc.php index 887e9283e..213ade38e 100644 --- a/includes/functions-poller.inc.php +++ b/includes/functions-poller.inc.php @@ -74,7 +74,7 @@ function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0) { function snmp_cache_oid($oid, $device, $array, $mib = 0) { global $config; - $cmd = $config['snmpbulkwalk'] . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $cmd = $config['snmpbulkwalk'] . " -O UQs -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; if($mib) { $cmd .= "-m $mib "; } $cmd .= $oid; $data = trim(shell_exec($cmd)); diff --git a/includes/polling/cisco-enhanced-mempool.inc.php b/includes/polling/cisco-enhanced-mempool.inc.php new file mode 100755 index 000000000..f62b869ec --- /dev/null +++ b/includes/polling/cisco-enhanced-mempool.inc.php @@ -0,0 +1,60 @@ + diff --git a/includes/polling/cisco-mempool.inc.php b/includes/polling/cisco-mempool.inc.php index 5203c5f07..c59a99389 100755 --- a/includes/polling/cisco-mempool.inc.php +++ b/includes/polling/cisco-mempool.inc.php @@ -1,34 +1,33 @@ diff --git a/includes/polling/device-ios.inc.php b/includes/polling/device-ios.inc.php index 2733f866d..d034ece08 100755 --- a/includes/polling/device-ios.inc.php +++ b/includes/polling/device-ios.inc.php @@ -75,6 +75,7 @@ include("includes/polling/bgpPeer.inc.php"); include("includes/polling/cisco-processors.inc.php"); + include("includes/polling/cisco-enhanced-mempool.inc.php"); include("includes/polling/cisco-mempool.inc.php"); include("includes/polling/cisco-entity-sensors.inc.php");