Honour 'Disable all alerting for this host'

Fixes some redundancy in macros (parentesis)
This commit is contained in:
f0o
2015-05-18 10:23:25 +00:00
parent b8b9ef7abe
commit 4c10cb625b
3 changed files with 12 additions and 7 deletions

View File

@@ -84,6 +84,9 @@ function IsRuleValid($device,$rule) {
*/
function IssueAlert($alert) {
global $config;
if( dbFetchCell('SELECT attrib_value FROM devices_attribs WHERE attrib_type = "disable_notify" && device_id = ?',array($alert['device_id'])) == "1" ) {
return true;
}
$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}"; //FIXME: Put somewhere else?
$obj = DescribeAlert($alert);
if( is_array($obj) ) {
@@ -101,6 +104,7 @@ function IssueAlert($alert) {
}
echo "\r\n";
}
return true;
}
/**
@@ -312,6 +316,7 @@ function DescribeAlert($alert) {
$i = 0;
$device = dbFetchRow("SELECT hostname FROM devices WHERE device_id = ?",array($alert['device_id']));
$obj['hostname'] = $device['hostname'];
$obj['device_id'] = $alert['device_id'];
$extra = $alert['details'];
if( $alert['state'] >= 1 ) {
$obj['title'] = 'Alert for device '.$device['hostname'].' Alert-ID #'.$alert['id'];