mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add php docs for log_event, small cleanups (#6141)
* Add php docs for log_event, clean up eventlog_severity a bit. * Update functions.php
This commit is contained in:
committed by
Neil Lathwood
parent
e2962adac8
commit
58495a3910
@@ -1408,30 +1408,24 @@ function array_to_htmljson($data)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $eventlog_severity
|
||||
* @return $eventlog_severity_icon
|
||||
* @param int $eventlog_severity
|
||||
* @return string $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
|
||||
|
||||
|
@@ -823,23 +823,30 @@ function get_astext($asn)
|
||||
}
|
||||
}
|
||||
|
||||
# Use this function to write to the eventlog table
|
||||
/**
|
||||
* Log events to the event table
|
||||
*
|
||||
* @param string $text message describing the event
|
||||
* @param array|int $device device array or device_id
|
||||
* @param string $type brief category for this event. Examples: sensor, state, stp, system, temperature, interface
|
||||
* @param int $severity 1: ok, 2: info, 3: notice, 4: warning, 5: critical, 0: unknown
|
||||
* @param int $reference the id of the referenced entity. Supported types: interface
|
||||
*/
|
||||
function log_event($text, $device = null, $type = null, $severity = 2, $reference = null)
|
||||
{
|
||||
if (!is_array($device)) {
|
||||
$device = device_by_id_cache($device);
|
||||
}
|
||||
|
||||
$username = $_SESSION['username'] ?: '';
|
||||
|
||||
$insert = array('host' => ($device['device_id'] ? $device['device_id'] : 0),
|
||||
'device_id' => ($device['device_id'] ? $device['device_id'] : 0),
|
||||
'reference' => ($reference ? $reference : "NULL"),
|
||||
'type' => ($type ? $type : "NULL"),
|
||||
$insert = array('host' => ($device['device_id'] ?: 0),
|
||||
'device_id' => ($device['device_id'] ?: 0),
|
||||
'reference' => ($reference ?: "NULL"),
|
||||
'type' => ($type ?: "NULL"),
|
||||
'datetime' => array("NOW()"),
|
||||
'severity' => $severity,
|
||||
'message' => $text,
|
||||
'username' => $username);
|
||||
'username' => $_SESSION['username'] ?: '',
|
||||
);
|
||||
|
||||
dbInsert($insert, 'eventlog');
|
||||
}
|
||||
|
Reference in New Issue
Block a user