From 5852121416c6dd1a7e49adbc3e196dd6d9057805 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 21 Feb 2010 01:35:13 +0000 Subject: [PATCH] add a default catch-all IOS cpu poller using avgBusy5 git-svn-id: http://www.observium.org/svn/observer/trunk@899 61d68cd4-352d-0410-923a-c4978735b2b8 --- database-update.sql | 1 + html/includes/functions.inc.php | 5 ++--- html/pages/device/health/storage.inc.php | 18 +++++++++++------- html/pages/device/storage.inc.php | 8 +++++++- html/pages/storage.php | 20 ++++++++++++-------- includes/discovery/functions.inc.php | 21 +++++++++++++++++++++ includes/discovery/processors-ios.inc.php | 21 +++++++-------------- poll-device.php | 5 ++++- 8 files changed, 65 insertions(+), 34 deletions(-) diff --git a/database-update.sql b/database-update.sql index 5e07cf8fe..fb404e9cd 100644 --- a/database-update.sql +++ b/database-update.sql @@ -106,3 +106,4 @@ ALTER TABLE `syslog` CHANGE `datetime` `datetime` TIMESTAMP NOT NULL DEFAULT CUR ALTER TABLE `syslog` DROP `host`, DROP `processed`; RENAME TABLE `interfaces` TO `ports` ; RENAME TABLE `interfaces_perms` TO `ports_perms` ; +ALTER TABLE `temperature` ADD `temp_index` VARCHAR( 32 ) NOT NULL AFTER `device_id` , ADD `temp_type` VARCHAR( 16 ) NOT NULL AFTER `temp_index`; diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 3cf379181..d0ea23ae8 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -6,14 +6,13 @@ function print_percentage_bar ($width, $height, $percent, $left_text, $left_colo
-
'.$left_text.'
-
'.$right_text.'
+
'.$left_text.'
+
'.$right_text.'
'; return $output; } - function generate_if_link($args) { global $twoday; global $now; global $config; global $day; global $month; diff --git a/html/pages/device/health/storage.inc.php b/html/pages/device/health/storage.inc.php index 0b1b5c575..46a661934 100644 --- a/html/pages/device/health/storage.inc.php +++ b/html/pages/device/health/storage.inc.php @@ -6,10 +6,8 @@ $query = mysql_query($sql); echo(""); echo(" - - - - + + "); @@ -21,8 +19,10 @@ while($drive = mysql_fetch_array($query)) { if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } $total = $drive['hrStorageSize'] * $drive['hrStorageAllocationUnits']; + $used = $drive['hrStorageUsed'] * $drive['hrStorageAllocationUnits']; $free = $total - $drive['hrStorageUsed'] * $drive['hrStorageAllocationUnits']; $perc = round($drive['storage_perc'], 0); + $used = formatStorage($used); $total = formatStorage($total); $free = formatStorage($free); @@ -32,11 +32,15 @@ while($drive = mysql_fetch_array($query)) { $fs_popup .= ""; $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - $drv_colour = percent_colour($perc); + if($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; + } elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; + } elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; + } elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; + } else { $left_background='9abf5b'; $right_background='bbd392'; } echo(""); + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)." + "); $graph_type = "hrstorage"; diff --git a/html/pages/device/storage.inc.php b/html/pages/device/storage.inc.php index 3b2b67598..888a1ad81 100644 --- a/html/pages/device/storage.inc.php +++ b/html/pages/device/storage.inc.php @@ -28,6 +28,12 @@ while($drive = mysql_fetch_array($query)) { $fs_url = "?page=device&id=".$device['device_id']."§ion=dev-storage"; + if($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; + } elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; + } elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; + } elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; + } else { $left_background='9abf5b'; $right_background='bbd392'; } + $fs_popup = "onmouseover=\"return overlib('
".$device['hostname']." - ".$drive['hrStorageDescr']; $fs_popup .= "
"; $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; @@ -35,7 +41,7 @@ while($drive = mysql_fetch_array($query)) { $drv_colour = percent_colour($perc); echo(""); diff --git a/html/pages/storage.php b/html/pages/storage.php index 17276ba47..968d9205c 100644 --- a/html/pages/storage.php +++ b/html/pages/storage.php @@ -14,11 +14,9 @@ echo("
echo("
- - - - - + + + "); $row = 1; @@ -40,6 +38,7 @@ while($drive = mysql_fetch_array($query)) { $total = $drive['hrStorageSize'] * $drive['hrStorageAllocationUnits']; $used = $drive['hrStorageUsed'] * $drive['hrStorageAllocationUnits']; + $free = $total - $used; $perc = round($drive['storage_perc'], 0); $total = formatStorage($total); $used = formatStorage($used); @@ -47,11 +46,16 @@ while($drive = mysql_fetch_array($query)) { $store_url = "graph.php?id=" . $drive['storage_id'] . "&type=hrstorage&from=$month&to=$now&width=400&height=125"; $store_popup = "onmouseover=\"return overlib('', LEFT);\" onmouseout=\"return nd();\""; - $drv_colour = percent_colour($perc); + if($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; + } elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; + } elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; + } elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; + } else { $left_background='9abf5b'; $right_background='bbd392'; } + echo(""); + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)." + "); $row++; diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 8dec6e5b8..35ae856fb 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -26,6 +26,27 @@ function discover_link($local_interface_id, $protocol, $remote_interface_id, $re } +function discover_processor(&$valid_processor, $device, $oid, $index, $type, $descr, $precision = "1", $current = NULL, $entPhysical = NULL, $hrDevice = NULL) { + + global $config; global $debug; global $valid_processor; + if($debug) { echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysical, $hrDevice\n"); } + if($descr) { + if(mysql_result(mysql_query("SELECT count(processor_id) FROM `processors` WHERE `processor_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `processor_type` = '$type'"),0) == '0') { + $query = "INSERT INTO processors (`entPhysicalIndex`, `device_id`, `processor_descr`, `processor_index`, `processor_oid`, `processor_usage`, `processor_type`) + values ('$entPhysicalIndex', '".$device['device_id']."', '$descr', '$index', '$usage_oid', '$usage', '$type')"; + mysql_query($query); + if($debug) { print $query . "\n"; } + echo("+"); + } else { + echo("."); + $query = "UPDATE `processors` SET `processor_descr` = '".$descr."', `processor_oid` = '".$usage_oid."', `processor_usage` = '".$usage."' + WHERE `device_id` = '".$device['device_id']."' AND `processor_index` = '".$index."' AND `processor_type` = '".$type."'"; + mysql_query($query); + if($debug) { print $query . "\n"; } + } + $valid_processor[$type][$index] = 1; + } +} function discover_fan($device, $oid, $index, $type, $descr, $precision = 1, $low_limit = NULL, $high_limit = NULL, $current = NULL) { diff --git a/includes/discovery/processors-ios.inc.php b/includes/discovery/processors-ios.inc.php index 329e47772..3254dd7f5 100755 --- a/includes/discovery/processors-ios.inc.php +++ b/includes/discovery/processors-ios.inc.php @@ -33,23 +33,16 @@ if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) { - if(mysql_result(mysql_query("SELECT count(processor_id) FROM `processors` WHERE `processor_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `processor_type` = 'cpm'"),0) == '0') { - $query = "INSERT INTO processors (`entPhysicalIndex`, `device_id`, `processor_descr`, `processor_index`, `processor_oid`, `processor_usage`, `processor_type`) - values ('$entPhysicalIndex', '".$device['device_id']."', '$descr', '$index', '$usage_oid', '".$entry['juniSystemModuleCpuUtilPct']."', 'cpm')"; - mysql_query($query); - if($debug) { print $query . "\n"; } - echo("+"); - } else { - echo("."); - $query = "UPDATE `processors` SET `processor_descr` = '".$descr."', `processor_oid` = '".$usage_oid."', `processor_usage` = '".$usage."' - WHERE `device_id` = '".$device['device_id']."' AND `processor_index` = '".$index."' AND `processor_type` = 'cpm'"; - mysql_query($query); - if($debug) { print $query . "\n"; } - } - $valid_processor['cpm'][$index] = 1; + discover_processor($valid_processor, $device, $oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL); } } } + if(!is_array($valid_processor['cpm'])) { + $avgBusy5 = snmp_get($device, ".1.3.6.1.4.1.9.2.1.58.0", "-Oqv"); + if(is_numeric($avgBusy5)) { + discover_processor($valid_processor, $device, ".1.3.6.1.4.1.9.2.1.58.0", "0", "ios", "Processor", $precision = "1", $current = $avgBusy5, $entPhysical = NULL, $hrDevice = NULL); + } + } } ## End Cisco Processors diff --git a/poll-device.php b/poll-device.php index c2e2e67ff..9aba77052 100755 --- a/poll-device.php +++ b/poll-device.php @@ -43,7 +43,7 @@ $polled_devices = 0; $device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' $where ORDER BY `device_id` ASC"); while ($device = mysql_fetch_array($device_query)) { $status = 0; unset($array); - + $device_start = utime(); // Start counting device poll time echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." "); if ($os_groups[$device[os]]) {$device['os_group'] = $os_groups[$device[os]]; echo "(".$device['os_group'].")";} echo("\n"); @@ -203,6 +203,9 @@ while ($device = mysql_fetch_array($device_query)) { echo("No Changes to " . $device['hostname'] . "\n"); } + $device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5); + echo("Polled in $device_time seconds\n"); + } $poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5);
DriveUsageUsedTotalDriveUsage Free
" . $drive['hrStorageDescr'] . " - - " . $perc . "%" . $total . "" . $free . "
" . $free . "
" . $drive['hrStorageDescr'] . " - + ".print_percentage_bar (200, 16, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)." " . $perc . "%" . $total . "" . $used . "
DeviceStorageUsageSizeUsedStorageUsageFree
" . generatedevicelink($drive) . "" . $drive['hrStorageDescr'] . " - - " . $perc . "%" . $total . "" . $used . "
" . formatStorage($free) . "