netwatch-notify: increase count for every parent in chain

This commit is contained in:
Christian Hesse 2020-11-17 22:02:41 +01:00
parent e7855b4611
commit 23923619dd
2 changed files with 5 additions and 2 deletions

View file

@ -46,7 +46,8 @@ suppress notification if the parent host is down:
/ tool netwatch add comment="notify, hostname=gateway" host=93.184.216.1;
/ tool netwatch add comment="notify, hostname=example.com, parent=gateway" host=93.184.216.34;
Note that a configured parent increases the check count threshould by one.
Note that every configured parent in a chain increases the check count
threshould by one.
Also notification settings are required for e-mail and telegram.

View file

@ -50,9 +50,11 @@
:set ($Metric->"since") ($HostVal->"since");
:local Count [ $IfThenElse ([ :tonum ($HostInfo->"count") ] > 0) ($HostInfo->"count") 5 ];
:local Parent ($HostInfo->"parent");
:if ([ :len $Parent ] > 0) do={
:while ([ :len $Parent ] > 0) do={
:set Count ($Count + 1);
:set Parent ($NetwatchNotify->$Parent->"parent");
}
:set Parent ($HostInfo->"parent");
:local ParentNotified false;
:while ($ParentNotified = false && [ :len $Parent ] > 0) do={
:set ParentNotified [ $IfThenElse (($NetwatchNotify->$Parent->"notified") = true) true false ];