Skip to content

Commit

Permalink
Merge pull request #1093 from f0o/issue-1092
Browse files Browse the repository at this point in the history
Add config-option to exclude SysContact from alerts
  • Loading branch information
laf committed May 20, 2015
2 parents 695edde + fe41295 commit 47e24f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions doc/Extensions/Alerting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions includes/alerts.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
1 change: 1 addition & 0 deletions includes/defaults.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
'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
Expand Down

0 comments on commit 47e24f3

Please sign in to comment.