mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added logging of reason device was detected as down (icmp/snmp)
This commit is contained in:
@ -321,6 +321,8 @@ __devices.location__ = The devices location.
|
||||
|
||||
__devices.status__ = The status of the device, 1 = up, 0 = down.
|
||||
|
||||
__devices.status_reason__ = The reason the device was detected as down (icmp or snmp).
|
||||
|
||||
__devices.ignore__ = If the device is ignored this will be set to 1.
|
||||
|
||||
__devices.disabled__ = If the device is disabled this will be set to 1.
|
||||
|
@ -94,7 +94,7 @@ foreach (dbFetchRows($sql, $param) as $device) {
|
||||
|
||||
if ($device['status'] == '0') {
|
||||
$extra = "danger";
|
||||
$msg = "down";
|
||||
$msg = $device['status_reason'];
|
||||
} else {
|
||||
$extra = "success";
|
||||
$msg = "up";
|
||||
|
@ -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")
|
||||
|
@ -1,3 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS `device_perf` ( `id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `timestamp` datetime NOT NULL, `xmt` float NOT NULL, `rcv` float NOT NULL, `loss` float NOT NULL, `min` float NOT NULL, `max` float NOT NULL, `avg` float NOT NULL, KEY `id` (`id`,`device_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_15m','(%macros.past_15m && %device_perf.loss)','(%macros.past_15m && %device_perf.loss)','Packet loss over the last 15 minutes','alerting',0,'macros',0,1,0);
|
||||
insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_5m','(%macros.past_5m && %device_perf.loss)','(%macros.past_5m && %device_perf.loss)','Packet loss over the last 5 minutes','alerting',0,'macros',0,1,0);
|
||||
ALTER TABLE `devices` ADD `status_reason` VARCHAR( 50 ) NOT NULL AFTER `status` ;
|
||||
UPDATE `devices` SET `status_reason`='down' WHERE `status`=0;
|
||||
|
Reference in New Issue
Block a user