feature: Add description and notes to be used in alerts templates (#4706)

This commit is contained in:
Vitali Kari
2016-10-03 21:31:50 +02:00
committed by Neil Lathwood
parent 715e371002
commit 3680849206
3 changed files with 16 additions and 12 deletions

View File

@@ -443,13 +443,15 @@ function DescribeAlert($alert)
{
$obj = array();
$i = 0;
$device = dbFetchRow('SELECT hostname, sysName, location, uptime FROM devices WHERE device_id = ?', array($alert['device_id']));
$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'];
if (!isset($tpl['template'])) {

View File

@@ -117,6 +117,8 @@ Placeholders:
- Hostname of the Device: `%hostname`
- sysName of the Device: `%sysName`
- location of the Device: `%location`
- description (purpose db field) of the Device: `%description`
- notes of the Device: `%notes`
- Title for the Alert: `%title`
- Time Elapsed, Only available on recovery (`%state == 0`): `%elapsed`
- Alert-ID: `%id`

View File

@@ -69,7 +69,7 @@ foreach ($controls as $control) {
</span><br /><br />
<span><strong>Placeholders:</strong><br />
<?php
$placeholders = array('hostname', 'sysName', 'location', 'title','elapsed','id','uid','faults','state','severity','rule','timestamp','contacts','key','value','new line');
$placeholders = array('hostname', 'sysName', 'location', 'uptime', 'description', 'notes', 'title','elapsed','id','uid','faults','state','severity','rule','timestamp','contacts','key','value','new line');
foreach ($placeholders as $placeholder) {
echo ' <button type="button" class="btn btn-success btn-sm" data-target="#placeholder-add" id="placeholder-add" name="placeholder-add" data-type="placeholder" data-value="'.$placeholder.'">'.$placeholder.'</button>';
}