mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Added formatted uptime value for alert templates #4983
feature: Added formatted uptime value for alert templates #4983
This commit is contained in:
committed by
Søren Rosiak
parent
a0fec9e574
commit
e934e306fc
18
alerts.php
18
alerts.php
@@ -449,14 +449,16 @@ function DescribeAlert($alert)
|
||||
$device = dbFetchRow('SELECT hostname, sysName, location, purpose, notes, uptime FROM devices WHERE device_id = ?', array($alert['device_id']));
|
||||
$tpl = dbFetchRow('SELECT `template`,`title`,`title_rec` FROM `alert_templates` JOIN `alert_template_map` ON `alert_template_map`.`alert_templates_id`=`alert_templates`.`id` WHERE `alert_template_map`.`alert_rule_id`=?', array($alert['rule_id']));
|
||||
$default_tpl = "%title\r\nSeverity: %severity\r\n{if %state == 0}Time elapsed: %elapsed\r\n{/if}Timestamp: %timestamp\r\nUnique-ID: %uid\r\nRule: {if %name}%name{else}%rule{/if}\r\n{if %faults}Faults:\r\n{foreach %faults} #%key: %value.string\r\n{/foreach}{/if}Alert sent to: {foreach %contacts}%value <%key> {/foreach}";
|
||||
$obj['hostname'] = $device['hostname'];
|
||||
$obj['sysName'] = $device['sysName'];
|
||||
$obj['location'] = $device['location'];
|
||||
$obj['uptime'] = $device['uptime'];
|
||||
$obj['description'] = $device['purpose'];
|
||||
$obj['notes'] = $device['notes'];
|
||||
$obj['device_id'] = $alert['device_id'];
|
||||
$extra = $alert['details'];
|
||||
$obj['hostname'] = $device['hostname'];
|
||||
$obj['sysName'] = $device['sysName'];
|
||||
$obj['location'] = $device['location'];
|
||||
$obj['uptime'] = $device['uptime'];
|
||||
$obj['uptime_short'] = formatUptime($device['uptime'], 'short');
|
||||
$obj['uptime_long'] = formatUptime($device['uptime']);
|
||||
$obj['description'] = $device['purpose'];
|
||||
$obj['notes'] = $device['notes'];
|
||||
$obj['device_id'] = $alert['device_id'];
|
||||
$extra = $alert['details'];
|
||||
if (!isset($tpl['template'])) {
|
||||
$obj['template'] = $default_tpl;
|
||||
} else {
|
||||
|
@@ -118,6 +118,9 @@ Placeholders:
|
||||
- Hostname of the Device: `%hostname`
|
||||
- sysName of the Device: `%sysName`
|
||||
- location of the Device: `%location`
|
||||
- uptime of the Device (in seconds): `%uptime`
|
||||
- short uptime of the Device (28d 22h 30m 7s): `%uptime_short`
|
||||
- long uptime of the Device (28 days, 22h 30m 7s): `%uptime_long`
|
||||
- description (purpose db field) of the Device: `%description`
|
||||
- notes of the Device: `%notes`
|
||||
- Title for the Alert: `%title`
|
||||
|
Reference in New Issue
Block a user