Add config-option to exclude SysContact from alerts

This commit is contained in:
f0o
2015-05-20 16:29:18 +00:00
parent 695edde7bd
commit fe412952c1
3 changed files with 12 additions and 5 deletions

View File

@@ -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. 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. 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. 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: To include users that have `Global-Read` or `Administrator` permissions it is required to add these additions to the `config.php` respectively:
```php ```php
$config['alert']['globals'] = true; //Include Global-Read into alert-contacts $config['alert']['globals'] = true; //Include Global-Read into alert-contacts

View File

@@ -299,12 +299,14 @@ function GetContacts($results) {
} }
} }
if( is_numeric($result["device_id"]) ) { 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" ) { if( $config['alert']['syscontact'] == true ) {
$tmpa = dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_string' AND device_id = ?",array($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" ) {
} else { $tmpa = dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_string' AND device_id = ?",array($result["device_id"]));
$tmpa = dbFetchCell("SELECT sysContact FROM devices WHERE 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"])); $tmpa = dbFetchRows("SELECT user_id FROM devices_perms WHERE access_level >= 0 AND device_id = ?", array($result["device_id"]));
foreach( $tmpa as $tmp ) { foreach( $tmpa as $tmp ) {
$uids[$tmp['user_id']] = $tmp['user_id']; $uids[$tmp['user_id']] = $tmp['user_id'];

View File

@@ -233,6 +233,7 @@ $config['alert'] = array(
'mail' => false, // E-Mail alerting 'mail' => false, // E-Mail alerting
'irc' => false, // IRC Alerting 'irc' => false, // IRC Alerting
), ),
'syscontact' => true, //Issue to SysContact (or it's override)
'globals' => false, //Issue to global-read users 'globals' => false, //Issue to global-read users
'admins' => false, //Issue to administrators 'admins' => false, //Issue to administrators
'default_only' => false, //Only issue to default 'default_only' => false, //Only issue to default