mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Honour new maintenance format (PR#835)
This commit is contained in:
@@ -71,6 +71,22 @@ function GetRules($device) {
|
||||
return dbFetchRows('SELECT alert_rules.* FROM alert_rules LEFT JOIN alert_map ON alert_rules.id=alert_map.rule WHERE alert_rules.disabled = 0 && ( (alert_rules.device_id = -1 || alert_rules.device_id = ? ) || alert_map.target = ? '.$where.' )',$params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device is under maintenance
|
||||
* @param int $device Device-ID
|
||||
* @return bool
|
||||
*/
|
||||
function IsMaintenance( $device ) {
|
||||
$groups = GetGroupsFromDevice($device);
|
||||
$params = array($device);
|
||||
$where = "";
|
||||
foreach( $groups as $group ) {
|
||||
$where .= " || alert_schedule_items.target = ?";
|
||||
$params[] = 'g'.$group;
|
||||
}
|
||||
return dbFetchCell('SELECT DISTINCT(alert_schedule.schedule_id) FROM alert_schedule LEFT JOIN alert_schedule_items ON alert_schedule.schedule_id=alert_schedule_items.schedule_id WHERE alert_schedule_items.target = ?'.$where.' LIMIT 1',$params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all rules for a device
|
||||
* @param int $device Device-ID
|
||||
@@ -78,8 +94,8 @@ function GetRules($device) {
|
||||
*/
|
||||
function RunRules($device) {
|
||||
global $debug;
|
||||
$chk = dbFetchRow("SELECT id FROM alert_schedule WHERE alert_schedule.device_id = ? AND NOW() BETWEEN alert_schedule.start AND alert_schedule.end", array($device));
|
||||
if( $chk['id'] > 0 ) {
|
||||
if( IsMaintenance($device) > 0 ) {
|
||||
echo "Under Maintenance, Skipping alerts.\r\n";
|
||||
return false;
|
||||
}
|
||||
foreach( GetRules($device) as $rule ) {
|
||||
|
Reference in New Issue
Block a user