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:
Daniel Preussker
2018-06-05 09:28:13 +00:00
committed by GitHub
parent 6e1db1c872
commit 4e79465f43
3 changed files with 23 additions and 1 deletions

View File

@@ -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'] = [];

View File

@@ -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') {

View File

@@ -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;
}