diff --git a/alerts.php b/alerts.php index a72fac5407..ab166a377f 100755 --- a/alerts.php +++ b/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 { diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 2e122bd350..e7e771a6c5 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -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`