From e21ee0d8d8e80b39ac079165b4b4a95741e9774e Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 7 Oct 2015 21:19:27 +0000 Subject: [PATCH 1/6] Added ability to disable icmp check on devices --- includes/defaults.inc.php | 2 ++ includes/functions.php | 51 ++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a47a32d87..c0345ffba 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -195,6 +195,8 @@ $config['snmp']['v3'][0]['cryptopass'] = ''; $config['snmp']['v3'][0]['cryptoalgo'] = 'AES'; // AES | DES +// Devices must respond to icmp by default +$config['icmp_check'] = true; // Autodiscovery Settings $config['autodiscovery']['xdp'] = true; diff --git a/includes/functions.php b/includes/functions.php index 42e9d0b25..ba4aeb30a 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -490,31 +490,38 @@ function isSNMPable($device) { function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE) { global $config; - $fping_params = ''; - if(is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) { - $fping_params .= ' -r ' . $config['fping_options']['retries']; - } - if(is_numeric($config['fping_options']['timeout']) || $config['fping_options']['timeout'] > 1) { - $fping_params .= ' -t ' . $config['fping_options']['timeout']; - } - if(is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { - $fping_params .= ' -c ' . $config['fping_options']['count']; - } - if(is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) { - $fping_params .= ' -p ' . $config['fping_options']['millisec']; - } - $response = array(); - $status = fping($hostname,$fping_params,$address_family); - if ($status['loss'] == 100) { - $response['result'] = FALSE; + if ($config['icmp_check'] === true) { + + $fping_params = ''; + if(is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) { + $fping_params .= ' -r ' . $config['fping_options']['retries']; + } + if(is_numeric($config['fping_options']['timeout']) || $config['fping_options']['timeout'] > 1) { + $fping_params .= ' -t ' . $config['fping_options']['timeout']; + } + if(is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { + $fping_params .= ' -c ' . $config['fping_options']['count']; + } + if(is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) { + $fping_params .= ' -p ' . $config['fping_options']['millisec']; + } + $response = array(); + $status = fping($hostname,$fping_params,$address_family); + if ($status['loss'] == 100) { + $response['result'] = FALSE; + } + else { + $response['result'] = TRUE; + } + if (is_numeric($status['avg'])) { + $response['last_ping_timetaken'] = $status['avg']; + } + $response['db'] = $status; } else { - $response['result'] = TRUE; + $response['result'] = true; + $response['last_ping_timetaken'] = 0; } - if (is_numeric($status['avg'])) { - $response['last_ping_timetaken'] = $status['avg']; - } - $response['db'] = $status; return($response); } From 769cc293c30552cc0602a4b8b9735e1f4f69245f Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 13 Oct 2015 19:12:07 +0000 Subject: [PATCH 2/6] Added WebUI override to disable icmp checks for a device --- html/pages/device/edit/misc.inc.php | 6 ++++++ includes/functions.php | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/html/pages/device/edit/misc.inc.php b/html/pages/device/edit/misc.inc.php index 5f66c88fd..8a38293ed 100644 --- a/html/pages/device/edit/misc.inc.php +++ b/html/pages/device/edit/misc.inc.php @@ -2,6 +2,12 @@ echo '
+
+ +
+ '.dynamic_override_config('checkbox','override_icmp_disable', $device).' +
+
diff --git a/includes/functions.php b/includes/functions.php index ba4aeb30a..1da63d4e8 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -490,7 +490,8 @@ function isSNMPable($device) { function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE) { global $config; - if ($config['icmp_check'] === true) { + $tmp_device = array('device_id'=>$device_id); + if ($config['icmp_check'] === true || get_dev_attrib($tmp_device,'override_icmp_disable') != "true") { $fping_params = ''; if(is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) { From 5f369562a5e5ae3e3224fa61d7731e25255f54d4 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 13 Oct 2015 19:16:23 +0000 Subject: [PATCH 3/6] Added docs on new config option --- doc/Support/Configuration.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 865b00b9b..7ffdffe08 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -59,6 +59,17 @@ $config['fping_options']['millisec'] = 200; * `count` (`fping` parameter `-c`): Number of request packets to send to each target. * `millisec` (`fping` parameter `-p`): Time in milliseconds that fping waits between successive packets to an individual target. +You can disable the fping / icmp check that is done for a device to be determined to be up on a global or per device basis. +**We don't advice disabling the fping / icmp check unless you know the impact, at worst if you have a large number of devices down +then it's possible that the poller would no longer complete in 5 minutes due to waiting for snmp to timeout.** + +Globally disable fping / icmp check: +```php +$config['icmp_check'] = false; +``` + +If you would like to do this on a per device basis then you can do so under Device -> Edit -> Misc -> Disable ICMP Test? On + ```php $config['snmpwalk'] = "/usr/bin/snmpwalk"; $config['snmpget'] = "/usr/bin/snmpget"; From 2f30848b8758bdb573e247475c99afb6ced5af35 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 13 Oct 2015 22:14:00 +0000 Subject: [PATCH 4/6] Should have been an && :( --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index 1da63d4e8..935d82dff 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -491,7 +491,7 @@ function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE) { global $config; $tmp_device = array('device_id'=>$device_id); - if ($config['icmp_check'] === true || get_dev_attrib($tmp_device,'override_icmp_disable') != "true") { + if ($config['icmp_check'] === true && get_dev_attrib($tmp_device,'override_icmp_disable') != "true") { $fping_params = ''; if(is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) { From 658f6faba64283deffa3613bf2f1ed4d1178b9e6 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 13 Oct 2015 22:46:36 +0000 Subject: [PATCH 5/6] Scrut fix --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index 935d82dff..319adb074 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -491,6 +491,7 @@ function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE) { global $config; $tmp_device = array('device_id'=>$device_id); + $response = array(); if ($config['icmp_check'] === true && get_dev_attrib($tmp_device,'override_icmp_disable') != "true") { $fping_params = ''; @@ -506,7 +507,6 @@ function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE) { if(is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) { $fping_params .= ' -p ' . $config['fping_options']['millisec']; } - $response = array(); $status = fping($hostname,$fping_params,$address_family); if ($status['loss'] == 100) { $response['result'] = FALSE; From 0af676ecb91679adabdb0fe6bdf74c58b6872318 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 17 Oct 2015 11:28:03 +0000 Subject: [PATCH 6/6] Updated for field --- html/pages/device/edit/misc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/pages/device/edit/misc.inc.php b/html/pages/device/edit/misc.inc.php index 8a38293ed..a85689852 100644 --- a/html/pages/device/edit/misc.inc.php +++ b/html/pages/device/edit/misc.inc.php @@ -3,7 +3,7 @@ echo '
- +
'.dynamic_override_config('checkbox','override_icmp_disable', $device).'