Add interval extra var on API add_rule and edit_rule (#10814)

This commit is contained in:
joretapoo
2019-11-14 19:46:11 +01:00
committed by Tony Murray
parent 3872de40c7
commit 2fa91fcbe7
2 changed files with 11 additions and 2 deletions

View File

@ -271,6 +271,9 @@ Input (JSON):
- delay: Delay is when to start alerting and how frequently. The value
is stored in seconds but you can specify minutes, hours or days by
doing 5 m, 5 h, 5 d for each one.
- interval: How often to re-issue notifications while this alert is active,0 means notify once.The value
is stored in seconds but you can specify minutes, hours or days by
doing 5 m, 5 h, 5 d for each one.
- mute: If mute is enabled then an alert will never be sent but will
show up in the Web UI (true or false).
- invert: This would invert the rules check.
@ -279,7 +282,7 @@ Input (JSON):
Example:
```curl
curl -X POST -d '{"devices":[1,2,3], "name": "testrule", "builder":{"condition":"AND","rules":[{"id":"devices.hostname","field":"devices.hostname","type":"string","input":"text","operator":"equal","value":"localhost"}],"valid":true},"severity": "critical","count":15,"delay":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
curl -X POST -d '{"devices":[1,2,3], "name": "testrule", "builder":{"condition":"AND","rules":[{"id":"devices.hostname","field":"devices.hostname","type":"string","input":"text","operator":"equal","value":"localhost"}],"valid":true},"severity": "critical","count":15,"delay":"5 m","interval":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
```
Output:
@ -312,6 +315,9 @@ Input (JSON):
- delay: Delay is when to start alerting and how frequently. The value
is stored in seconds but you can specify minutes, hours or days by
doing 5 m, 5 h, 5 d for each one.
- interval: How often to re-issue notifications while this alert is active,0 means notify once.The value
is stored in seconds but you can specify minutes, hours or days by
doing 5 m, 5 h, 5 d for each one.
- mute: If mute is enabled then an alert will never be sent but will
show up in the Web UI (true or false).
- invert: This would invert the rules check.
@ -320,7 +326,7 @@ Input (JSON):
Example:
```curl
curl -X PUT -d '{"rule_id":1,"device_id":"-1", "name": "testrule", "builder":"{"condition":"AND","rules":[{"id":"devices.hostname","field":"devices.hostname","type":"string","input":"text","operator":"equal","value":"localhost"}],"valid":true}","severity": "critical","count":15,"delay":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
curl -X PUT -d '{"rule_id":1,"device_id":"-1", "name": "testrule", "builder":"{"condition":"AND","rules":[{"id":"devices.hostname","field":"devices.hostname","type":"string","input":"text","operator":"equal","value":"localhost"}],"valid":true}","severity": "critical","count":15,"delay":"5 m","interval":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
```
Output:

View File

@ -1040,9 +1040,11 @@ function add_edit_rule(\Illuminate\Http\Request $request)
$count = $data['count'];
$mute = $data['mute'];
$delay = $data['delay'];
$interval = $data['interval'];
$override_query = $data['override_query'];
$adv_query = $data['adv_query'];
$delay_sec = convert_delay($delay);
$interval_sec = convert_delay($interval);
if ($mute == 1) {
$mute = true;
} else {
@ -1053,6 +1055,7 @@ function add_edit_rule(\Illuminate\Http\Request $request)
'mute' => $mute,
'count' => $count,
'delay' => $delay_sec,
'interval' => $interval_sec,
'options' =>
[
'override_query' => $override_query