From ea5512ffe6ac71a51b553c16cbd1d65debe27a11 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 13 Jun 2016 22:03:17 +0000 Subject: [PATCH 1/2] Added location to be available in alerts template --- alerts.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alerts.php b/alerts.php index 0044dc66d1..4574ae9986 100755 --- a/alerts.php +++ b/alerts.php @@ -455,11 +455,12 @@ function FormatAlertTpl($obj) { function DescribeAlert($alert) { $obj = array(); $i = 0; - $device = dbFetchRow('SELECT hostname, sysName FROM devices WHERE device_id = ?', array($alert['device_id'])); + $device = dbFetchRow('SELECT hostname, sysName, location 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['device_id'] = $alert['device_id']; $extra = $alert['details']; if (!isset($tpl['template'])) { From 1d678642b36f9278dd51f164e8b18dbc4290c31f Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 13 Jun 2016 22:04:51 +0000 Subject: [PATCH 2/2] Updated docs and webui --- doc/Extensions/Alerting.md | 2 ++ html/includes/modal/alert_template.inc.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 173ef51fd7..a549684208 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -111,6 +111,8 @@ Controls: Placeholders: - Hostname of the Device: `%hostname` +- sysName of the Device: `%sysName` +- location of the Device: `%location` - Title for the Alert: `%title` - Time Elapsed, Only available on recovery (`%state == 0`): `%elapsed` - Alert-ID: `%id` diff --git a/html/includes/modal/alert_template.inc.php b/html/includes/modal/alert_template.inc.php index 8e96f3032a..4339e1ad28 100644 --- a/html/includes/modal/alert_template.inc.php +++ b/html/includes/modal/alert_template.inc.php @@ -69,7 +69,7 @@ if(is_admin() === false) {

Placeholders:
'.$placeholder.''; }