mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Add description and notes to be used in alerts templates (#4706)
This commit is contained in:
committed by
Neil Lathwood
parent
715e371002
commit
3680849206
@@ -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'])) {
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user