Added logging of reason device was detected as down (icmp/snmp)

This commit is contained in:
laf
2015-06-22 22:11:02 +01:00
parent eee2ae5be1
commit 820afa6dbb
4 changed files with 11 additions and 5 deletions

View File

@@ -144,21 +144,23 @@ function poll_device($device, $options)
$device['pingable'] = $ping_response['result'];
$ping_time = $ping_response['last_ping_timetaken'];
$response = array();
$status_reason = '';
if ($device['pingable'])
{
$device['snmpable'] = isSNMPable($device);
if ($device['snmpable'])
{
$status = "1";
$response['status_reason'] = '';
} else {
echo("SNMP Unreachable");
$status = "0";
$response['status'] = 'snmp';
$response['status_reason'] = 'snmp';
}
} else {
echo("Unpingable");
$status = "0";
$response['status'] = 'icmp';
$response['status_reason'] = 'icmp';
}
if ($device['status'] != $status)
@@ -166,11 +168,11 @@ function poll_device($device, $options)
$poll_update .= $poll_separator . "`status` = '$status'";
$poll_separator = ", ";
dbUpdate(array('status' => $status), 'devices', 'device_id=?', array($device['device_id']));
dbUpdate(array('status' => $status,'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id']));
dbInsert(array('importance' => '0', 'device_id' => $device['device_id'], 'message' => "Device is " .($status == '1' ? 'up' : 'down')), 'alerts');
log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device, ($status == '1' ? 'up' : 'down'));
notify($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " " . $response['status']);
notify($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " " . $response['status_reason']);
}
if ($status == "1")