diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php
index d5ccd5212..688a18900 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 e4bd13d84..154cbbfb5 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 bcef46da0..248285600 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 319adb074..4682c994f 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -483,17 +483,15 @@ function isSNMPable($device) {
*
* @param string $hostname The hostname or IP address to send ping requests to.
* @param int $address_family The address family (AF_INET for IPv4 or AF_INET6 for IPv6) to use. Defaults to IPv4. Will *not* be autodetected for IP addresses, so it has to be set to AF_INET6 when pinging an IPv6 address or an IPv6-only host.
- * @param int $device_id This parameter is currently ignored.
+ * @param array $attribs The device attributes
*
* @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, $attribs = array()) {
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 bbdad009c..fff7bbe45 100644
--- a/includes/polling/functions.inc.php
+++ b/includes/polling/functions.inc.php
@@ -146,6 +146,7 @@ function poll_device($device, $options) {
unset($poll_update_query);
unset($poll_separator);
$poll_update_array = array();
+ $update_array = array();
$host_rrd = $config['rrd_dir'].'/'.$device['hostname'];
if (!is_dir($host_rrd)) {
@@ -155,12 +156,12 @@ 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, $attribs);
$device_perf = $ping_response['db'];
$device_perf['device_id'] = $device['device_id'];
$device_perf['timestamp'] = array('NOW()');
- if (is_array($device_perf)) {
+ if (can_ping_device($attribs) === true && is_array($device_perf)) {
dbInsert($device_perf, 'device_perf');
}
@@ -265,23 +266,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";