From 6c14412aa936d24a7a6c124b390bbd95fdc66cd7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 17 Nov 2020 15:03:01 +0100 Subject: netwatch-notify: implemented simple dependency model --- doc/netwatch-notify.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'doc/netwatch-notify.md') diff --git a/doc/netwatch-notify.md b/doc/netwatch-notify.md index 557ae88..66c5c75 100644 --- a/doc/netwatch-notify.md +++ b/doc/netwatch-notify.md @@ -8,8 +8,9 @@ Description This script sends notifications about host UP and DOWN events. In comparison to just netwatch (`/ tool netwatch`) and its `up-script` and `down-script` -this script implements a simple state machine. Host down events are triggered -only if the host is down for several checks to avoid false alerts. +this script implements a simple state machine and dependency model. Host +down events are triggered only if the host is down for several checks and +optional parent host is not down to avoid false alerts. Requirements and installation ----------------------------- @@ -39,6 +40,14 @@ The count threshould (default is 5 checks) is configurable as well: / tool netwatch add comment="notify, hostname=example.com, count=10" host=104.18.144.11; +If the host is behind another checked host add a dependency, this will +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. + Also notification settings are required for e-mail and telegram. --- -- cgit v1.2.3-54-g00ecf From 23923619dd0d92e4af65060e7b51b058fc1842aa Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 17 Nov 2020 22:02:41 +0100 Subject: netwatch-notify: increase count for every parent in chain --- doc/netwatch-notify.md | 3 ++- netwatch-notify | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'doc/netwatch-notify.md') diff --git a/doc/netwatch-notify.md b/doc/netwatch-notify.md index 66c5c75..11371ff 100644 --- a/doc/netwatch-notify.md +++ b/doc/netwatch-notify.md @@ -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. diff --git a/netwatch-notify b/netwatch-notify index 1cfd4a6..9a12c5a 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -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 ]; -- cgit v1.2.3-54-g00ecf