diff --git a/includes/discovery/cisco-mac-accounting.inc.php b/includes/discovery/cisco-mac-accounting.inc.php index 2928bced6..3ea601728 100755 --- a/includes/discovery/cisco-mac-accounting.inc.php +++ b/includes/discovery/cisco-mac-accounting.inc.php @@ -7,7 +7,7 @@ if ($device['os_group'] == "ios") $datas = shell_exec($config['snmpbulkwalk'] . " -M ".$config['mibdir']." -m CISCO-IP-STAT-MIB -Oqn -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." cipMacSwitchedBytes"); #echo("$datas\n"); #echo("done\n"); - foreach(explode("\n", $datas) as $data) { + foreach (explode("\n", $datas) as $data) { list($oid) = explode(" ", $data); $oid = str_replace(".1.3.6.1.4.1.9.9.84.1.2.1.1.4.", "", $oid); list($if, $direction, $a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode(".", $oid); @@ -25,13 +25,13 @@ if ($device['os_group'] == "ios") $mac_cisco = $mac_table[$if][$mac]['ciscomac']; $clean_mac = $mac_table[$if][$mac]['cleanmac']; $ip = $mac_table[$if][$mac]['ip']; - if($ip && $interface) { + if ($ip && $interface) { $new_mac = str_replace(":", "", $mac); #echo($interface['ifDescr'] . " ($if) -> $mac ($oid) -> $ip"); - if(mysql_result(mysql_query("SELECT COUNT(*) from mac_accounting WHERE interface_id = '".$interface['interface_id']."' AND mac = '$clean_mac'"),0)) { + if (mysql_result(mysql_query("SELECT COUNT(*) from mac_accounting WHERE interface_id = '".$interface['interface_id']."' AND mac = '$clean_mac'"),0)) { #$sql = "UPDATE `mac_accounting` SET `mac` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND `mac` = '$clean_mac'"; #mysql_query($sql); - #if(mysql_affected_rows()) { echo(" UPDATED!"); } + #if (mysql_affected_rows()) { echo(" UPDATED!"); } #echo($sql); echo("."); } else { diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index 9d0166255..a6003c558 100755 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -4,7 +4,7 @@ unset($valid); - if($config['enable_inventory']) { + if ($config['enable_inventory']) { echo("\nCaching OIDs:"); @@ -15,7 +15,7 @@ echo(" entAliasMappingIdentifier"); $entity_array = snmpwalk_cache_twopart_oid($device, "entAliasMappingIdentifier", $entity_array, "ENTITY-MIB:IF-MIB"); - foreach($entity_array as $entPhysicalIndex => $entry) { + foreach ($entity_array as $entPhysicalIndex => $entry) { $entPhysicalDescr = $entry['entPhysicalDescr']; $entPhysicalContainedIn = $entry['entPhysicalContainedIn']; @@ -33,14 +33,14 @@ $entPhysicalAlias = $entry['entPhysicalAlias']; $entPhysicalAssetID = $entry['entPhysicalAssetID']; - if(isset($entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier'])) { $ifIndex = $entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier']; } + if (isset($entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier'])) { $ifIndex = $entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier']; } # $ent_data = $config['snmpget'] . " -M ".$config['mibdir']." -m ENTITY-MIB:IF-MIB -Ovqs -"; # $ent_data .= $device['snmpver'] . " -M ".$config['mibdir']." -c " . $device['community'] . " " . $device['hostname'] .":".$device['port']; # $ent_data .= " entAliasMappingIdentifier." . $entPhysicalIndex. ".0"; # $ifIndex = shell_exec($ent_data); - if(!strpos($ifIndex, "fIndex") || $ifIndex == "") { unset($ifIndex); } + if (!strpos($ifIndex, "fIndex") || $ifIndex == "") { unset($ifIndex); } list(,$ifIndex) = explode(".", $ifIndex); if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName) @@ -52,7 +52,7 @@ { $entPhysical_id = @mysql_result(mysql_query("SELECT entPhysical_id FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'"),0); - if($entPhysical_id) { + if ($entPhysical_id) { $sql = "UPDATE `entPhysical` SET `ifIndex` = '$ifIndex'"; $sql .= ", entPhysicalIndex = '$entPhysicalIndex', entPhysicalDescr = '$entPhysicalDescr', entPhysicalClass = '$entPhysicalClass', entPhysicalName = '$entPhysicalName'"; $sql .= ", entPhysicalModelName = '$entPhysicalModelName', entPhysicalSerialNum = '$entPhysicalSerialNum', entPhysicalContainedIn = '$entPhysicalContainedIn'"; @@ -80,7 +80,7 @@ $query = mysql_query($sql); while ($test = mysql_fetch_array($query)) { $id = $test['entPhysicalIndex']; - if(!$valid[$id]) { + if (!$valid[$id]) { echo("-"); mysql_query("DELETE FROM `entPhysical` WHERE entPhysical_id = '".$test['entPhysical_id']."'"); } diff --git a/includes/discovery/hr-device.inc.php b/includes/discovery/hr-device.inc.php index f0b1d6b0b..6b139898a 100755 --- a/includes/discovery/hr-device.inc.php +++ b/includes/discovery/hr-device.inc.php @@ -3,55 +3,59 @@ echo("hrDevice : "); $hrDevice_oids = array('hrDeviceEntry','hrProcessorEntry'); -if($debug) {print_r($hrDevices);} +if ($debug) {print_r($hrDevices);} $hrDevices = array(); foreach ($hrDevice_oids as $oid) { $hrDevices = snmpwalk_cache_oid($device, $oid, $hrDevices, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); } -if($debug) {print_r($hrDevices);} +if ($debug) {print_r($hrDevices);} -if(is_array($hrDevices)) +if (is_array($hrDevices)) { $hrDevices = $hrDevices; - foreach($hrDevices as $hrDevice) + foreach ($hrDevices as $hrDevice) { - if(is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) + if (is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) { - if(mysql_result(mysql_query("SELECT COUNT(*) FROM `hrDevice` WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"),0)) - { - $update_query = "UPDATE `hrDevice` SET"; - $update_query .= " `hrDeviceType` = '".mres($hrDevice[hrDeviceType])."'"; - $update_query .= ", `hrDeviceDescr` = '".mres($hrDevice[hrDeviceDescr])."'"; - $update_query .= ", `hrDeviceStatus` = '".mres($hrDevice[hrDeviceStatus])."'"; - $update_query .= ", `hrDeviceErrors` = '".mres($hrDevice[hrDeviceErrors])."'"; - if($hrDevice['hrDeviceType'] == "hrDeviceProcessor") - { - $update_query .= ", `hrProcessorLoad` = '".mres($hrDevice[hrProcessorLoad])."'"; - } - $update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"; - @mysql_query($update_query); echo("."); - } else { - $insert_query = "INSERT INTO `hrDevice` (`hrDeviceIndex`,`device_id`,`hrDeviceType`,`hrDeviceDescr`,`hrDeviceStatus`,`hrDeviceErrors`) "; - $insert_query .= " VALUES ('".mres($hrDevice[hrDeviceIndex])."','".mres($device[device_id])."','".mres($hrDevice[hrDeviceType])."','".mres($hrDevice[hrDeviceDescr])."','".mres($hrDevice[hrDeviceStatus])."','".mres($hrDevice[hrDeviceErrors])."')"; - @mysql_query($insert_query); echo("+"); - if($debug) { print_r($hrDevice); echo("$insert_query" . mysql_affected_rows() . " row inserted"); } - } - $valid_hrDevice[$hrDevice[hrDeviceIndex]] = 1; - } + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `hrDevice` WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"),0)) + { + $update_query = "UPDATE `hrDevice` SET"; + $update_query .= " `hrDeviceType` = '".mres($hrDevice[hrDeviceType])."'"; + $update_query .= ", `hrDeviceDescr` = '".mres($hrDevice[hrDeviceDescr])."'"; + $update_query .= ", `hrDeviceStatus` = '".mres($hrDevice[hrDeviceStatus])."'"; + $update_query .= ", `hrDeviceErrors` = '".mres($hrDevice[hrDeviceErrors])."'"; + if ($hrDevice['hrDeviceType'] == "hrDeviceProcessor") + { + $update_query .= ", `hrProcessorLoad` = '".mres($hrDevice[hrProcessorLoad])."'"; + } + $update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"; + @mysql_query($update_query); echo("."); + } + else + { + $insert_query = "INSERT INTO `hrDevice` (`hrDeviceIndex`,`device_id`,`hrDeviceType`,`hrDeviceDescr`,`hrDeviceStatus`,`hrDeviceErrors`) "; + $insert_query .= " VALUES ('".mres($hrDevice[hrDeviceIndex])."','".mres($device[device_id])."','".mres($hrDevice[hrDeviceType])."','".mres($hrDevice[hrDeviceDescr])."','".mres($hrDevice[hrDeviceStatus])."','".mres($hrDevice[hrDeviceErrors])."')"; + @mysql_query($insert_query); echo("+"); + if ($debug) { print_r($hrDevice); echo("$insert_query" . mysql_affected_rows() . " row inserted"); } + } + $valid_hrDevice[$hrDevice[hrDeviceIndex]] = 1; + } } } $sql = "SELECT * FROM `hrDevice` WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); -while ($test_hrDevice = mysql_fetch_array($query)) { - if(!$valid_hrDevice[$test_hrDevice[hrDeviceIndex]]) { +while ($test_hrDevice = mysql_fetch_array($query)) +{ + if (!$valid_hrDevice[$test_hrDevice[hrDeviceIndex]]) + { echo("-"); mysql_query("DELETE FROM `hrDevice` WHERE hrDevice_id = '" . $test_hrDevice['hrDevice_id'] . "'"); - if($debug) { print_r($test_hrDevice); echo(mysql_affected_rows() . " row deleted"); } + if ($debug) { print_r($test_hrDevice); echo(mysql_affected_rows() . " row deleted"); } } } unset($valid_hrDevice); echo("\n"); -?> +?> \ No newline at end of file diff --git a/includes/discovery/mempools.inc.php b/includes/discovery/mempools.inc.php index cb30e0100..1d6457967 100755 --- a/includes/discovery/mempools.inc.php +++ b/includes/discovery/mempools.inc.php @@ -4,32 +4,29 @@ echo("Memory : "); include_dir("includes/discovery/mempools"); -#include("mempools/hrstorage.inc.php"); -#include("mempools/cemp.inc.php"); -#include("mempools/cmp.inc.php"); -#include("mempools/junos.inc.php"); -#include("mempools/ironware-dyn.inc.php"); -#include("mempools/screenos.inc.php"); - ### Remove memory pools which weren't redetected here $sql = "SELECT * FROM `mempools` WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); -if($debug) { print_r ($valid_mempool); } +if ($debug) { print_r ($valid_mempool); } -while ($test_mempool = mysql_fetch_array($query)) { +while ($test_mempool = mysql_fetch_array($query)) +{ $mempool_index = $test_mempool['mempool_index']; $mempool_type = $test_mempool['mempool_type']; - if($debug) { echo($mempool_index . " -> " . $mempool_type . "\n"); } - if(!$valid_mempool[$mempool_type][$mempool_index]) { + if ($debug) { echo($mempool_index . " -> " . $mempool_type . "\n"); } + + if (!$valid_mempool[$mempool_type][$mempool_index]) + { echo("-"); mysql_query("DELETE FROM `mempools` WHERE mempool_id = '" . $test_mempool['mempool_id'] . "'"); } + unset($mempool_oid); unset($mempool_type); } unset($valid_mempool); echo("\n"); -?> +?> \ No newline at end of file diff --git a/includes/discovery/processors/ios.inc.php b/includes/discovery/processors/ios.inc.php index fca7cc159..fa7c7e47e 100755 --- a/includes/discovery/processors/ios.inc.php +++ b/includes/discovery/processors/ios.inc.php @@ -34,7 +34,7 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios") if (is_file($old_rrd)) { - shell_exec("mv -f $old_rrd $new_rrd"); + rename($old_rrd,$new_rrd); if ($debug) { echo("$old_rrd $new_rrd"); } echo("Moved RRD "); } diff --git a/includes/discovery/q-bridge-mib.inc.php b/includes/discovery/q-bridge-mib.inc.php index e7c0bdecc..39310b248 100644 --- a/includes/discovery/q-bridge-mib.inc.php +++ b/includes/discovery/q-bridge-mib.inc.php @@ -1,53 +1,58 @@ \ No newline at end of file diff --git a/includes/discovery/storage-hrstorage.inc.php b/includes/discovery/storage-hrstorage.inc.php index f3111ba25..104d389f2 100755 --- a/includes/discovery/storage-hrstorage.inc.php +++ b/includes/discovery/storage-hrstorage.inc.php @@ -2,38 +2,38 @@ $storage_array = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); -if(is_array($storage_array)) { +if (is_array($storage_array)) +{ echo("hrStorage : "); - foreach($storage_array as $index => $storage) + foreach ($storage_array as $index => $storage) { - $fstype = $storage['hrStorageType']; $descr = $storage['hrStorageDescr']; $size = $storage['hrStorageSize'] * $storage['hrStorageAllocationUnits']; $used = $storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits']; $units = $storage['hrStorageAllocationUnits']; - - foreach($config['ignore_mount'] as $bi) { if($bi == $descr) { $deny = 1; if ($debug) echo("$bi == $descr \n"); } } - foreach($config['ignore_mount_string'] as $bi) { if(strpos($descr, $bi) !== FALSE) { $deny = 1; if ($debug) echo("strpos: $descr, $bi \n"); } } - foreach($config['ignore_mount_regexp'] as $bi) { if(preg_match($bi, $descr) > "0") { $deny = 1; if ($debug) echo("preg_match $bi, $descr \n"); } } + foreach ($config['ignore_mount'] as $bi) { if ($bi == $descr) { $deny = 1; if ($debug) echo("$bi == $descr \n"); } } + foreach ($config['ignore_mount_string'] as $bi) { if (strpos($descr, $bi) !== FALSE) { $deny = 1; if ($debug) echo("strpos: $descr, $bi \n"); } } + foreach ($config['ignore_mount_regexp'] as $bi) { if (preg_match($bi, $descr) > "0") { $deny = 1; if ($debug) echo("preg_match $bi, $descr \n"); } } if (isset($config['ignore_mount_removable']) && $config['ignore_mount_removable'] && $fstype == "hrStorageRemovableDisk") { $deny = 1; if ($debug) echo("skip(removable)\n"); } if (isset($config['ignore_mount_network']) && $config['ignore_mount_network'] && $fstype == "hrStorageNetworkDisk") { $deny = 1; if ($debug) echo("skip(network)\n"); } if (isset($config['ignore_mount_optical']) && $config['ignore_mount_optical'] && $fstype == "hrStorageCompactDisc") { $deny = 1; if ($debug) echo("skip(cd)\n"); } if ($fstype == "hrStorageVirtualMemory" || $fstype == "hrStorageRam" || $fstype == "hrStorageOther") { $deny = 1; } - if(!$deny && is_numeric($index)) { + if (!$deny && is_numeric($index)) + { discover_storage($valid_storage, $device, $index, $fstype, "hrstorage", $descr, $size , $units, $used); } #$old_storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("hrStorage-" . $index . ".rrd"); #$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("storage-hrstorage-" . $index . ".rrd"); - #if(is_file($old_storage_rrd)) { rename($old_storage_rrd,$storage_rrd); } + #if (is_file($old_storage_rrd)) { rename($old_storage_rrd,$storage_rrd); } unset($deny, $fstype, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $storage_array); } } -?> +?> \ No newline at end of file diff --git a/includes/discovery/storage.inc.php b/includes/discovery/storage.inc.php index ca03b1675..3e8746933 100755 --- a/includes/discovery/storage.inc.php +++ b/includes/discovery/storage.inc.php @@ -9,20 +9,24 @@ include("storage-hrstorage.inc.php"); $sql = "SELECT * FROM `storage` WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); -if($debug) { print_r ($valid_storage); } +if ($debug) { print_r ($valid_storage); } -while ($test_storage = mysql_fetch_array($query)) { +while ($test_storage = mysql_fetch_array($query)) +{ $storage_index = $test_storage['storage_index']; $storage_mib = $test_storage['storage_mib']; - if($debug) { echo($storage_index . " -> " . $storage_mib . "\n"); } - if(!$valid_storage[$storage_mib][$storage_index]) { + if ($debug) { echo($storage_index . " -> " . $storage_mib . "\n"); } + + if (!$valid_storage[$storage_mib][$storage_index]) + { echo("-"); mysql_query("DELETE FROM `storage` WHERE storage_id = '" . $test_storage['storage_id'] . "'"); } + unset($storage_index); unset($storage_mib); } unset($valid_storage); echo("\n"); -?> +?> \ No newline at end of file diff --git a/includes/discovery/ucd-diskio.inc.php b/includes/discovery/ucd-diskio.inc.php index 006f2c0a8..a82e49da3 100644 --- a/includes/discovery/ucd-diskio.inc.php +++ b/includes/discovery/ucd-diskio.inc.php @@ -3,13 +3,13 @@ echo("UCD Disk IO : "); $diskio_array = snmpwalk_cache_oid($device, "diskIOEntry", array(), "UCD-DISKIO-MIB" , "+".$config['install_dir']."/mibs/"); $valid_diskio = array(); -# if($debug) { print_r($diskio_array); } +# if ($debug) { print_r($diskio_array); } -if (is_array($diskio_array)) +if (is_array($diskio_array)) { - foreach ($diskio_array as $index => $entry) + foreach ($diskio_array as $index => $entry) { - if($entry['diskIONRead'] > "0" || $entry['diskIONWritten'] > "0") + if ($entry['diskIONRead'] > "0" || $entry['diskIONWritten'] > "0") { if ($debug) { echo("$index ".$entry['diskIODevice']."\n"); } @@ -17,7 +17,7 @@ if (is_array($diskio_array)) { $sql = "INSERT INTO `ucd_diskio` (`device_id`,`diskio_index`,`diskio_descr`) VALUES ('".$device['device_id']."','".$index."','".$entry['diskIODevice']."')"; mysql_query($sql); echo("+"); - if($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); } + if ($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); } } else { @@ -26,7 +26,6 @@ if (is_array($diskio_array)) } $valid_diskio[$index] = 1; - } ## end validity check } ## end array foreach } ## End array if @@ -36,11 +35,13 @@ if (is_array($diskio_array)) $sql = "SELECT * FROM `ucd_diskio` where `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); -if($debug) { print_r ($valid_diskio); } +if ($debug) { print_r ($valid_diskio); } -while ($test = mysql_fetch_array($query)) { - if($debug) { echo($test['diskio_index'] . " -> " . $test['diskio_descr'] . "\n"); } - if(!$valid_diskio[$test['diskio_index']]) { +while ($test = mysql_fetch_array($query)) +{ + if ($debug) { echo($test['diskio_index'] . " -> " . $test['diskio_descr'] . "\n"); } + if (!$valid_diskio[$test['diskio_index']]) + { echo("-"); mysql_query("DELETE FROM `ucd_diskio` WHERE `diskio_id` = '" . $test['diskio_id'] . "'"); }