diff --git a/includes/discovery/arp-table.inc.php b/includes/discovery/arp-table.inc.php index 7864fe338..2b2d2b94f 100644 --- a/includes/discovery/arp-table.inc.php +++ b/includes/discovery/arp-table.inc.php @@ -12,35 +12,35 @@ foreach (explode("\n", $ipNetToMedia_data) as $data) { list($oid, $mac) = explode(" ", $data); list($if, $first, $second, $third, $fourth) = explode(".", $oid); - list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac); + list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac); $interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'")); $ip = $first .".". $second .".". $third .".". $fourth; $m_a = zeropad($m_a);$m_b = zeropad($m_b);$m_c = zeropad($m_c);$m_d = zeropad($m_d);$m_e = zeropad($m_e);$m_f = zeropad($m_f); $md_a = hexdec($m_a);$md_b = hexdec($m_b);$md_c = hexdec($m_c);$md_d = hexdec($m_d);$md_e = hexdec($m_e);$md_f = hexdec($m_f); - $mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f"; + $mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f"; $mac_table[$if][$mac]['ip'] = $ip; $mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f"; - $clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f; + $clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f; $mac_table[$if][$mac]['cleanmac'] = $clean_mac; $interface_id = $interface['interface_id']; $mac_table[$interface_id][$clean_mac] = 1; - if (mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0)) + if (mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0)) { $sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"; $old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND interface_id = '".$interface['interface_id']."'")); - if ($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '') + if ($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '') { if ($debug) { echo("Changed mac address for $ip from $old_mac[0] to $clean_mac\n"); } log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['interface_id']); } mysql_query($sql); echo("."); - } - else + } + else { echo("+"); #echo("Add MAC $mac\n"); @@ -51,16 +51,16 @@ foreach (explode("\n", $ipNetToMedia_data) as $data) $sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'"; $query = mysql_query($sql); -while ($entry = mysql_fetch_array($query)) +while ($entry = mysql_fetch_array($query)) { $entry_mac = $entry['mac_address']; $entry_if = $entry['interface_id']; - if (!$mac_table[$entry_if][$entry_mac]) + if (!$mac_table[$entry_if][$entry_mac]) { mysql_query("DELETE FROM ipv4_mac WHERE interface_id = '".$entry_if."' AND mac_address = '".$entry_mac."'"); if ($debug) { echo("Removing MAC $entry_mac from interface ".$interface['ifName']); } echo("-"); - } + } } echo("\n"); diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index af12d217b..6501ef169 100755 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -206,4 +206,4 @@ if ($config['enable_bgp']) echo("\n"); } -?> \ No newline at end of file +?> \ No newline at end of file diff --git a/includes/discovery/cisco-mac-accounting.inc.php b/includes/discovery/cisco-mac-accounting.inc.php index 3ea601728..41ad63ea5 100755 --- a/includes/discovery/cisco-mac-accounting.inc.php +++ b/includes/discovery/cisco-mac-accounting.inc.php @@ -38,7 +38,7 @@ if ($device['os_group'] == "ios") #echo(" Not Exists!"); mysql_query("INSERT INTO `mac_accounting` (interface_id, mac) VALUES ('".$interface['interface_id']."','$clean_mac')"); echo("+"); - } + } #echo("\n"); } } diff --git a/includes/discovery/cisco-vlans.inc.php b/includes/discovery/cisco-vlans.inc.php index 0fa86653f..2eeec5de4 100755 --- a/includes/discovery/cisco-vlans.inc.php +++ b/includes/discovery/cisco-vlans.inc.php @@ -49,7 +49,7 @@ if ($device['os_group'] == "ios") { if ($test_vlan == $dev_vlan['vlan_vlan']) { $vlan_exists = 1; } } - + if (!$vlan_exists) { mysql_query("DELETE FROM `vlans` WHERE `vlan_id` = '" . $dev_vlan['vlan_id'] . "'"); diff --git a/includes/discovery/current/ipoman.inc.php b/includes/discovery/current/ipoman.inc.php index f44f1f590..02d8e6ae3 100644 --- a/includes/discovery/current/ipoman.inc.php +++ b/includes/discovery/current/ipoman.inc.php @@ -40,6 +40,7 @@ if ($device['os'] == "ipoman") $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') : "Inlet $index"); $current = $entry['inletStatusCurrent'] / $divisor; $high_limit = $entry['inletConfigCurrentHigh'] / 10; + discover_sensor($valid_sensor, 'current', $device, $cur_oid, '1.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, $high_limit, $current); # FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? } @@ -54,6 +55,7 @@ if ($device['os'] == "ipoman") $descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') : "Output $index"); $current = $entry['outletStatusCurrent'] / $divisor; $high_limit = $entry['outletConfigCurrentHigh'] / 10; + discover_sensor($valid_sensor, 'current', $device, $cur_oid, '2.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, $high_limit, $current); } } diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index a6003c558..ce2297573 100755 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -11,7 +11,7 @@ $entity_array = array(); echo(" entPhysicalEntry"); - $entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, "ENTITY-MIB"); + $entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, "ENTITY-MIB"); echo(" entAliasMappingIdentifier"); $entity_array = snmpwalk_cache_twopart_oid($device, "entAliasMappingIdentifier", $entity_array, "ENTITY-MIB:IF-MIB"); @@ -26,7 +26,7 @@ $entPhysicalMfgName = $entry['entPhysicalMfgName']; $entPhysicalVendorType = $entry['entPhysicalVendorType']; $entPhysicalParentRelPos = $entry['entPhysicalParentRelPos']; - $entPhysicalHardwareRev = $entry['entPhysicalHardwareRev']; + $entPhysicalHardwareRev = $entry['entPhysicalHardwareRev']; $entPhysicalFirmwareRev = $entry['entPhysicalFirmwareRev']; $entPhysicalSoftwareRev = $entry['entPhysicalSoftwareRev']; $entPhysicalIsFRU = $entry['entPhysicalIsFRU']; @@ -46,7 +46,7 @@ if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName) { $entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType]; - } + } if ($entPhysicalDescr || $entPhysicalName) { @@ -60,12 +60,12 @@ $sql .= ", entPhysicalHardwareRev = '$entPhysicalHardwareRev', entPhysicalFirmwareRev = '$entPhysicalFirmwareRev', entPhysicalSoftwareRev = '$entPhysicalSoftwareRev'"; $sql .= ", entPhysicalIsFRU = '$entPhysicalIsFRU', entPhysicalAlias = '$entPhysicalAlias', entPhysicalAssetID = '$entPhysicalAssetID'"; $sql .= " WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'"; - + mysql_query($sql); echo("."); } else { $sql = "INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `entPhysicalHardwareRev`,`entPhysicalFirmwareRev`,`entPhysicalSoftwareRev`,`entPhysicalIsFRU`,`entPhysicalAlias`,`entPhysicalAssetID`, `ifIndex` ) "; - $sql .= "VALUES ( '" . $device['device_id'] . "', '$entPhysicalIndex', '$entPhysicalDescr', '$entPhysicalClass', '$entPhysicalName', '$entPhysicalModelName', '$entPhysicalSerialNum', '$entPhysicalContainedIn', '$entPhysicalMfgName','$entPhysicalParentRelPos' , '$entPhysicalVendorType', '$entPhysicalHardwareRev', '$entPhysicalFirmwareRev', '$entPhysicalSoftwareRev', '$entPhysicalIsFRU', '$entPhysicalAlias', '$entPhysicalAssetID', '$ifIndex')"; + $sql .= "VALUES ( '" . $device['device_id'] . "', '$entPhysicalIndex', '$entPhysicalDescr', '$entPhysicalClass', '$entPhysicalName', '$entPhysicalModelName', '$entPhysicalSerialNum', '$entPhysicalContainedIn', '$entPhysicalMfgName','$entPhysicalParentRelPos' , '$entPhysicalVendorType', '$entPhysicalHardwareRev', '$entPhysicalFirmwareRev', '$entPhysicalSoftwareRev', '$entPhysicalIsFRU', '$entPhysicalAlias', '$entPhysicalAssetID', '$ifIndex')"; mysql_query($sql); echo("+"); } diff --git a/includes/discovery/frequencies/rfc1628.inc.php b/includes/discovery/frequencies/rfc1628.inc.php index db45f2683..7d3d03839 100644 --- a/includes/discovery/frequencies/rfc1628.inc.php +++ b/includes/discovery/frequencies/rfc1628.inc.php @@ -6,7 +6,7 @@ global $valid_sensor; if ($device['os'] == "netmanplus" || $device['os'] == "deltaups") { echo("RFC1628 "); - + $oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.3.2.0", "-OsqnU")); if ($debug) { echo($oids."\n"); } list($unused,$numPhase) = explode(' ',$oids); diff --git a/includes/discovery/frequencies/xups.inc.php b/includes/discovery/frequencies/xups.inc.php index aaae3cc13..d2f4008f8 100644 --- a/includes/discovery/frequencies/xups.inc.php +++ b/includes/discovery/frequencies/xups.inc.php @@ -6,9 +6,9 @@ global $valid_sensor; if ($device['os'] == "powerware") { echo("XUPS-MIB "); - + # I'm not sure if there is provision for frequency of multiple phases in this MIB -TL - + # XUPS-MIB::xupsInputFrequency.0 = INTEGER: 500 $freq_oid = ".1.3.6.1.4.1.534.1.3.1.0"; $descr = "Input"; diff --git a/includes/discovery/humidity/akcp.inc.php b/includes/discovery/humidity/akcp.inc.php index 2e3bc4f46..3a33ce029 100644 --- a/includes/discovery/humidity/akcp.inc.php +++ b/includes/discovery/humidity/akcp.inc.php @@ -24,14 +24,14 @@ if ($device['os'] == 'akcp' || $device['os'] == 'minkelsrms') $limit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.8.$index"; $warnlowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.9.$index"; $lowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.10.$index"; - + $descr = trim(snmp_get($device, $descr_oid, "-Oqv", ""),'"'); $humidity = snmp_get($device, $oid, "-Oqv", ""); $warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", ""); $limit = snmp_get($device, $limit_oid, "-Oqv", ""); $lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", ""); $warnlowlimit = snmp_get($device, $warnlowlimit_oid, "-Oqv", ""); - + discover_sensor($valid_sensor, 'humidity', $device, $oid, $index, 'akcp', $descr, '1', '1', $lowlimit, $warnlowlimit, $limit, $warnlimit, $humidity); } } diff --git a/includes/discovery/ipmi.inc.php b/includes/discovery/ipmi.inc.php index 653d13981..df42b316b 100644 --- a/includes/discovery/ipmi.inc.php +++ b/includes/discovery/ipmi.inc.php @@ -9,14 +9,14 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) $ipmi['user'] = get_dev_attrib($device,'ipmi_username'); $ipmi['password'] = get_dev_attrib($device,'ipmi_password'); - + $results = shell_exec($config['ipmitool'] . " -H " . $ipmi['host'] . " -U " . $ipmi['user'] . " -P " . $ipmi['password'] . " sensor|sort"); - + $index = 0; foreach (explode("\n",$results) as $sensor) { - # BB +1.1V IOH | 1.089 | Volts | ok | na | 1.027 | 1.054 | 1.146 | 1.177 | na + # BB +1.1V IOH | 1.089 | Volts | ok | na | 1.027 | 1.054 | 1.146 | 1.177 | na list($desc,$current,$unit,$state,$low_nonrecoverable,$low_limit,$low_warn,$high_warn,$high_limit,$high_nonrecoverable) = explode('|',$sensor); $index++; if (trim($current) != "na" && $ipmi_unit[trim($unit)]) @@ -27,7 +27,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) $current, 'ipmi'); } } - + echo("\n"); } diff --git a/includes/discovery/ipv4-addresses.inc.php b/includes/discovery/ipv4-addresses.inc.php index cdc5e6838..aa04a8a59 100755 --- a/includes/discovery/ipv4-addresses.inc.php +++ b/includes/discovery/ipv4-addresses.inc.php @@ -12,7 +12,7 @@ foreach (explode("\n", $oids) as $data) $addr = Net_IPv4::parseAddress("$oid/$mask"); $network = $addr->network . "/" . $addr->bitmask; $cidr = $addr->bitmask; - + if (mysql_result(mysql_query("SELECT count(*) FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $oid != "0.0.0.0") { $i_query = "SELECT interface_id FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"; diff --git a/includes/discovery/junose-atm-vp.inc.php b/includes/discovery/junose-atm-vp.inc.php index fc5946206..cb363428e 100755 --- a/includes/discovery/junose-atm-vp.inc.php +++ b/includes/discovery/junose-atm-vp.inc.php @@ -45,7 +45,7 @@ if ($device['os'] == "junose" && $config['enable_ports_junoseatmvp']) echo("-"); mysql_query("DELETE FROM `juniAtmvp` WHERE `juniAtmVp` = '" . $test['juniAtmvp'] . "'"); } - + unset($interface_id); unset($vp_id); } diff --git a/includes/discovery/mempools.inc.php b/includes/discovery/mempools.inc.php index 1d6457967..53d5d4b3d 100755 --- a/includes/discovery/mempools.inc.php +++ b/includes/discovery/mempools.inc.php @@ -22,7 +22,7 @@ while ($test_mempool = mysql_fetch_array($query)) echo("-"); mysql_query("DELETE FROM `mempools` WHERE mempool_id = '" . $test_mempool['mempool_id'] . "'"); } - + unset($mempool_oid); unset($mempool_type); } diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 1d39337ef..d3bdb67b8 100755 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -30,7 +30,7 @@ foreach (explode("\n", $ports) as $entry){ } if (empty($ifDescr)) { $nullintf = 1; } - if ($device['os'] == "catos" && strstr($if, "vlan") ) { $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']) { @@ -43,11 +43,11 @@ foreach (explode("\n", $ports) as $entry){ # Add Interface echo("+"); } else { - mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"); + mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"); echo("."); } $int_exists[] = "$ifIndex"; - } else { + } else { # Ignored Interface 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'"); @@ -57,7 +57,7 @@ foreach (explode("\n", $ports) as $entry){ echo("X"); ## Ignored Interface } } - } + } } diff --git a/includes/discovery/storage.inc.php b/includes/discovery/storage.inc.php index 3e8746933..d99501046 100755 --- a/includes/discovery/storage.inc.php +++ b/includes/discovery/storage.inc.php @@ -22,7 +22,7 @@ while ($test_storage = mysql_fetch_array($query)) echo("-"); mysql_query("DELETE FROM `storage` WHERE storage_id = '" . $test_storage['storage_id'] . "'"); } - + unset($storage_index); unset($storage_mib); } diff --git a/includes/discovery/temperatures/adva.inc.php b/includes/discovery/temperatures/adva.inc.php index 6fd0fd4d1..62e4a115d 100755 --- a/includes/discovery/temperatures/adva.inc.php +++ b/includes/discovery/temperatures/adva.inc.php @@ -23,7 +23,7 @@ Disabled needing rewrite echo("Adva Chassis "); if ($temperature_chassis != "0") { - if (mysql_result(mysql_query("SELECT count(temperature_id) FROM `temperature` WHERE temperature_oid = '$oid_chassis' AND temperature_host = '$id'"),0) == '0') + if (mysql_result(mysql_query("SELECT count(temperature_id) FROM `temperature` WHERE temperature_oid = '$oid_chassis' AND temperature_host = '$id'"),0) == '0') { $query = "INSERT INTO temperature (`temperature_host`, `temperature_oid`, `temperature_descr`, `temperature_precision`, `temperature_limit`, `temperature_current`) values ('$id', '$oid_chassis', '$descr_chassis',1," . ($config['defaults']['temperature_limit'] ? $config['defaults']['temperature_limit'] : '60') . ", '$temperature_chassis')"; mysql_query($query); diff --git a/includes/discovery/temperatures/dell.inc.php b/includes/discovery/temperatures/dell.inc.php index 6e43949e9..ce74e69fe 100644 --- a/includes/discovery/temperatures/dell.inc.php +++ b/includes/discovery/temperatures/dell.inc.php @@ -1,5 +1,5 @@ $entry) diff --git a/includes/discovery/toner.inc.php b/includes/discovery/toner.inc.php index 38896efc6..fe76931de 100644 --- a/includes/discovery/toner.inc.php +++ b/includes/discovery/toner.inc.php @@ -3,18 +3,18 @@ if ($config['enable_printers']) { $valid_toner = array(); - + echo("Toner : "); - if ($device['os_group'] == 'printer') + if ($device['os_group'] == 'printer') { $oids = trim(snmp_walk($device, "SNMPv2-SMI::mib-2.43.12.1.1.2.1 ", "-OsqnU")); if ($debug) { echo($oids."\n"); } if ($oids) echo("Jetdirect "); - foreach (explode("\n", $oids) as $data) + foreach (explode("\n", $oids) as $data) { $data = trim($data); - if ($data) + if ($data) { list($oid,$kind) = explode(" ", $data); $split_oid = explode('.',$oid); @@ -38,10 +38,10 @@ if ($config['enable_printers']) } } } - - ## Delete removed toners + + ## Delete removed toners if ($debug) { echo("\n Checking ... \n"); print_r($valid_toner); } - + $sql = "SELECT * FROM toner WHERE device_id = '".$device['device_id']."'"; if ($query = mysql_query($sql)) { @@ -55,8 +55,8 @@ if ($config['enable_printers']) } } } - + unset($valid_toner); echo("\n"); - + } # if ($config['enable_printers']) ?> \ No newline at end of file