more cleanups and reindents, still a lot to come

git-svn-id: http://www.observium.org/svn/observer/trunk@1836 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-15 09:45:00 +00:00
parent 890823b00f
commit 3a4e92e246
11 changed files with 92 additions and 92 deletions
+12 -11
View File
@@ -3,14 +3,14 @@
global $valid_processor;
echo("hrDevice ");
$hrDevice_oids = array('hrDevice','hrProcessorLoad');
$hrDevice_oids = array('hrDevice','hrProcessorLoad');
unset($hrDevice_array);
foreach ($hrDevice_oids as $oid) { $hrDevice_array = snmpwalk_cache_oid($device, $oid, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
if(is_array($hrDevice_array))
if (is_array($hrDevice_array))
{
foreach($hrDevice_array as $index => $entry)
foreach ($hrDevice_array as $index => $entry)
{
if ($entry['hrDeviceType'] == "hrDeviceProcessor")
if ($entry['hrDeviceType'] == "hrDeviceProcessor")
{
$hrDeviceIndex = $entry['hrDeviceIndex'];
@@ -20,10 +20,10 @@ if(is_array($hrDevice_array))
#### What is this for? I have forgotten. What has : in its hrDeviceDescr?
#### Set description to that found in hrDeviceDescr, first part only if containing a :
$descr_array = explode(":",$entry['hrDeviceDescr']);
if($descr_array['1']) { $descr = $descr_array['1']; } else { $descr = $descr_array['0']; }
if ($descr_array['1']) { $descr = $descr_array['1']; } else { $descr = $descr_array['0']; }
### Workaround to set fake description for Mikrotik who don't populate hrDeviceDescr
if($device['os'] == "routeros" && !isset($entry['hrDeviceDescr'])) { $descr = "Processor";}
if ($device['os'] == "routeros" && !isset($entry['hrDeviceDescr'])) { $descr = "Processor";}
$descr = str_replace("CPU ", "", $descr);
$descr = str_replace("(TM)", "", $descr);
@@ -32,12 +32,13 @@ if(is_array($hrDevice_array))
$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)) {
if ($debug) { echo("$old_rrd $new_rrd"); }
if (is_file($old_rrd))
{
rename($old_rrd,$new_rrd);
echo("Moved RRD ");
}
if(isset($descr) && $descr != "An electronic chip that makes the computer work.")
if (isset($descr) && $descr != "An electronic chip that makes the computer work.")
{
discover_processor($valid_processor, $device, $usage_oid, $index, "hr", $descr, "1", $usage, NULL, $hrDeviceIndex);
}
@@ -46,8 +47,8 @@ if(is_array($hrDevice_array))
unset($entry);
}
unset($hrDevice_oids, $hrDevice_array, $oid);
}
}
## End hrDevice Processors
?>
?>
+15 -14
View File
@@ -6,58 +6,59 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("CISCO-PROCESS-MIB : ");
$processors_array = snmpwalk_cache_oid($device, "cpmCPU", NULL, "CISCO-PROCESS-MIB");
if($debug) { print_r($processors_array); }
if ($debug) { print_r($processors_array); }
foreach ($processors_array as $index => $entry)
foreach ($processors_array as $index => $entry)
{
if (is_numeric($entry['cpmCPUTotal5minRev']) || is_numeric($entry['cpmCPUTotal5min']))
if (is_numeric($entry['cpmCPUTotal5minRev']) || is_numeric($entry['cpmCPUTotal5min']))
{
$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
if(isset($entry['cpmCPUTotal5minRev'])) {
if (isset($entry['cpmCPUTotal5minRev']))
{
$usage_oid = ".1.3.6.1.4.1.9.9.109.1.1.1.1.8." . $index;
$usage = $entry['cpmCPUTotal5minRev'];
} elseif(isset($entry['cpmCPUTotal5min'])) {
} elseif (isset($entry['cpmCPUTotal5min'])) {
$usage_oid = ".1.3.6.1.4.1.9.9.109.1.1.1.1.5." . $index;
$usage = $entry['cpmCPUTotal5min'];
}
if($entPhysicalIndex) {
if ($entPhysicalIndex) {
$descr_oid = "entPhysicalName." . $entPhysicalIndex;
$descr = snmp_get($device, $descr_oid, "-Oqv", "ENTITY-MIB");
}
if(!$descr) { $descr = "Processor $index"; }
if (!$descr) { $descr = "Processor $index"; }
$old_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("cpmCPU-" . $index . ".rrd");
$new_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-cpm-" . $index . ".rrd");
if (is_file($old_rrd))
if (is_file($old_rrd))
{
shell_exec("mv -f $old_rrd $new_rrd");
if($debug) { echo("$old_rrd $new_rrd"); }
if ($debug) { echo("$old_rrd $new_rrd"); }
echo("Moved RRD ");
}
#echo("|".$descr."|");
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
{
discover_processor($valid_processor, $device, $usage_oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL);
}
}
}
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);
}
}
}
}
## End Cisco Processors
unset ($processors_array);
?>
?>
@@ -2,22 +2,23 @@
global $valid_processor;
if($device['os'] == "ironware" || $device['os_group'] == "ironware")
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 as $index => $entry)
if ($debug) { print_r($processors_array); }
foreach ($processors_array as $index => $entry)
{
if (($entry['snAgentCpuUtilValue'] || $entry['snAgentCpuUtil100thPercent']) && $entry['snAgentCpuUtilInterval'] == "300")
if (($entry['snAgentCpuUtilValue'] || $entry['snAgentCpuUtil100thPercent']) && $entry['snAgentCpuUtilInterval'] == "300")
{
#$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
if($entry['snAgentCpuUtil100thPercent']) {
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']) {
} 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;
@@ -39,9 +40,8 @@ if($device['os'] == "ironware" || $device['os_group'] == "ironware")
}
}
}
}
## End Ironware Processors
}
unset ($processors_array);
?>
?>
+5 -5
View File
@@ -3,7 +3,7 @@
global $valid_processor;
## JUNOS Processors
if($device['os'] == "junos")
if ($device['os'] == "junos")
{
echo("JUNOS : ");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingCPU", $processors_array, "JUNIPER-MIB" , '+'.$config['install_dir']."/mibs/junos");
@@ -13,15 +13,15 @@ if($device['os'] == "junos")
if (is_array($processors_array))
{
foreach ($processors_array as $index => $entry)
foreach ($processors_array as $index => $entry)
{
if ($entry['jnxOperatingDescr'] == "Routing Engine" || $entry['jnxOperatingDRAMSize'] && !strpos($entry['jnxOperatingDescr'], "sensor") && !strstr($entry['jnxOperatingDescr'], "fan"))
if ($entry['jnxOperatingDescr'] == "Routing Engine" || $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);
}
@@ -32,4 +32,4 @@ if($device['os'] == "junos")
unset ($processors_array);
?>
?>
+6 -6
View File
@@ -3,13 +3,13 @@
global $valid_processor;
## JUNOSe Processors
if($device['os'] == "junose")
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); }
if ($debug) { print_r($processors_array); }
foreach ($processors_array as $index => $entry)
foreach ($processors_array as $index => $entry)
{
if ($entry['juniSystemModuleCpuUtilPct'] && $entry['juniSystemModuleCpuUtilPct'] != "-1")
{
@@ -19,14 +19,14 @@ if($device['os'] == "junose")
$descr = $entry['juniSystemModuleDescr'];
$usage = $entry['juniSystemModuleCpuFiveMinAvgPct'];
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
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);
?>
?>
@@ -8,20 +8,19 @@ global $valid_processor;
## STATISTICS-MIB::hpSwitchCpuStat.0 = INTEGER: 10
if($device['os'] == "procurve")
if ($device['os'] == "procurve")
{
echo("Procurve : ");
$descr = "Processor";
$usage = snmp_get($device, ".1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "-OQUvs", "STATISTICS-MIB", $config['mib_dir'].":".$config['mib_dir']."/hp");
if(is_numeric($usage))
{
discover_processor($valid_processor, $device, "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "0", "procurve-fixed", $descr, "1", $usage, NULL, NULL);
}
$descr = "Processor";
$usage = snmp_get($device, ".1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "-OQUvs", "STATISTICS-MIB", $config['mib_dir'].":".$config['mib_dir']."/hp");
if (is_numeric($usage))
{
discover_processor($valid_processor, $device, "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "0", "procurve-fixed", $descr, "1", $usage, NULL, NULL);
}
}
unset ($processors_array);
?>
?>
+8 -10
View File
@@ -6,21 +6,19 @@ global $valid_processor;
## Hardcoded discovery of cpu usage on RADLAN devices.
##
if($device['os'] == "radlan")
if ($device['os'] == "radlan")
{
echo("RADLAN : ");
$descr = "Processor";
$usage = snmp_get($device, ".1.3.6.1.4.1.89.1.9.0", "-OQUvs", "RADLAN-rndMng", $config['mib_dir'].":".$config['mib_dir']."/radlan");
if(is_numeric($usage))
{
discover_processor($valid_processor, $device, ".1.3.6.1.4.1.89.1.9.0", "0", "radlan", $descr, "1", $usage, NULL, NULL);
}
$descr = "Processor";
$usage = snmp_get($device, ".1.3.6.1.4.1.89.1.9.0", "-OQUvs", "RADLAN-rndMng", $config['mib_dir'].":".$config['mib_dir']."/radlan");
if (is_numeric($usage))
{
discover_processor($valid_processor, $device, ".1.3.6.1.4.1.89.1.9.0", "0", "radlan", $descr, "1", $usage, NULL, NULL);
}
}
unset ($processors_array);
?>
?>
@@ -1,20 +1,18 @@
<?php
if($device['os'] == "screenos" && mysql_result(mysql_query("SELECT COUNT(*) FROM processors WHERE device_id = '".$device['device_id']."' AND processor_type != 'screenos'"),0) == "0")
if ($device['os'] == "screenos" && mysql_result(mysql_query("SELECT COUNT(*) FROM processors WHERE device_id = '".$device['device_id']."' AND processor_type != 'screenos'"),0) == "0")
{
# .1.3.6.1.4.1.3224.16.1.3.0 Cpu Last 5 Minutes
# .1.3.6.1.4.1.3224.16.1.3.0 Cpu Last 5 Minutes
# discover_processor(&$valid, $device, $oid, $index, $type, $descr, $precision = "1", $current = NULL, $entPhysicalIndex = NULL, $hrDeviceIndex = NULL)
echo("ScreenOS ");
$percent = snmp_get($device, ".1.3.6.1.4.1.3224.16.1.3.0", "-OvQ");
if(is_numeric($percent)) {
if (is_numeric($percent))
{
discover_processor($valid_processor, $device, ".1.3.6.1.4.1.3224.16.1.3.0", "1", "screenos", "Processor", "1", $percent, NULL, NULL);
}
}
?>
?>