Merge pull request #2175 from laf/issue-2174

Removed ping + performance graphs and tab if skip ping check
This commit is contained in:
Mike Rostermund
2015-10-21 00:14:29 +02:00
5 changed files with 47 additions and 24 deletions

View File

@ -353,11 +353,13 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
</li>';
}
echo '<li class="'.$select['performance'].'">
<a href="'.generate_device_url($device, array('tab' => 'performance')).'">
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> Performance
</a>
</li>';
if (can_ping_device($attribs) === true) {
echo '<li class="'.$select['performance'].'">
<a href="'.generate_device_url($device, array('tab' => 'performance')).'">
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> Performance
</a>
</li>';
}
echo '<li class="'.$select['notes'].'">
<a href="'.generate_device_url($device, array('tab' => 'notes')).'">

View File

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

View File

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

View File

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

View File

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