mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
discovery cleanup complete
git-svn-id: http://www.observium.org/svn/observer/trunk@1840 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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']."'");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -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");
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -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 ");
|
||||
}
|
||||
|
||||
@@ -1,53 +1,58 @@
|
||||
<?php
|
||||
|
||||
echo("Q-BRIDGE-MIB VLANs : ");
|
||||
echo("Q-BRIDGE-MIB VLANs : ");
|
||||
|
||||
$vlanversion = snmp_get($device, "dot1qVlanVersionNumber.0", "-Oqv", "Q-BRIDGE-MIB");
|
||||
$vlanversion = snmp_get($device, "dot1qVlanVersionNumber.0", "-Oqv", "Q-BRIDGE-MIB");
|
||||
|
||||
if($vlanversion == 'version1') {
|
||||
if ($vlanversion == 'version1')
|
||||
{
|
||||
echo("VLAN $vlanversion ");
|
||||
|
||||
echo("VLAN $vlanversion ");
|
||||
$vlans = snmp_walk($device, "dot1qVlanFdbId", $options = "-Oqn", $mib = "Q-BRIDGE-MIB");
|
||||
|
||||
$vlans = snmp_walk($device, "dot1qVlanFdbId", $options = "-Oqn", $mib = "Q-BRIDGE-MIB");
|
||||
foreach (explode("\n", $vlans) as $vlan_oid)
|
||||
{
|
||||
list($oid,$vlan_index) = split(' ',$vlan_oid);
|
||||
$oid_ex = explode('.',$oid);
|
||||
$vlan = $oid_ex[count($oid_ex)-1];
|
||||
|
||||
foreach(explode("\n", $vlans) as $vlan_oid) {
|
||||
$vlan_descr_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m Q-BRIDGE-MIB -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
||||
$vlan_descr_cmd .= "dot1qVlanStaticName.$vlan|grep -v \"No Such Instance currently exists at this OID\"";
|
||||
$vlan_descr = shell_exec($vlan_descr_cmd);
|
||||
|
||||
list($oid,$vlan_index) = split(' ',$vlan_oid);
|
||||
$oid_ex = explode('.',$oid);
|
||||
$vlan = $oid_ex[count($oid_ex)-1];
|
||||
|
||||
$vlan_descr_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m Q-BRIDGE-MIB -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
||||
$vlan_descr_cmd .= "dot1qVlanStaticName.$vlan|grep -v \"No Such Instance currently exists at this OID\"";
|
||||
$vlan_descr = shell_exec($vlan_descr_cmd);
|
||||
|
||||
$vlan_descr = trim(str_replace("\"", "", $vlan_descr));
|
||||
|
||||
if(mysql_result(mysql_query("SELECT COUNT(vlan_id) FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '' AND `vlan_vlan` = '" . $vlan . "'"), 0) == '0') {
|
||||
mysql_query("INSERT INTO `vlans` (`device_id`,`vlan_domain`,`vlan_vlan`, `vlan_descr`) VALUES (" . $device['device_id'] . ",'','$vlan', '" . mres($vlan_descr) . "')");
|
||||
echo("+");
|
||||
} else {
|
||||
mysql_query("UPDATE `vlans` SET `vlan_descr`='" . mres($vlan_descr) . "' WHERE `device_id`='" . $device['device_id'] . "' AND `vlan_vlan`='" . $vlan . "'");
|
||||
echo(".");
|
||||
}
|
||||
|
||||
$this_vlans[] = $vlan;
|
||||
$vlan_descr = trim(str_replace("\"", "", $vlan_descr));
|
||||
|
||||
if (mysql_result(mysql_query("SELECT COUNT(vlan_id) FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '' AND `vlan_vlan` = '" . $vlan . "'"), 0) == '0')
|
||||
{
|
||||
mysql_query("INSERT INTO `vlans` (`device_id`,`vlan_domain`,`vlan_vlan`, `vlan_descr`) VALUES (" . $device['device_id'] . ",'','$vlan', '" . mres($vlan_descr) . "')");
|
||||
echo("+");
|
||||
} else {
|
||||
mysql_query("UPDATE `vlans` SET `vlan_descr`='" . mres($vlan_descr) . "' WHERE `device_id`='" . $device['device_id'] . "' AND `vlan_vlan`='" . $vlan . "'");
|
||||
echo(".");
|
||||
}
|
||||
|
||||
$device_vlans = mysql_query("SELECT * FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "'");
|
||||
while($dev_vlan = mysql_fetch_array($device_vlans)) {
|
||||
unset($vlan_exists);
|
||||
foreach($this_vlans as $test_vlan) {
|
||||
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'] . "'");
|
||||
echo("-");
|
||||
if ($debug) { echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n"); }
|
||||
}
|
||||
}
|
||||
$this_vlans[] = $vlan;
|
||||
}
|
||||
|
||||
unset($this_vlans);
|
||||
$device_vlans = mysql_query("SELECT * FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "'");
|
||||
while ($dev_vlan = mysql_fetch_array($device_vlans))
|
||||
{
|
||||
unset($vlan_exists);
|
||||
foreach ($this_vlans as $test_vlan)
|
||||
{
|
||||
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'] . "'");
|
||||
echo("-");
|
||||
if ($debug) { echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
unset($this_vlans);
|
||||
|
||||
echo("\n");
|
||||
|
||||
?>
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -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");
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -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'] . "'");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user