From fe412952c1df2e683a488892770e992f312a6945 Mon Sep 17 00:00:00 2001 From: f0o Date: Wed, 20 May 2015 16:29:18 +0000 Subject: [PATCH] Add config-option to exclude SysContact from alerts --- doc/Extensions/Alerting.md | 4 ++++ includes/alerts.inc.php | 12 +++++++----- includes/defaults.inc.php | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 1bfba162f..f27fce6c1 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -124,6 +124,10 @@ Transports are located within `$config['install_dir']/includes/alerts/transports Contacts will be gathered automatically and passed to the configured transports. The contacts will always include the `SysContact` defined in the Device's SNMP configuration and also every LibreNMS-User that has at least `read`-permissions on the entity that is to be alerted. At the moment LibreNMS only supports Port or Device permissions. +You can exclude the `SysContact` by setting: +```php +$config['alert']['syscontact'] = false; +``` To include users that have `Global-Read` or `Administrator` permissions it is required to add these additions to the `config.php` respectively: ```php $config['alert']['globals'] = true; //Include Global-Read into alert-contacts diff --git a/includes/alerts.inc.php b/includes/alerts.inc.php index 8392daa19..ea3bf8d49 100644 --- a/includes/alerts.inc.php +++ b/includes/alerts.inc.php @@ -299,12 +299,14 @@ function GetContacts($results) { } } if( is_numeric($result["device_id"]) ) { - if( dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_bool' AND device_id = ?",array($result["device_id"])) === "1" ) { - $tmpa = dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_string' AND device_id = ?",array($result["device_id"])); - } else { - $tmpa = dbFetchCell("SELECT sysContact FROM devices WHERE device_id = ?",array($result["device_id"])); + if( $config['alert']['syscontact'] == true ) { + if( dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_bool' AND device_id = ?",array($result["device_id"])) === "1" ) { + $tmpa = dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_string' AND device_id = ?",array($result["device_id"])); + } else { + $tmpa = dbFetchCell("SELECT sysContact FROM devices WHERE device_id = ?",array($result["device_id"])); + } + $contacts[$tmpa] = "NOC"; } - $contacts[$tmpa] = "NOC"; $tmpa = dbFetchRows("SELECT user_id FROM devices_perms WHERE access_level >= 0 AND device_id = ?", array($result["device_id"])); foreach( $tmpa as $tmp ) { $uids[$tmp['user_id']] = $tmp['user_id']; diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index eeebfd7d1..9710868d7 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -233,6 +233,7 @@ $config['alert'] = array( 'mail' => false, // E-Mail alerting 'irc' => false, // IRC Alerting ), + 'syscontact' => true, //Issue to SysContact (or it's override) 'globals' => false, //Issue to global-read users 'admins' => false, //Issue to administrators 'default_only' => false, //Only issue to default