From af4e0bc2ff90cf3ff63d7b06a82b56a48ab515cc Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Sun, 28 Feb 2010 02:17:25 +0000 Subject: [PATCH] move mount ignores to defaults config file, add option to ignore optical drives, and fix the entire ignore thing as 'someone' broke it after semi-rewriting the storage portion git-svn-id: http://www.observium.org/svn/observer/trunk@971 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 5 ----- includes/defaults.inc.php | 3 +++ includes/discovery/storage-hrstorage.inc.php | 16 +++++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config.php.default b/config.php.default index 57424edf3..490f9b668 100755 --- a/config.php.default +++ b/config.php.default @@ -124,11 +124,6 @@ $config['allow_entity_sensor']['watts'] = 1; $config['allow_entity_sensor']['truthvalue'] = 1; $config['allow_entity_sensor']['specialEnum'] = 1; -### Mountpoints to ignore - -$config['ignore_mount_removable'] = 1; # Ignore removable disk storage -$config['ignore_mount_network'] = 1; # Ignore network mounted storage - ### Hardcoded ASN descriptions # $config['astext'][65333] = "Cymru Bogon Feed"; diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 09c492def..049cec01f 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -71,6 +71,9 @@ $config['bad_if_regexp'] = array("/serial[0-9]:/"); $config['processor_filter'][] = "An electronic chip that makes the computer work."; +$config['ignore_mount_removable'] = 1; # Ignore removable disk storage +$config['ignore_mount_network'] = 1; # Ignore network mounted storage +$config['ignore_mount_optical'] = 1; # Ignore mounted optical discs # Sensors diff --git a/includes/discovery/storage-hrstorage.inc.php b/includes/discovery/storage-hrstorage.inc.php index 9b518d9f2..d0eeb625b 100755 --- a/includes/discovery/storage-hrstorage.inc.php +++ b/includes/discovery/storage-hrstorage.inc.php @@ -4,28 +4,30 @@ $storage_array = snmp_cache_oid("hrStorageEntry", $device, array(), "HOST-RESOUR if(is_array($storage_array)) { echo("hrStorage : "); - foreach($storage_array[$device[device_id]] as $index => $storage) { + foreach($storage_array[$device[device_id]] as $index => $storage) + { 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("$descr, $bi \n"); } } foreach($config['ignore_mount_regexp'] as $bi) { if(preg_match($bi, $descr)) { $deny = 1; if ($debug) echo("$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"); } - - $type = $storage['hrStorageType']; + $fstype = $storage['hrStorageType']; $descr = $storage['hrStorageDescr']; $size = $storage['hrStorageSize'] * $storage['hrStorageAllocationUnits']; $used = $storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits']; $units = $storage['hrStorageAllocationUnits']; + 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(!$deny && is_numeric($index)) { - discover_storage($valid_storage, $device, $index, $type, "hrstorage", $descr, $size , $units, $used); + 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); } - unset($deny, $type, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $storage_array); + unset($deny, $fstype, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $storage_array); } }