aboutsummaryrefslogtreecommitdiffstats
path: root/netwatch-notify
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-09-07 08:53:11 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-09-07 11:21:15 +0200
commita7f8aa95d0bb676e47023cd8afecbf8dafcec176 (patch)
treeba87cb930ef505f07dccaa1824379ac5db8ea52b /netwatch-notify
parente820323e7836f4f258b4af8af4e49f3d088bc18e (diff)
netwatch-notify: show dns name (resolve option) in message
Diffstat (limited to 'netwatch-notify')
-rw-r--r--netwatch-notify12
1 files changed, 7 insertions, 5 deletions
diff --git a/netwatch-notify b/netwatch-notify
index 3b84a06..305baba 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -63,6 +63,8 @@ $ScriptLock $0;
:local HostVal [ /tool/netwatch/get $Host ];
:local Type [ $IfThenElse ($HostVal->"type" ~ "^(http-get|tcp-conn)\$") "service" "host" ];
:local HostInfo [ $ParseKeyValueStore ($HostVal->"comment") ];
+ :local HostDetails ($HostVal->"host" . \
+ [ $IfThenElse ([ :len ($HostInfo->"resolve") ] > 0) (", " . $HostInfo->"resolve") ]);
:if ($HostInfo->"notify" = true && $HostInfo->"disabled" != true) do={
:local Name [ $EitherOr ($HostInfo->"name") ($HostVal->"name") ];
@@ -98,12 +100,12 @@ $ScriptLock $0;
:if ($HostVal->"status" = "up") do={
:local Count ($Metric->"count");
:if ($Count > 0) do={
- $LogPrintExit2 info $0 ("The " . $Type . " '" . $Name . "' (" . $HostVal->"host" . \
- ") is up.") false;
+ $LogPrintExit2 info $0 \
+ ("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is up.") false;
:set ($Metric->"count") 0;
}
:if ($Metric->"notified" = true) do={
- :local Message ("The " . $Type . " '" . $Name . "' (" . $HostVal->"host" . \
+ :local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \
") is up since " . $HostVal->"since" . ".\n" . \
"It was down for " . $Count . " checks since " . ($Metric->"since") . ".");
:if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={
@@ -138,7 +140,7 @@ $ScriptLock $0;
}
}
$LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \
- ("The " . $Type . " '" . $Name . "' (" . $HostVal->"host" . ") is down for " . \
+ ("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is down for " . \
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . \
" to go.") ] ("parent " . $Type . " " . $Parent . " is down.") ]) false;
@@ -148,7 +150,7 @@ $ScriptLock $0;
}
:if ($ParentNotified = false && $Metric->"count" >= $Count && \
$Metric->"notified" != true) do={
- :local Message ("The " . $Type . " '" . $Name . "' (" . $HostVal->"host" . \
+ :local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \
") is down since " . $HostVal->"since" . ".");
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
:set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $Name $Type "down" \