feature: Added formatted uptime value for alert templates #4983

feature: Added formatted uptime value for alert templates #4983
This commit is contained in:
Neil Lathwood
2016-11-15 20:11:12 +00:00
committed by Søren Rosiak
parent a0fec9e574
commit e934e306fc
2 changed files with 13 additions and 8 deletions

View File

@@ -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 {