mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Feature: Add option to ignore blockdevice regex (#8797)
* Feature: Add option to ignore blockdevice regex * Update defaults.inc.php * Update functions.php
This commit is contained in:
@@ -955,3 +955,6 @@ $config['api']['cors']['origin'] = '*';
|
||||
$config['api']['cors']['maxage'] = '86400';
|
||||
$config['api']['cors']['allowmethods'] = array('POST', 'GET', 'PUT', 'DELETE', 'PATCH');
|
||||
$config['api']['cors']['allowheaders'] = array('Origin', 'X-Requested-With', 'Content-Type', 'Accept', 'X-Auth-Token');
|
||||
|
||||
// Disk
|
||||
$config['bad_disk_regexp'] = [];
|
||||
|
@@ -4,7 +4,7 @@ $diskio_array = snmpwalk_cache_oid($device, 'diskIOEntry', array(), 'UCD-DISKIO-
|
||||
$valid_diskio = array();
|
||||
if (is_array($diskio_array)) {
|
||||
foreach ($diskio_array as $index => $entry) {
|
||||
if ($entry['diskIONRead'] > '0' || $entry['diskIONWritten'] > '0') {
|
||||
if (($entry['diskIONRead'] > '0' || $entry['diskIONWritten'] > '0') && is_disk_valid($entry, $device) === true) {
|
||||
d_echo("$index ".$entry['diskIODevice']."\n");
|
||||
|
||||
if (dbFetchCell('SELECT COUNT(*) FROM `ucd_diskio` WHERE `device_id` = ? AND `diskio_index` = ? and `diskio_descr` = ?', array($device['device_id'], $index, $entry['diskIODevice'])) == '0') {
|
||||
|
@@ -2460,3 +2460,22 @@ function hexbin($hex_string)
|
||||
}
|
||||
return $chr_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if disk is valid to poll.
|
||||
* Settings: bad_disk_regexp
|
||||
*
|
||||
* @param array $disk
|
||||
* @param array $device
|
||||
* @return bool
|
||||
*/
|
||||
function is_disk_valid($disk, $device)
|
||||
{
|
||||
foreach (Config::getCombined($device['os'], 'bad_disk_regexp') as $bir) {
|
||||
if (preg_match($bir ."i", $disk['diskIODevice'])) {
|
||||
d_echo("Ignored Disk: {$disk['diskIODevice']} (matched: $bir)\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user