diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 5a68c3fe13..41d94b5e99 100755 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -13,32 +13,32 @@ $ports = str_replace(" ", "||", $ports); $interface_ignored = 0; $interface_added = 0; -foreach(explode("\n", $ports) as $entry){ +foreach (explode("\n", $ports) as $entry){ $entry = trim($entry); list($ifIndex, $ifDescr) = explode("||", $entry, 2); - if(!strstr($entry, "irtual")) { + if (!strstr($entry, "irtual")) { $if = trim(strtolower($ifDescr)); $nullintf = 0; - foreach($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } } - if(is_array($config['bad_if_regexp'])) { - foreach($config['bad_if_regexp'] as $bi) { + foreach ($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } } + if (is_array($config['bad_if_regexp'])) { + foreach ($config['bad_if_regexp'] as $bi) { if (preg_match($bi ."i", $if)) { $nullintf = 1; } } } - if(empty($ifDescr)) { $nullintf = 1; } - if($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; } + if (empty($ifDescr)) { $nullintf = 1; } + if ($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; } $ifDescr = fixifName($ifDescr); if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; } - if(isset($config['allow_ng']) && !$config['allow_ng']) { + if (isset($config['allow_ng']) && !$config['allow_ng']) { if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = 1; } } if ($debug) echo("\n $if "); if ($nullintf == 0) { - if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') { + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') { mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','$ifDescr')"); # Add Interface echo("+"); @@ -49,7 +49,7 @@ foreach(explode("\n", $ports) as $entry){ $int_exists[] = "$ifIndex"; } else { # Ignored Interface - if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') { + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') { mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"); # Delete Interface echo("-"); ## Deleted Interface @@ -72,7 +72,7 @@ while ($test_if = mysql_fetch_array($query)) { if ($int_exists[$i] == $this_if) { $exists = 1; } $i++; } - if(!$exists) { + if (!$exists) { echo("-"); mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE interface_id = '" . $test_if['interface_id'] . "'"); } diff --git a/includes/discovery/processors-ucd-old.inc.php b/includes/discovery/processors-ucd-old.inc.php index bcf54082b1..13ca49f15a 100644 --- a/includes/discovery/processors-ucd-old.inc.php +++ b/includes/discovery/processors-ucd-old.inc.php @@ -2,19 +2,20 @@ $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"); - $user = snmp_get($device, "ssCpuUser.0", "-OvQ", "UCD-SNMP-MIB"); - $idle = snmp_get($device, "ssCpuIdle.0", "-OvQ", "UCD-SNMP-MIB"); + $user = snmp_get($device, "ssCpuUser.0" , "-OvQ", "UCD-SNMP-MIB"); + $idle = snmp_get($device, "ssCpuIdle.0" , "-OvQ", "UCD-SNMP-MIB"); $percent = $system + $user + $idle; - if(is_numeric($percent)) { + if (is_numeric($percent)) + { discover_processor($valid_processor, $device, 0, 0, "ucd-old", "CPU", "1", $system+$user, NULL, NULL); } } -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors.inc.php b/includes/discovery/processors.inc.php index 9bfdac11be..ddd32c8c95 100755 --- a/includes/discovery/processors.inc.php +++ b/includes/discovery/processors.inc.php @@ -13,13 +13,15 @@ include("processors-ucd-old.inc.php"); $sql = "SELECT * FROM `processors` WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); -if($debug) { print_r ($valid_processor); } +if ($debug) { print_r ($valid_processor); } -while ($test_processor = mysql_fetch_array($query)) { +while ($test_processor = mysql_fetch_array($query)) +{ $processor_index = $test_processor['processor_index']; $processor_type = $test_processor['processor_type']; - if($debug) { echo($processor_index . " -> " . $processor_type . "\n"); } - if(!$valid_processor[$processor_type][$processor_index]) { + if ($debug) { echo($processor_index . " -> " . $processor_type . "\n"); } + if (!$valid_processor[$processor_type][$processor_index]) + { echo("-"); mysql_query("DELETE FROM `processors` WHERE processor_id = '" . $test_processor['processor_id'] . "'"); } @@ -29,4 +31,4 @@ while ($test_processor = mysql_fetch_array($query)) { unset($valid_processor); echo("\n"); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/hrdevice.inc.php b/includes/discovery/processors/hrdevice.inc.php index 3a58fccd3e..3daa3a35c5 100755 --- a/includes/discovery/processors/hrdevice.inc.php +++ b/includes/discovery/processors/hrdevice.inc.php @@ -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 -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/ios.inc.php b/includes/discovery/processors/ios.inc.php index b3554d17a4..fca7cc159b 100755 --- a/includes/discovery/processors/ios.inc.php +++ b/includes/discovery/processors/ios.inc.php @@ -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); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/ironware.inc.php b/includes/discovery/processors/ironware.inc.php index b6763006de..d579080e86 100755 --- a/includes/discovery/processors/ironware.inc.php +++ b/includes/discovery/processors/ironware.inc.php @@ -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); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/junos.inc.php b/includes/discovery/processors/junos.inc.php index a678aa5dbb..c84170cd0e 100755 --- a/includes/discovery/processors/junos.inc.php +++ b/includes/discovery/processors/junos.inc.php @@ -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); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/junose.inc.php b/includes/discovery/processors/junose.inc.php index ed8b5f8751..0593d712c8 100755 --- a/includes/discovery/processors/junose.inc.php +++ b/includes/discovery/processors/junose.inc.php @@ -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); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/procurve.inc.php b/includes/discovery/processors/procurve.inc.php index 5fbea4c4bf..3d5ef44e78 100755 --- a/includes/discovery/processors/procurve.inc.php +++ b/includes/discovery/processors/procurve.inc.php @@ -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); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/radlan.inc.php b/includes/discovery/processors/radlan.inc.php index 1ca6ec8f90..a899cabe28 100644 --- a/includes/discovery/processors/radlan.inc.php +++ b/includes/discovery/processors/radlan.inc.php @@ -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); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/screenos.inc.php b/includes/discovery/processors/screenos.inc.php index 896f5d5d4d..e1257d5ff7 100644 --- a/includes/discovery/processors/screenos.inc.php +++ b/includes/discovery/processors/screenos.inc.php @@ -1,20 +1,18 @@ +?> \ No newline at end of file