mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
"Disable alerting" on device disables alert rules check (not just alert transport) (#11015)
* Fix disable notify * Fix disable notify * Disable all alerting * fix db migration * fix db migration * fix db migration * Add autoclearing active alerts if disable alerting set * Add autoclearing active alerts if disable alerting set * fix check * Device in gray if disable_notify is set - not ignore tag
This commit is contained in:
@@ -44,7 +44,16 @@ class AlertRules
|
||||
|
||||
//Check to see if under maintenance
|
||||
if (AlertUtil::isMaintenance($device_id) > 0) {
|
||||
echo "Under Maintenance, Skipping alerts.\r\n";
|
||||
echo "Under Maintenance, skipping alert rules check.\r\n";
|
||||
return false;
|
||||
}
|
||||
//Check to see if disable alerting is set
|
||||
if (AlertUtil::hasDisableNotify($device_id)) {
|
||||
echo "Disable alerting is set, Clearing active alerts and skipping alert rules check\r\n";
|
||||
$device_alert['state'] = 0;
|
||||
$device_alert['alerted'] = 0;
|
||||
$device_alert['open'] = 0;
|
||||
dbUpdate($device_alert, 'alerts', '`device_id` = ?', array($device_id));
|
||||
return false;
|
||||
}
|
||||
//Checks each rule.
|
||||
|
@@ -195,6 +195,17 @@ class AlertUtil
|
||||
return !is_null($device) && $device->isUnderMaintenance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device is set to ignore alerts
|
||||
* @param int $device_id Device-ID
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasDisableNotify($device_id)
|
||||
{
|
||||
$device = Device::find($device_id);
|
||||
return !is_null($device) && $device->disable_notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Macros
|
||||
* @param string $rule Rule to process
|
||||
|
@@ -260,10 +260,6 @@ class RunAlerts
|
||||
*/
|
||||
public function issueAlert($alert)
|
||||
{
|
||||
if (dbFetchCell('SELECT attrib_value FROM devices_attribs WHERE attrib_type = "disable_notify" && device_id = ?', array($alert['device_id'])) == '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config::get('alert.fixed-contacts') == false) {
|
||||
if (empty($alert['query'])) {
|
||||
$alert['query'] = AlertDB::genSQL($alert['rule'], $alert['builder']);
|
||||
|
Reference in New Issue
Block a user