mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 08:02:23 +02:00
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
This commit is contained in:
@@ -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`;
|
||||
|
||||
@@ -6,14 +6,13 @@ function print_percentage_bar ($width, $height, $percent, $left_text, $left_colo
|
||||
<div style="font-size:11px;">
|
||||
<div style=" width:'.$width.'px; height:'.$height.'px; background-color:#'.$right_background.';">
|
||||
<div style="width:'.$percent.'%; height:'.$height.'px; background-color:#'.$left_background.'; border-right:0px white solid;"></div>
|
||||
<div style="vertical-align: center;height: '.$height.'px;margin-top:-'.($height + 2).'px; color:#'.$left_colour .'; padding-left :4px;"><b>'.$left_text.'</b></div>
|
||||
<div style="vertical-align: center;height: '.$height.'px;margin-top:-'.($height + 2).'px; color:#'.$right_colour.'; padding-right:4px;text-align:right;"><b>'.$right_text.'</b></div>
|
||||
<div style="vertical-align: center;height: '.$height.'px;margin-top:-'.($height).'px; color:#'.$left_colour .'; padding-left :4px;"><b>'.$left_text.'</b></div>
|
||||
<div style="vertical-align: center;height: '.$height.'px;margin-top:-'.($height).'px; color:#'.$right_colour.'; padding-right:4px;text-align:right;"><b>'.$right_text.'</b></div>
|
||||
</div>
|
||||
</div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function generate_if_link($args)
|
||||
{
|
||||
global $twoday; global $now; global $config; global $day; global $month;
|
||||
|
||||
@@ -6,10 +6,8 @@ $query = mysql_query($sql);
|
||||
echo("<table cellspacing=0 cellpadding=5 width=100%>");
|
||||
|
||||
echo("<tr class=tablehead>
|
||||
<th width=200>Drive</th>
|
||||
<th width=360>Usage</th>
|
||||
<th width=50>Used</th>
|
||||
<th width=50>Total</th>
|
||||
<th width=250>Drive</th>
|
||||
<th width=420>Usage</th>
|
||||
<th width=50>Free</th>
|
||||
<th></th>
|
||||
</tr>");
|
||||
@@ -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 .= "</div><img src=\'graph.php?id=" . $drive['storage_id'] . "&type=hrstorage&from=$month&to=$now&width=400&height=125\'>";
|
||||
$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("<tr bgcolor='$row_colour'><th><a href='$fs_url' $fs_popup>" . $drive['hrStorageDescr'] . "</a></td><td>
|
||||
<a href='$fs_url' $fs_popup><img src='percentage.php?per=" . $perc . "&width=350'></a>
|
||||
</td><td style='font-weight: bold; color: $drv_colour'>" . $perc . "%</td><td>" . $total . "</td><td>" . $free . "</td><td></td></tr>");
|
||||
<a href='$fs_url' $fs_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)."</a>
|
||||
</td><td>" . $free . "</td><td></td></tr>");
|
||||
|
||||
|
||||
$graph_type = "hrstorage";
|
||||
|
||||
@@ -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('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr'];
|
||||
$fs_popup .= "</div><img src=\'graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125\'>";
|
||||
$fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"";
|
||||
@@ -35,7 +41,7 @@ while($drive = mysql_fetch_array($query)) {
|
||||
$drv_colour = percent_colour($perc);
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><th><a href='$fs_url' $fs_popup>" . $drive['hrStorageDescr'] . "</a></td><td>
|
||||
<a href='$fs_url' $fs_popup><img src='percentage.php?per=" . $perc . "&width=350'></a>
|
||||
<a href='$fs_url' $fs_popup>".print_percentage_bar (200, 16, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)."</a>
|
||||
</td><td style='font-weight: bold; color: $drv_colour'>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td><td></td></tr>");
|
||||
|
||||
|
||||
|
||||
+12
-8
@@ -14,11 +14,9 @@ echo("<div style='padding: 5px;'>
|
||||
|
||||
echo("<tr class=tablehead>
|
||||
<th width=280>Device</th>
|
||||
<th width=175>Storage</th>
|
||||
<th width=360>Usage</th>
|
||||
<th width=60></th>
|
||||
<th width=100>Size</th>
|
||||
<th width=100>Used</th>
|
||||
<th>Storage</th>
|
||||
<th width=420>Usage</th>
|
||||
<th width=100>Free</th>
|
||||
</tr>");
|
||||
|
||||
$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('<img src=\'$store_url\'>', 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("<tr bgcolor='$row_colour'><td>" . generatedevicelink($drive) . "</td><td class=tablehead>" . $drive['hrStorageDescr'] . "</td><td>
|
||||
<a href='#' $store_popup><img src='percentage.php?per=" . $perc . "&width=350'></a>
|
||||
</td><td style='font-weight: bold; color: $drv_colour'>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td></tr>");
|
||||
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)."</a>
|
||||
</td><td>" . formatStorage($free) . "</td></tr>");
|
||||
|
||||
|
||||
$row++;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+4
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user