From bbae6e9c4896515746e2e21859ee485090e7f005 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 17 Oct 2015 18:49:01 +0000 Subject: [PATCH] Removed ping + performance graphs and tab if skip ping check --- html/pages/device.inc.php | 12 +++++++----- html/pages/device/graphs.inc.php | 4 +++- includes/common.php | 16 ++++++++++++++++ includes/functions.php | 6 ++---- includes/polling/functions.inc.php | 28 ++++++++++++++++------------ 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index d5ccd5212b..688a18900a 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -353,11 +353,13 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) { '; } - echo '
  • - - Performance - -
  • '; + if (can_ping_device($attribs) === true) { + echo '
  • + + Performance + +
  • '; + } echo '
  • diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index e4bd13d84c..154cbbfb51 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -24,7 +24,9 @@ foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY g // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; -$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +if (can_ping_device($attribs) === true) { + $graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +} $sep = ''; foreach ($graph_enable as $section => $nothing) { diff --git a/includes/common.php b/includes/common.php index bcef46da05..2482856002 100644 --- a/includes/common.php +++ b/includes/common.php @@ -758,3 +758,19 @@ function round_Nth($val = 0, $round_to) { } } // end round_Nth +/** + * Checks if config allows us to ping this device + * $attribs contains an array of all of this devices + * attributes + * @param array $attribs Device attributes + * @return bool +**/ +function can_ping_device($attribs) { + global $config; + if ($config['icmp_check'] === true && $attribs['override_icmp_disable'] != "true") { + return true; + } + else { + return false; + } +} // end can_ping_device diff --git a/includes/functions.php b/includes/functions.php index 319adb0740..d87d385365 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -487,13 +487,11 @@ function isSNMPable($device) { * * @return bool TRUE if the host responded to at least one ping request, FALSE otherwise. */ -function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE) { +function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE, $attribs = 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") { - + if (can_ping_device($attribs) === true) { $fping_params = ''; if(is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) { $fping_params .= ' -r ' . $config['fping_options']['retries']; diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index bbdad009cb..ca28abc79b 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -155,7 +155,7 @@ function poll_device($device, $options) { $address_family = snmpTransportToAddressFamily($device['transport']); - $ping_response = isPingable($device['hostname'], $address_family, $device['device_id']); + $ping_response = isPingable($device['hostname'], $address_family, $device['device_id'], $attribs); $device_perf = $ping_response['db']; $device_perf['device_id'] = $device['device_id']; @@ -265,23 +265,27 @@ function poll_device($device, $options) { } // Ping response rrd - $ping_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/ping-perf.rrd'; - if (!is_file($ping_rrd)) { - rrdtool_create($ping_rrd, 'DS:ping:GAUGE:600:0:65535 '.$config['rrd_rra']); - } + if (can_ping_device($attribs) === true) { + $ping_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/ping-perf.rrd'; + if (!is_file($ping_rrd)) { + rrdtool_create($ping_rrd, 'DS:ping:GAUGE:600:0:65535 '.$config['rrd_rra']); + } - if (!empty($ping_time)) { - $fields = array( - 'ping' => $ping_time, - ); + if (!empty($ping_time)) { + $fields = array( + 'ping' => $ping_time, + ); + + rrdtool_update($ping_rrd, $fields); + } + + $update_array['last_ping'] = array('NOW()'); + $update_array['last_ping_timetaken'] = $ping_time; - rrdtool_update($ping_rrd, $fields); } $update_array['last_polled'] = array('NOW()'); $update_array['last_polled_timetaken'] = $device_time; - $update_array['last_ping'] = array('NOW()'); - $update_array['last_ping_timetaken'] = $ping_time; // echo("$device_end - $device_start; $device_time $device_run"); echo "Polled in $device_time seconds\n";