move processors discovery to include_dir

git-svn-id: http://www.observium.org/svn/observer/trunk@1326 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-07-10 11:23:14 +00:00
parent 5c97185974
commit b3b7db7e3a
10 changed files with 151 additions and 138 deletions

View File

@ -1,48 +0,0 @@
<?php
if($device['os_group'] == "unix" || $device['os'] == "windows")
{
echo("hrDevice ");
$hrDevice_oids = array('hrDevice','hrProcessorLoad');
if($debug) { print_r($processors_array); }
foreach ($hrDevice_oids as $oid) { $hrDevice_array = snmp_cache_oid($oid, $device, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
foreach($hrDevice_array[$device['device_id']] as $index => $entry)
{
if ($entry['hrDeviceType'] == "hrDeviceProcessor")
{
$hrDeviceIndex = $entry['hrDeviceIndex'];
$usage_oid = ".1.3.6.1.2.1.25.3.3.1.2." . $index;
$usage = $entry['hrProcessorLoad'];
$descr = $entry['hrDeviceDescr'];
$descr_array = explode(":",$entry['hrDeviceDescr']);
if($descr_array['1']) { $descr = $descr_array['1']; } else { $descr = $descr_array['0']; }
$descr = str_replace("CPU ", "", $descr);
$descr = str_replace("(TM)", "", $descr);
$descr = str_replace("(R)", "", $descr);
$old_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("hrProcessor-" . $index . ".rrd");
$new_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-hr-" . $index . ".rrd");
if($debug) { echo("$old_rrd $new_rrd"); }
if (is_file($old_rrd)) {
rename($old_rrd,$new_rrd);
echo("Moved RRD ");
}
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" && $descr != "An electronic chip that makes the computer work.")
{
discover_processor($valid_processor, $device, $usage_oid, $index, "hr", $descr, "1", $usage, NULL, $hrDeviceIndex);
}
}
}
}
## End hrDevice Processors
unset ($processors_array);
?>

View File

@ -1,45 +0,0 @@
<?php
if($device['os'] == "ironware" || $device['os_group'] == "ironware")
{
echo("IronWare : ");
$processors_array = snmpwalk_cache_triple_oid($device, "snAgentCpuUtilEntry", $processors_array, "FOUNDRY-SN-AGENT-MIB");
if($debug) { print_r($processors_array); }
foreach($processors_array[$device['device_id']] as $index => $entry)
{
if (($entry['snAgentCpuUtilValue'] || $entry['snAgentCpuUtil100thPercent']) && $entry['snAgentCpuUtilInterval'] == "300")
{
#$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
if($entry['snAgentCpuUtil100thPercent']) {
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.6." . $index;
$usage = $entry['snAgentCpuUtil100thPercent'];
$precision = 100;
} elseif($entry['snAgentCpuUtilValue']) {
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.4." . $index;
$usage = $entry['snAgentCpuUtilValue'];
$precision = 100;
}
list($slot, $instance, $interval) = explode(".", $index);
$descr_oid = "snAgentConfigModuleDescription." . $entry['snAgentCpuUtilSlotNum'];
$descr = snmp_get($device, $descr_oid, "-Oqv", "FOUNDRY-SN-AGENT-MIB");
$descr = str_replace("\"", "", $descr);
list($descr) = explode(" ", $descr);
$descr = "Slot " . $entry['snAgentCpuUtilSlotNum'] . " " . $descr;
$descr = $descr . " [".$instance."]";
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
{
discover_processor($valid_processor, $device, $usage_oid, $index, "ironware", $descr, $precision, $usage, $entPhysicalIndex, NULL);
}
}
}
}
## End Ironware Processors
unset ($processors_array);
?>

View File

@ -1,27 +0,0 @@
<?php
## JUNOSe Processors
if($device['os'] == "junose")
{
echo("JUNOSe : ");
$processors_array = snmpwalk_cache_double_oid($device, "juniSystemModule", $processors_array, "Juniper-System-MIB" , "+".$config['install_dir']."/mibs/junose");
if($debug) { print_r($processors_array); }
foreach($processors_array[$device['device_id']] as $index => $entry) {
if ($entry['juniSystemModuleCpuUtilPct'] && $entry['juniSystemModuleCpuUtilPct'] != "-1") {
$entPhysicalIndex = $entry['juniSystemModulePhysicalIndex'];
$usage_oid = ".1.3.6.1.4.1.4874.2.2.2.1.3.5.1.3." . $index;
$descr_oid = ".1.3.6.1.4.1.4874.2.2.2.1.3.5.1.6." . $index;
$descr = $entry['juniSystemModuleDescr'];
$usage = $entry['juniSystemModuleCpuFiveMinAvgPct'];
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) {
discover_processor($valid_processor, $device, $usage_oid, $index, "junose", $descr, "1", $usage, $entPhysicalIndex, NULL);
}
}
}
} ## End JUNOSe Processors
unset ($processors_array);
?>

View File

@ -1,8 +1,9 @@
<?php
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM processors WHERE device_id = '".$device['device_id']."' AND processor_type != 'ucd-old'"),0);
if($device['os_group'] == "unix" && $count == "0") {
if($device['os_group'] == "unix" && $count == "0")
{
echo("UCD Old: ");
$system = snmp_get($device, "ssCpuSystem.0", "-OvQ", "UCD-SNMP-MIB");
@ -14,7 +15,6 @@ if($device['os_group'] == "unix" && $count == "0") {
if(is_numeric($percent)) {
discover_processor($valid_processor, $device, 0, 0, "ucd-old", CPU, "1", $system+$user, NULL, NULL);
}
}
?>

View File

@ -2,11 +2,7 @@
echo("Processors : ");
include("processors-ios.inc.php");
include("processors-junose.inc.php");
include("processors-junos.inc.php");
include("processors-hrdevice.inc.php");
include("processors-ironware.inc.php");
include_dir("includes/discovery/processors");
## Last-resort discovery here

View File

@ -0,0 +1,47 @@
<?php
global $valid_processor;
if ($device['os_group'] == "unix" || $device['os'] == "windows")
{
echo("hrDevice ");
$hrDevice_oids = array('hrDevice','hrProcessorLoad');
foreach ($hrDevice_oids as $oid) { $hrDevice_array = snmp_cache_oid($oid, $device, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
foreach($hrDevice_array[$device['device_id']] as $index => $entry)
{
if ($entry['hrDeviceType'] == "hrDeviceProcessor")
{
$hrDeviceIndex = $entry['hrDeviceIndex'];
$usage_oid = ".1.3.6.1.2.1.25.3.3.1.2." . $index;
$usage = $entry['hrProcessorLoad'];
$descr = $entry['hrDeviceDescr'];
$descr_array = explode(":",$entry['hrDeviceDescr']);
if($descr_array['1']) { $descr = $descr_array['1']; } else { $descr = $descr_array['0']; }
$descr = str_replace("CPU ", "", $descr);
$descr = str_replace("(TM)", "", $descr);
$descr = str_replace("(R)", "", $descr);
$old_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("hrProcessor-" . $index . ".rrd");
$new_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-hr-" . $index . ".rrd");
if($debug) { echo("$old_rrd $new_rrd"); }
if (is_file($old_rrd)) {
rename($old_rrd,$new_rrd);
echo("Moved RRD ");
}
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" && $descr != "An electronic chip that makes the computer work.")
{
discover_processor($valid_processor, $device, $usage_oid, $index, "hr", $descr, "1", $usage, NULL, $hrDeviceIndex);
}
}
}
}
## End hrDevice Processors
?>

View File

@ -1,11 +1,13 @@
<?php
if($device['os'] == "ios" || $device['os_group'] == "ios")
global $valid_processor;
if ($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("CISCO-PROCESS-MIB : ");
$processors_array = snmpwalk_cache_oid("cpmCPU", $device, $processors_array, "CISCO-PROCESS-MIB");
if($debug) { print_r($processors_array); }
foreach($processors_array[$device['device_id']] as $index => $entry)
foreach ($processors_array[$device['device_id']] as $index => $entry)
{
if ($entry['cpmCPUTotal5minRev'] || $entry['cpmCPUTotal5min'])
{
@ -27,7 +29,8 @@ if($device['os'] == "ios" || $device['os_group'] == "ios")
$new_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-cpm-" . $index . ".rrd");
if($debug) { echo("$old_rrd $new_rrd"); }
if (is_file($old_rrd)) {
if (is_file($old_rrd))
{
shell_exec("mv -f $old_rrd $new_rrd");
echo("Moved RRD ");
}
@ -38,9 +41,11 @@ if($device['os'] == "ios" || $device['os_group'] == "ios")
}
}
}
if(!is_array($valid_processor['cpm'])) {
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)) {
if (is_numeric($avgBusy5))
{
discover_processor($valid_processor, $device, ".1.3.6.1.4.1.9.2.1.58.0", "0", "ios", "Processor", "1", $avgBusy5, NULL, NULL);
}
}

View File

@ -0,0 +1,47 @@
<?php
global $valid_processor;
if($device['os'] == "ironware" || $device['os_group'] == "ironware")
{
echo("IronWare : ");
$processors_array = snmpwalk_cache_triple_oid($device, "snAgentCpuUtilEntry", $processors_array, "FOUNDRY-SN-AGENT-MIB");
if($debug) { print_r($processors_array); }
foreach($processors_array[$device['device_id']] as $index => $entry)
{
if (($entry['snAgentCpuUtilValue'] || $entry['snAgentCpuUtil100thPercent']) && $entry['snAgentCpuUtilInterval'] == "300")
{
#$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
if($entry['snAgentCpuUtil100thPercent']) {
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.6." . $index;
$usage = $entry['snAgentCpuUtil100thPercent'];
$precision = 100;
} elseif($entry['snAgentCpuUtilValue']) {
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.4." . $index;
$usage = $entry['snAgentCpuUtilValue'];
$precision = 100;
}
list($slot, $instance, $interval) = explode(".", $index);
$descr_oid = "snAgentConfigModuleDescription." . $entry['snAgentCpuUtilSlotNum'];
$descr = snmp_get($device, $descr_oid, "-Oqv", "FOUNDRY-SN-AGENT-MIB");
$descr = str_replace("\"", "", $descr);
list($descr) = explode(" ", $descr);
$descr = "Slot " . $entry['snAgentCpuUtilSlotNum'] . " " . $descr;
$descr = $descr . " [".$instance."]";
if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "")
{
discover_processor($valid_processor, $device, $usage_oid, $index, "ironware", $descr, $precision, $usage, $entPhysicalIndex, NULL);
}
}
}
}
## End Ironware Processors
unset ($processors_array);
?>

View File

@ -1,5 +1,7 @@
<?php
global $valid_processor;
## JUNOS Processors
if($device['os'] == "junos")
{
@ -7,16 +9,20 @@ if($device['os'] == "junos")
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingCPU", $processors_array, "JUNIPER-MIB" , '+'.$config['install_dir']."/mibs/junos");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingDRAMSize", $processors_array, "JUNIPER-MIB" , '+'.$config['install_dir']."/mibs/junos");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingDescr", $processors_array, "JUNIPER-MIB" , '+'.$config['install_dir']."/mibs/junos");
if($debug) { print_r($processors_array); }
if ($debug) { print_r($processors_array); }
if(is_array($processors_array[$device['device_id']])) {
foreach($processors_array[$device['device_id']] as $index => $entry) {
if($entry['jnxOperatingDRAMSize'] && !strpos($entry['jnxOperatingDescr'], "sensor") && !strstr($entry['jnxOperatingDescr'], "fan")) {
if (is_array($processors_array[$device['device_id']]))
{
foreach ($processors_array[$device['device_id']] as $index => $entry)
{
if ($entry['jnxOperatingDRAMSize'] && !strpos($entry['jnxOperatingDescr'], "sensor") && !strstr($entry['jnxOperatingDescr'], "fan"))
{
if ($debug) { echo($index . " " . $entry['jnxOperatingDescr'] . " -> " . $entry['jnxOperatingCPU'] . " -> " . $entry['jnxOperatingDRAMSize'] . "\n"); }
$usage_oid = ".1.3.6.1.4.1.2636.3.1.13.1.8." . $index;
$descr = $entry['jnxOperatingDescr'];
$usage = $entry['jnxOperatingCPU'];
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) {
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
{
discover_processor($valid_processor, $device, $usage_oid, $index, "junos", $descr, "1", $usage, NULL, NULL);
}
} ## End if checks
@ -24,6 +30,6 @@ if($device['os'] == "junos")
} ## End if array
} ## End JUNOS Processors
unset ($processors_array);
unset ($processors_array);
?>

View File

@ -0,0 +1,32 @@
<?php
global $valid_processor;
## JUNOSe Processors
if($device['os'] == "junose")
{
echo("JUNOSe : ");
$processors_array = snmpwalk_cache_double_oid($device, "juniSystemModule", $processors_array, "Juniper-System-MIB" , "+".$config['install_dir']."/mibs/junose");
if($debug) { print_r($processors_array); }
foreach ($processors_array[$device['device_id']] as $index => $entry)
{
if ($entry['juniSystemModuleCpuUtilPct'] && $entry['juniSystemModuleCpuUtilPct'] != "-1")
{
$entPhysicalIndex = $entry['juniSystemModulePhysicalIndex'];
$usage_oid = ".1.3.6.1.4.1.4874.2.2.2.1.3.5.1.3." . $index;
$descr_oid = ".1.3.6.1.4.1.4874.2.2.2.1.3.5.1.6." . $index;
$descr = $entry['juniSystemModuleDescr'];
$usage = $entry['juniSystemModuleCpuFiveMinAvgPct'];
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
{
discover_processor($valid_processor, $device, $usage_oid, $index, "junose", $descr, "1", $usage, $entPhysicalIndex, NULL);
}
}
}
} ## End JUNOSe Processors
unset ($processors_array);
?>