mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
webui: New eventlog severity classification (#5830)
* New event log severity model * Revert "New event log severity model" This reverts commit0783527af8. * New event log severity model * Fixed spaces vs tabs * Learning the format requirements * Learning the format requirements * Moved the colours in to the stylesheet * change SQL file to stop conflicting * refactor log_event so severity isn't last, but reference is. * keep having to move the file due to new PR conflicts * Revert "keep having to move the file due to new PR conflicts" This reverts commitf3030e7218. * extended support to dashboard and eventlog page * formatting
This commit is contained in:
committed by
Neil Lathwood
parent
a75ec7ab31
commit
5bfd23e7eb
@@ -357,7 +357,7 @@ class Component
|
||||
dbUpdate($DATA, 'component_prefs', '`component` = ? AND `attribute` = ?', array($COMPONENT, $ATTR));
|
||||
|
||||
// Add the modification to the Eventlog.
|
||||
log_event("Component: ".$AVP[$COMPONENT]['type']."(".$COMPONENT."). Attribute: ".$ATTR.", was modified from: ".$OLD[$COMPONENT][$ATTR].", to: ".$VALUE, $device_id, 'component', $COMPONENT);
|
||||
log_event("Component: " . $AVP[$COMPONENT]['type'] . "(" . $COMPONENT . "). Attribute: " . $ATTR . ", was modified from: " . $OLD[$COMPONENT][$ATTR] . ", to: " . $VALUE, $device_id, 'component', $COMPONENT);
|
||||
}
|
||||
} // End Foreach AVP
|
||||
|
||||
|
||||
+3
-3
@@ -349,13 +349,13 @@ function ExtTransports($obj)
|
||||
$prefix[4] = &$prefix[0];
|
||||
if ($tmp === true) {
|
||||
echo 'OK';
|
||||
log_event('Issued '.$prefix[$obj['state']]." for rule '".$obj['name']."' to transport '".$transport."'", $obj['device_id']);
|
||||
log_event('Issued ' . $prefix[$obj['state']] . " for rule '" . $obj['name'] . "' to transport '" . $transport . "'", $obj['device_id'], null, 1);
|
||||
} elseif ($tmp === false) {
|
||||
echo 'ERROR';
|
||||
log_event('Could not issue '.$prefix[$obj['state']]." for rule '".$obj['name']."' to transport '".$transport."'", $obj['device_id']);
|
||||
log_event('Could not issue ' . $prefix[$obj['state']] . " for rule '" . $obj['name'] . "' to transport '" . $transport . "'", $obj['device_id'], null, 5);
|
||||
} else {
|
||||
echo 'ERROR: '.$tmp."\r\n";
|
||||
log_event('Could not issue '.$prefix[$obj['state']]." for rule '".$obj['name']."' to transport '".$transport."' Error: ".$tmp, $obj['device_id']);
|
||||
log_event('Could not issue ' . $prefix[$obj['state']] . " for rule '" . $obj['name'] . "' to transport '" . $transport . "' Error: " . $tmp, $obj['device_id'], null, 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2164,3 +2164,27 @@ label {
|
||||
.device-icon-48h img {
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
.severity-ok {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.severity-info {
|
||||
color: royalblue;
|
||||
}
|
||||
|
||||
.severity-notice {
|
||||
color: gold;
|
||||
}
|
||||
|
||||
.severity-warning {
|
||||
color: darkorange;
|
||||
}
|
||||
|
||||
.severity-critical {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.severity-unknown {
|
||||
color: darkgrey;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ $common_output[] = '
|
||||
<table id="eventlog" class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="eventicon"></th>
|
||||
<th data-column-id="datetime" data-order="desc">Datetime</th>
|
||||
<th data-column-id="hostname">Hostname</th>
|
||||
<th data-column-id="type">Type</th>
|
||||
|
||||
@@ -711,46 +711,6 @@ function print_optionbar_end()
|
||||
}//end print_optionbar_end()
|
||||
|
||||
|
||||
function geteventicon($message)
|
||||
{
|
||||
if ($message == 'Device status changed to Down from check') {
|
||||
$icon = 'fa-bookmark';
|
||||
$icon_colour = 'red';
|
||||
}
|
||||
|
||||
if ($message == 'Device status changed to Up from check') {
|
||||
$icon = 'fa-bookmark';
|
||||
$icon_colour = 'green';
|
||||
}
|
||||
|
||||
if ($message == 'Interface went down' || $message == 'Interface changed state to Down' || $message == 'ifOperStatus: up -> down') {
|
||||
$icon = 'fa-bookmark';
|
||||
$icon_colour = 'red';
|
||||
}
|
||||
|
||||
if ($message == 'Interface went up' || $message == 'Interface changed state to Up' || $message == 'ifOperStatus: down -> up') {
|
||||
$icon = 'fa-bookmark';
|
||||
$icon_colour = 'green';
|
||||
}
|
||||
|
||||
if ($message == 'Interface disabled' || $message == 'ifAdminStatus: up -> down') {
|
||||
$icon = 'fa-bookmark';
|
||||
$icon_colour = 'grey';
|
||||
}
|
||||
|
||||
if ($message == 'Interface enabled' || $message == 'ifAdminStatus: down -> up') {
|
||||
$icon = 'fa-bookmark';
|
||||
$icon_colour = 'green';
|
||||
}
|
||||
|
||||
if (isset($icon)) {
|
||||
return array('icon' => $icon,'colour' => $icon_colour);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}//end geteventicon()
|
||||
|
||||
|
||||
function overlibprint($text)
|
||||
{
|
||||
return "onmouseover=\"return overlib('".$text."');\" onmouseout=\"return nd();\"";
|
||||
@@ -1426,3 +1386,31 @@ function array_to_htmljson($data)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $eventlog_severity
|
||||
* @return $eventlog_severity_icon
|
||||
*/
|
||||
function eventlog_severity($eventlog_severity)
|
||||
{
|
||||
switch ($eventlog_severity) {
|
||||
case 1:
|
||||
return "severity-ok"; //OK
|
||||
break;
|
||||
case 2:
|
||||
return "severity-info"; //Informational
|
||||
break;
|
||||
case 3:
|
||||
return "severity-notice"; //Notice
|
||||
break;
|
||||
case 4:
|
||||
return "severity-warning"; //Warning
|
||||
break;
|
||||
case 5:
|
||||
return "severity-critical"; //Critical
|
||||
break;
|
||||
default:
|
||||
return "severity-unknown"; //Unknown
|
||||
break;
|
||||
}
|
||||
} // end eventlog_severity
|
||||
|
||||
@@ -7,15 +7,9 @@ if ($bg == $list_colour_a) {
|
||||
}
|
||||
|
||||
unset($icon);
|
||||
$icon_returned = geteventicon($entry['message']);
|
||||
$icon_type = $icon_returned['icon'];
|
||||
$icon_colour = $icon_returned['colour'];
|
||||
$severity_colour = eventlog_severity($entry['severity']);
|
||||
|
||||
if ($icon_type) {
|
||||
$icon = "<i class='fa $icon_type fa-lg' style='color:$icon_colour' aria-hidden='true'></i>";
|
||||
} else {
|
||||
$icon = "<i class='fa fa-bookmark-o fa-lg' style='color:black' aria-hidden='true'></i>";
|
||||
}
|
||||
$icon = "<i class='fa fa-bookmark fa-lg $severity_colour' aria-hidden='true'></i>";
|
||||
|
||||
echo '<tr">
|
||||
<td>'.$icon.'
|
||||
|
||||
@@ -3,15 +3,9 @@
|
||||
$hostname = gethostbyid($entry['host']);
|
||||
|
||||
unset($icon);
|
||||
$icon_returned = geteventicon($entry['message']);
|
||||
$icon_type = $icon_returned['icon'];
|
||||
$icon_colour = $icon_returned['colour'];
|
||||
$severity_colour = eventlog_severity($entry['severity']);
|
||||
|
||||
if ($icon_type) {
|
||||
$icon = "<i class='fa $icon_type fa-lg' style='color:$icon_colour' aria-hidden='true'></i>";
|
||||
} else {
|
||||
$icon = "<i class='fa fa-bookmark-o fa-lg' style='color:black' aria-hidden='true'></i>";
|
||||
}
|
||||
$icon = "<i class='fa fa-bookmark fa-lg $severity_colour' aria-hidden='true'></i>";
|
||||
|
||||
echo '<tr>
|
||||
<td>'.$icon.'
|
||||
|
||||
@@ -49,7 +49,7 @@ if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql";
|
||||
$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate,severity $sql";
|
||||
|
||||
foreach (dbFetchRows($sql, $param) as $eventlog) {
|
||||
$dev = device_by_id_cache($eventlog['host']);
|
||||
@@ -59,8 +59,9 @@ foreach (dbFetchRows($sql, $param) as $eventlog) {
|
||||
} else {
|
||||
$type = $eventlog['type'];
|
||||
}
|
||||
|
||||
$severity_colour = $eventlog['severity'];
|
||||
$response[] = array(
|
||||
'eventicon' => "<i class='fa fa-bookmark fa-lg ".eventlog_severity($severity_colour)."' aria-hidden='true'></i>",
|
||||
'datetime' => $eventlog['humandate'],
|
||||
'hostname' => generate_device_link($dev, shorthost($dev['hostname'])),
|
||||
'type' => $type,
|
||||
|
||||
+2
-2
@@ -139,8 +139,8 @@ if (empty($config['favicon'])) {
|
||||
<link href="css/MarkerCluster.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/MarkerCluster.Default.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/leaflet.awesome-markers.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?php echo($config['stylesheet']); ?>?ver=342435234432" rel="stylesheet" type="text/css" />
|
||||
<link href="css/<?php echo $config['site_style']; ?>.css?ver=90376932432" rel="stylesheet" type="text/css" />
|
||||
<link href="<?php echo($config['stylesheet']); ?>?ver=291727419" rel="stylesheet" type="text/css" />
|
||||
<link href="css/<?php echo $config['site_style']; ?>.css?ver=632417638" rel="stylesheet" type="text/css" />
|
||||
<?php
|
||||
|
||||
foreach ((array)$config['webui']['custom_css'] as $custom_css) {
|
||||
|
||||
+1
-1
@@ -1543,7 +1543,7 @@ function load_os(&$device)
|
||||
|
||||
// Set type to a predefined type for the OS if it's not already set
|
||||
if ($device['attribs']['override_device_type'] != 1 && $config['os'][$device['os']]['type'] != $device['type']) {
|
||||
log_event('Device type changed '.$device['type'].' => '.$config['os'][$device['os']]['type'], $device, 'system');
|
||||
log_event('Device type changed ' . $device['type'] . ' => ' . $config['os'][$device['os']]['type'], $device, 'system', 3);
|
||||
$device['type'] = $config['os'][$device['os']]['type'];
|
||||
dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo "Device type changed to " . $device['type'] . "!\n";
|
||||
|
||||
@@ -68,7 +68,7 @@ foreach ($vrfs_lite_cisco as $vrf) {
|
||||
$old_mac = $existing_data[$index]['mac_address'];
|
||||
if ($mac != $old_mac && $mac != '') {
|
||||
d_echo("Changed mac address for $ip from $old_mac to $mac\n");
|
||||
log_event("MAC change: $ip : ".mac_clean_to_readable($old_mac).' -> '.mac_clean_to_readable($mac), $device, 'interface', $port_id);
|
||||
log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac) . ' -> ' . mac_clean_to_readable($mac), $device, 'interface', $port_id);
|
||||
dbUpdate(array('mac_address' => $mac), 'ipv4_mac', 'port_id=? AND ipv4_address=? AND context_name=?', array($port_id, $ip, $context));
|
||||
}
|
||||
d_echo(null, '.');
|
||||
|
||||
@@ -32,7 +32,7 @@ function discover_new_device($hostname, $device = '', $method = '', $interface =
|
||||
// $ip isn't a valid IP so it must be a name.
|
||||
if ($ip == $hostname) {
|
||||
d_echo("name lookup of $hostname failed\n");
|
||||
log_event("$method discovery of " . $hostname . " failed - Check name lookup", $device['device_id'], 'discovery');
|
||||
log_event("$method discovery of " . $hostname . " failed - Check name lookup", $device['device_id'], 'discovery');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') {
|
||||
if (!in_array($db_vm['vmwVmVMID'], $libvirt_vmlist)) {
|
||||
dbDelete('vminfo', '`id` = ?', array($db_vm['id']));
|
||||
echo '-';
|
||||
log_event('Virtual Machine removed: '.$db_vm['vmwVmDisplayName'], $device, 'vm', $db_vm['id']);
|
||||
log_event('Virtual Machine removed: ' . $db_vm['vmwVmDisplayName'], $device, 'vm', $db_vm['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
$os = getHostOS($device);
|
||||
if ($os != $device['os']) {
|
||||
log_event('Device OS changed '.$device['os']." => $os", $device, 'system');
|
||||
log_event('Device OS changed ' . $device['os'] . " => $os", $device, 'system', 3);
|
||||
$device['os'] = $os;
|
||||
$sql = dbUpdate(array('os' => $os), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo "Changed OS! : $os\n";
|
||||
@@ -10,7 +10,7 @@ if ($os != $device['os']) {
|
||||
|
||||
$icon = getImageName($device, false);
|
||||
if ($icon != $device['icon']) {
|
||||
log_event('Device Icon changed '.$device['icon']." => $icon", $device, 'system');
|
||||
log_event('Device Icon changed ' . $device['icon'] . " => $icon", $device, 'system', 3);
|
||||
$device['icon'] = $icon;
|
||||
$sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo "Changed Icon! : $icon\n";
|
||||
|
||||
@@ -20,7 +20,7 @@ foreach (dbFetchRows($sql) as $test_processor) {
|
||||
if (!$valid['processor'][$processor_type][$processor_index]) {
|
||||
echo '-';
|
||||
dbDelete('processors', '`processor_id` = ?', array($test_processor['processor_id']));
|
||||
log_event('Processor removed: type '.$processor_type.' index '.$processor_index.' descr '.$test_processor['processor_descr'], $device, 'processor', $test_processor['processor_id']);
|
||||
log_event('Processor removed: type ' . $processor_type . ' index ' . $processor_index . ' descr ' . $test_processor['processor_descr'], $device, 'processor', $test_processor['processor_id']);
|
||||
}
|
||||
|
||||
unset($processor_oid);
|
||||
|
||||
@@ -97,7 +97,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||
|
||||
if (!$stp_db['bridgeAddress'] && $stp['bridgeAddress']) {
|
||||
dbInsert($stp, 'stp');
|
||||
log_event('STP added, bridge address: '.$stp['bridgeAddress'], $device, 'stp');
|
||||
log_event('STP added, bridge address: ' . $stp['bridgeAddress'], $device, 'stp');
|
||||
echo '+';
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ if (($device['os'] == 'vmware') || ($device['os'] == 'linux')) {
|
||||
*/
|
||||
if (dbFetchCell("SELECT COUNT(id) FROM `vminfo` WHERE `device_id` = ? AND `vmwVmVMID` = ? AND vm_type='vmware'", array($device['device_id'], $index)) == 0) {
|
||||
$vmid = dbInsert(array('device_id' => $device['device_id'], 'vm_type' => 'vmware', 'vmwVmVMID' => $index, 'vmwVmDisplayName' => mres($vmwVmDisplayName), 'vmwVmGuestOS' => mres($vmwVmGuestOS), 'vmwVmMemSize' => mres($vmwVmMemSize), 'vmwVmCpus' => mres($vmwVmCpus), 'vmwVmState' => mres($vmwVmState)), 'vminfo');
|
||||
log_event(mres($vmwVmDisplayName)." ($vmwVmMemSize GB / $vmwVmCpus vCPU) Discovered", $device, 'system', $vmid);
|
||||
log_event(mres($vmwVmDisplayName) . " ($vmwVmMemSize GB / $vmwVmCpus vCPU) Discovered", $device, 'system', $vmid);
|
||||
echo '+';
|
||||
// FIXME eventlog
|
||||
} else {
|
||||
@@ -69,7 +69,7 @@ if (($device['os'] == 'vmware') || ($device['os'] == 'linux')) {
|
||||
|
||||
if (!in_array($db_vm['vmwVmVMID'], $vmw_vmlist)) {
|
||||
dbDelete('vminfo', '`id` = ?', array($db_vm['id']));
|
||||
log_event(mres($db_vm['vmwVmDisplayName']).' Removed', $device, 'system', $db_vm['vmwVmVMID']);
|
||||
log_event(mres($db_vm['vmwVmDisplayName']) . ' Removed', $device, 'system', $db_vm['vmwVmVMID']);
|
||||
echo '-';
|
||||
// FIXME eventlog
|
||||
}
|
||||
|
||||
@@ -299,9 +299,9 @@ function renamehost($id, $new, $source = 'console')
|
||||
$host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
|
||||
if (!is_dir($config['rrd_dir']."/$new") && rename($config['rrd_dir']."/$host", $config['rrd_dir']."/$new") === true) {
|
||||
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system', 3);
|
||||
} else {
|
||||
log_event("Renaming of $host failed", $id, 'system');
|
||||
log_event("Renaming of $host failed", $id, 'system', 5);
|
||||
if (__FILE__ === $_SERVER['SCRIPT_FILE_NAME']) {
|
||||
echo "Renaming of $host failed\n";
|
||||
} else {
|
||||
@@ -355,7 +355,7 @@ function delete_device($id)
|
||||
}
|
||||
|
||||
$ret .= "Removed device $host\n";
|
||||
log_event("Device $host has been removed", 0, 'system');
|
||||
log_event("Device $host has been removed", 0, 'system', 3);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -789,7 +789,7 @@ function get_astext($asn)
|
||||
}
|
||||
|
||||
# Use this function to write to the eventlog table
|
||||
function log_event($text, $device = null, $type = null, $reference = null)
|
||||
function log_event($text, $device = null, $type = null, $severity = 2, $reference = null)
|
||||
{
|
||||
if (!is_array($device)) {
|
||||
$device = device_by_id_cache($device);
|
||||
@@ -800,6 +800,7 @@ function log_event($text, $device = null, $type = null, $reference = null)
|
||||
'reference' => ($reference ? $reference : "NULL"),
|
||||
'type' => ($type ? $type : "NULL"),
|
||||
'datetime' => array("NOW()"),
|
||||
'severity' => $severity,
|
||||
'message' => $text);
|
||||
|
||||
dbInsert($insert, 'eventlog');
|
||||
|
||||
@@ -135,11 +135,11 @@ if ($config['enable_bgp']) {
|
||||
if ($bgpPeerFsmEstablishedTime) {
|
||||
if (!(is_array($config['alerts']['bgp']['whitelist']) && !in_array($peer['bgpPeerRemoteAs'], $config['alerts']['bgp']['whitelist'])) && ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])) {
|
||||
if ($peer['bgpPeerState'] == $bgpPeerState) {
|
||||
log_event('BGP Session Flap: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
} elseif ($bgpPeerState == 'established') {
|
||||
log_event('BGP Session Up: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
} elseif ($peer['bgpPeerState'] == 'established') {
|
||||
log_event('BGP Session Down: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ if ($config['os'][$device['os']]['bad_snmpEngineTime'] !== true) {
|
||||
|
||||
if (is_numeric($uptime) && ($config['os'][$device['os']]['bad_uptime'] !== true)) {
|
||||
if ($uptime < $device['uptime']) {
|
||||
log_event('Device rebooted after ' . formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
|
||||
log_event('Device rebooted after ' . formatUptime($device['uptime']), $device, 'reboot', 4, $device['uptime']);
|
||||
}
|
||||
|
||||
$tags = array(
|
||||
|
||||
@@ -168,10 +168,10 @@ function poll_sensor($device, $class)
|
||||
// FIXME also warn when crossing WARN level!!
|
||||
if ($sensor['sensor_limit_low'] != '' && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value < $sensor['sensor_limit_low'] && $sensor['sensor_alert'] == 1) {
|
||||
echo 'Alerting for '.$device['hostname'].' '.$sensor['sensor_descr']."\n";
|
||||
log_event(ucfirst($class).' '.$sensor['sensor_descr'].' under threshold: '.$sensor_value." $unit (< ".$sensor['sensor_limit_low']." $unit)", $device, $class, $sensor['sensor_id']);
|
||||
log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . ' under threshold: ' . $sensor_value . " $unit (< " . $sensor['sensor_limit_low'] . " $unit)", $device, $class, $sensor['sensor_id']);
|
||||
} elseif ($sensor['sensor_limit'] != '' && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value > $sensor['sensor_limit'] && $sensor['sensor_alert'] == 1) {
|
||||
echo 'Alerting for '.$device['hostname'].' '.$sensor['sensor_descr']."\n";
|
||||
log_event(ucfirst($class).' '.$sensor['sensor_descr'].' above threshold: '.$sensor_value." $unit (> ".$sensor['sensor_limit']." $unit)", $device, $class, $sensor['sensor_id']);
|
||||
log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . ' above threshold: ' . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']);
|
||||
}
|
||||
if ($sensor['sensor_class'] == 'state' && $sensor['sensor_current'] != $sensor_value) {
|
||||
log_event($class . ' sensor has changed from ' . $sensor['sensor_current'] . ' to ' . $sensor_value, $device, $class, $sensor['sensor_id']);
|
||||
@@ -203,7 +203,7 @@ function poll_device($device, $options)
|
||||
$ip = dnslookup($device);
|
||||
|
||||
if (!empty($ip) && $ip != inet6_ntop($device['ip'])) {
|
||||
log_event('Device IP changed to '.$ip, $device, 'system');
|
||||
log_event('Device IP changed to ' . $ip, $device, 'system');
|
||||
$db_ip = inet_pton($ip);
|
||||
dbUpdate(array('ip' => $db_ip), 'devices', 'device_id=?', array($device['device_id']));
|
||||
}
|
||||
@@ -264,7 +264,7 @@ function poll_device($device, $options)
|
||||
|
||||
dbUpdate(array('status' => $status, 'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id']));
|
||||
|
||||
log_event('Device status changed to '.($status == '1' ? 'Up' : 'Down'). ' from ' . $response['status_reason'] . ' check.', $device, ($status == '1' ? 'up' : 'down'));
|
||||
log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down') . ' from ' . $response['status_reason'] . ' check.', $device, ($status == '1' ? 'up' : 'down'));
|
||||
}
|
||||
|
||||
if ($status == '1') {
|
||||
|
||||
@@ -12,27 +12,27 @@ if (is_file($config['install_dir'].'/includes/polling/os/'.$device['os'].'.inc.p
|
||||
|
||||
if ($device['version'] != $version) {
|
||||
$update_array['version'] = $version;
|
||||
log_event('OS Version -> '.$version, $device, 'system');
|
||||
log_event('OS Version -> ' . $version, $device, 'system');
|
||||
}
|
||||
|
||||
if ($features != $device['features']) {
|
||||
$update_array['features'] = $features;
|
||||
log_event('OS Features -> '.$features, $device, 'system');
|
||||
log_event('OS Features -> ' . $features, $device, 'system');
|
||||
}
|
||||
|
||||
if ($hardware != $device['hardware']) {
|
||||
$update_array['hardware'] = $hardware;
|
||||
log_event('Hardware -> '.$hardware, $device, 'system');
|
||||
log_event('Hardware -> ' . $hardware, $device, 'system');
|
||||
}
|
||||
|
||||
if ($serial != $device['serial']) {
|
||||
$update_array['serial'] = $serial;
|
||||
log_event('Serial -> '.$serial, $device, 'system');
|
||||
log_event('Serial -> ' . $serial, $device, 'system');
|
||||
}
|
||||
|
||||
if ($icon != $device['icon']) {
|
||||
$update_array['icon'] = $icon;
|
||||
log_event('Icon -> '.$icon, $device, 'system');
|
||||
log_event('Icon -> ' . $icon, $device, 'system');
|
||||
}
|
||||
|
||||
echo 'Hardware: ' . $hardware . PHP_EOL;
|
||||
|
||||
@@ -476,7 +476,7 @@ foreach ($ports as $port) {
|
||||
|
||||
if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) {
|
||||
$port['update'][$oid] = array('NULL');
|
||||
log_event($oid.': '.$port[$oid].' -> NULL', $device, 'interface', $port['port_id']);
|
||||
log_event($oid . ': ' . $port[$oid] . ' -> NULL', $device, 'interface', $port['port_id']);
|
||||
if ($debug) {
|
||||
d_echo($oid.': '.$port[$oid].' -> NULL ');
|
||||
} else {
|
||||
@@ -504,7 +504,7 @@ foreach ($ports as $port) {
|
||||
$port['update'][$oid.'_prev'] = $port[$oid];
|
||||
}
|
||||
|
||||
log_event($oid.': '.$port[$oid].' -> '.$this_port[$oid], $device, 'interface', $port['port_id']);
|
||||
log_event($oid . ': ' . $port[$oid] . ' -> ' . $this_port[$oid], $device, 'interface', $port['port_id']);
|
||||
if ($debug) {
|
||||
d_echo($oid.': '.$port[$oid].' -> '.$this_port[$oid].' ');
|
||||
} else {
|
||||
@@ -536,7 +536,7 @@ foreach ($ports as $port) {
|
||||
}
|
||||
|
||||
$port['update'][$attrib_key] = $port_ifAlias[$attrib];
|
||||
log_event($attrib.': '.$port[$attrib_key].' -> '.$log_port, $device, 'interface', $port['port_id']);
|
||||
log_event($attrib . ': ' . $port[$attrib_key] . ' -> ' . $log_port, $device, 'interface', $port['port_id']);
|
||||
unset($log_port);
|
||||
}
|
||||
}
|
||||
@@ -605,7 +605,7 @@ foreach ($ports as $port) {
|
||||
$saturation_threshold = ($this_port['ifSpeed'] * ( $config['alerts']['port_util_perc'] / 100 ));
|
||||
echo 'IN: '.$port['stats']['ifInBits_rate'].' OUT: '.$port['stats']['ifOutBits_rate'].' THRESH: '.$saturation_threshold;
|
||||
if (($port['stats']['ifInBits_rate'] >= $saturation_threshold || $port['stats']['ifOutBits_rate'] >= $saturation_threshold) && $saturation_threshold > 0) {
|
||||
log_event('Port reached saturation threshold: '.formatRates($port['stats']['ifInBits_rate']).'/'.formatRates($port['stats']['ifOutBits_rate']).' - ifspeed: '.formatRates($this_port['stats']['ifSpeed']), $device, 'interface', $port['port_id']);
|
||||
log_event('Port reached saturation threshold: ' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates($this_port['stats']['ifSpeed']), $device, 'interface', $port['port_id']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ foreach ($ports as $port) {
|
||||
// If data has changed, build a query
|
||||
$port['update'][$oid] = $this_port[$oid];
|
||||
echo 'PAgP ';
|
||||
log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['port_id']);
|
||||
log_event("$oid -> " . $this_port[$oid], $device, 'interface', $port['port_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,12 +92,12 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||
if ($stp_db['bridgeAddress'] && $stp['bridgeAddress']) {
|
||||
// Logging if designated root changed since last db update
|
||||
if ($stp_db['designatedRoot'] != $stp['designatedRoot']) {
|
||||
log_event('STP designated root changed: '.$stp_db['designatedRoot'].' > '.$stp['designatedRoot'], $device, 'stp');
|
||||
log_event('STP designated root changed: ' . $stp_db['designatedRoot'] . ' > ' . $stp['designatedRoot'], $device, 'stp');
|
||||
}
|
||||
|
||||
// Logging if designated root port changed since last db update
|
||||
if (isset($stp['rootPort']) && $stp_db['rootPort'] != $stp['rootPort']) {
|
||||
log_event('STP root port changed: '.$stp_db['rootPort'].' > '.$stp['rootPort'], $device, 'stp');
|
||||
log_event('STP root port changed: ' . $stp_db['rootPort'] . ' > ' . $stp['rootPort'], $device, 'stp');
|
||||
}
|
||||
|
||||
// Logging if topology changed since last db update
|
||||
@@ -110,7 +110,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||
// ToDo fix log_event()
|
||||
//
|
||||
//log_event('STP topology changed after: '.formatUptime($stp['timeSinceTopologyChange']), $device, 'stp', $stp['timeSinceTopologyChange']);
|
||||
log_event('STP topology changed after: '.formatUptime($stp['timeSinceTopologyChange']), $device, 'stp');
|
||||
log_event('STP topology changed after: ' . formatUptime($stp['timeSinceTopologyChange']), $device, 'stp');
|
||||
}
|
||||
// Write to db
|
||||
dbUpdate($stp, 'stp', 'device_id = ?', array($device['device_id']));
|
||||
|
||||
@@ -19,12 +19,12 @@ foreach ($toner_data as $toner) {
|
||||
|
||||
// Log empty supplies (but only once)
|
||||
if ($tonerperc == 0 && $toner['toner_current'] > 0) {
|
||||
log_event('Toner '.$toner['toner_descr'].' is empty', $device, 'toner', $toner['toner_id']);
|
||||
log_event('Toner ' . $toner['toner_descr'] . ' is empty', $device, 'toner', $toner['toner_id']);
|
||||
}
|
||||
|
||||
// Log toner swap
|
||||
if ($tonerperc > $toner['toner_current']) {
|
||||
log_event('Toner '.$toner['toner_descr'].' was replaced (new level: '.$tonerperc.'%)', $device, 'toner', $toner['toner_id']);
|
||||
log_event('Toner ' . $toner['toner_descr'] . ' was replaced (new level: ' . $tonerperc . '%)', $device, 'toner', $toner['toner_id']);
|
||||
}
|
||||
|
||||
dbUpdate(array('toner_current' => $tonerperc, 'toner_capacity' => $toner['toner_capacity']), 'toner', '`toner_id` = ?', array($toner['toner_id']));
|
||||
|
||||
@@ -118,7 +118,7 @@ foreach ($pkgs_id as $pkg) {
|
||||
}
|
||||
|
||||
echo '+'.$name.'-'.$version.$dbuild.'-'.$arch;
|
||||
log_event('Package installed: '.$name.' ('.$arch.') version '.$version.$dbuild, $device, 'package');
|
||||
log_event('Package installed: ' . $name . ' (' . $arch . ') version ' . $version . $dbuild, $device, 'package');
|
||||
} elseif (count($pkgs_db[$manager][$name][$arch], 1)) {
|
||||
$pkg_c = dbFetchRow('SELECT * FROM `packages` WHERE `device_id` = ? AND `manager` = ? AND `name` = ? and `arch` = ? ORDER BY version DESC, build DESC', array($device['device_id'], $manager, $name, $arch));
|
||||
if ($pkg_c['build'] != '') {
|
||||
@@ -135,7 +135,7 @@ foreach ($pkgs_id as $pkg) {
|
||||
'size' => $size,
|
||||
);
|
||||
dbUpdate($pkg_update, 'packages', '`pkg_id` = ?', array($pkg_c['pkg_id']));
|
||||
log_event('Package updated: '.$name.' ('.$arch.') from '.$pkg_c['version'].$pkg_c_dbuild.' to '.$version.$dbuild, $device, 'package');
|
||||
log_event('Package updated: ' . $name . ' (' . $arch . ') from ' . $pkg_c['version'] . $pkg_c_dbuild . ' to ' . $version . $dbuild, $device, 'package');
|
||||
unset($pkgs_db_id[$pkg_c['pkg_id']]);
|
||||
}//end if
|
||||
}//end if
|
||||
@@ -146,7 +146,7 @@ foreach ($pkgs_id as $pkg) {
|
||||
foreach ($pkgs_db_id as $id => $pkg) {
|
||||
dbDelete('packages', '`pkg_id` = ?', array($id));
|
||||
echo '-'.$pkg['text'];
|
||||
log_event('Package removed: '.$pkg['name'].' '.$pkg['arch'].' '.$pkg['version'].($pkg['build'] != '' ? '-'.$pkg['build'] : ''), $device, 'package');
|
||||
log_event('Package removed: ' . $pkg['name'] . ' ' . $pkg['arch'] . ' ' . $pkg['version'] . ($pkg['build'] != '' ? '-' . $pkg['build'] : ''), $device, 'package');
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
@@ -424,10 +424,10 @@ function rrd_file_rename($device, $oldname, $newname)
|
||||
$newrrd = rrd_name($device['hostname'], $newname);
|
||||
if (is_file($oldrrd) && !is_file($newrrd)) {
|
||||
if (rename($oldrrd, $newrrd)) {
|
||||
log_event("Renamed $oldrrd to $newrrd", $device, "poller");
|
||||
log_event("Renamed $oldrrd to $newrrd", $device, "poller", 1);
|
||||
return true;
|
||||
} else {
|
||||
log_event("Failed to rename $oldrrd to $newrrd", $device, "poller");
|
||||
log_event("Failed to rename $oldrrd to $newrrd", $device, "poller", 5);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -105,7 +105,7 @@ function discover_service($device, $service)
|
||||
{
|
||||
if (! dbFetchCell('SELECT COUNT(service_id) FROM `services` WHERE `service_type`= ? AND `device_id` = ?', array($service, $device['device_id']))) {
|
||||
add_service($device, $service, "(Auto discovered) $service");
|
||||
log_event('Autodiscovered service: type '.mres($service), $device, 'service');
|
||||
log_event('Autodiscovered service: type ' . mres($service), $device, 'service', 2);
|
||||
echo '+';
|
||||
}
|
||||
echo "$service ";
|
||||
|
||||
@@ -8,13 +8,13 @@ if (!$interface) {
|
||||
|
||||
$ifOperStatus = 'down';
|
||||
// $ifAdminStatus = "down";
|
||||
log_event('SNMP Trap: linkDown '.$interface['ifDescr'], $device, 'interface', $interface['port_id']);
|
||||
log_event('SNMP Trap: linkDown ' . $interface['ifDescr'], $device, 'interface', 5, $interface['port_id']);
|
||||
|
||||
// if ($ifAdminStatus != $interface['ifAdminStatus'])
|
||||
// {
|
||||
// log_event("Interface Disabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['port_id']);
|
||||
// }
|
||||
if ($ifOperStatus != $interface['ifOperStatus']) {
|
||||
log_event('Interface went Down : '.$interface['ifDescr'].' (TRAP)', $device, 'interface', $interface['port_id']);
|
||||
log_event('Interface went Down : ' . $interface['ifDescr'] . ' (TRAP)', $device, 'interface', 5, $interface['port_id']);
|
||||
dbUpdate(array('ifOperStatus' => 'down'), 'ports', 'port_id=?', array($interface['port_id']));
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ if (!$interface) {
|
||||
$ifOperStatus = "up";
|
||||
$ifAdminStatus = "up";
|
||||
|
||||
log_event("SNMP Trap: linkUp $ifAdminStatus/$ifOperStatus " . $interface['ifDescr'], $device, "interface", $interface['port_id']);
|
||||
log_event("SNMP Trap: linkUp $ifAdminStatus/$ifOperStatus " . $interface['ifDescr'], $device, "interface", 1, $interface['port_id']);
|
||||
|
||||
if ($ifAdminStatus != $interface['ifAdminStatus']) {
|
||||
log_event("Interface Enabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['port_id']);
|
||||
log_event("Interface Enabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", 3, $interface['port_id']);
|
||||
dbUpdate(array('ifAdminStatus' => 'up'), 'ports', 'port_id=?', array($interface['port_id']));
|
||||
}
|
||||
|
||||
if ($ifOperStatus != $interface['ifOperStatus']) {
|
||||
log_event("Interface went Up : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['port_id']);
|
||||
log_event("Interface went Up : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", 1, $interface['port_id']);
|
||||
dbUpdate(array('ifOperStatus' => 'up'), 'ports', 'port_id=?', array($interface['port_id']));
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `eventlog` ADD COLUMN `severity` INT(1) NULL DEFAULT 2 AFTER `reference`;
|
||||
Reference in New Issue
Block a user