aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-07-05 13:41:35 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-07-06 11:37:02 +0200
commita7c94445454642ce57be4da9693f914da5d05c1a (patch)
treeaeed680a98a31ed0fc9ff350187605e5614269cc
parent19103cd3451a9a5a6be6faa8c2745754ddc40606 (diff)
netwatch-notify: rename variable: $HostName -> $Name
-rw-r--r--netwatch-notify26
1 files changed, 13 insertions, 13 deletions
diff --git a/netwatch-notify b/netwatch-notify
index e1c8e43..e3f0633 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -59,11 +59,11 @@ $ScriptLock $0;
:local HostInfo [ $ParseKeyValueStore ($HostVal->"comment") ];
:if ($HostInfo->"notify" = true && $HostInfo->"disabled" != true) do={
- :local HostName ($HostInfo->"name");
+ :local Name ($HostInfo->"name");
:local Metric { "count"=0; "notified"=false };
- :if ([ :typeof ($NetwatchNotify->$HostName) ] = "array") do={
- :set $Metric ($NetwatchNotify->$HostName);
+ :if ([ :typeof ($NetwatchNotify->$Name) ] = "array") do={
+ :set $Metric ($NetwatchNotify->$Name);
}
:if ([ :typeof ($HostInfo->"resolve") ] = "str") do={
@@ -90,17 +90,17 @@ $ScriptLock $0;
:if ($HostVal->"status" = "up") do={
:local Count ($Metric->"count");
:if ($Count > 0) do={
- $LogPrintExit2 info $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is up.") false;
+ $LogPrintExit2 info $0 ("Host " . $Name . " (" . $HostVal->"host" . ") is up.") false;
:set ($Metric->"count") 0;
}
:if ($Metric->"notified" = true) do={
- :local Message ("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \
+ :local Message ("Host " . $Name . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \
"It was down for " . $Count . " checks since " . ($Metric->"since") . ".");
:if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={
- :set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $HostName "up" ($HostInfo->"up-hook") ]);
+ :set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $Name "up" ($HostInfo->"up-hook") ]);
}
$SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Netwatch Notify: " . $HostName . " up"); \
+ subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Netwatch Notify: " . $Name . " up"); \
message=$Message });
}
:set ($Metric->"notified") false;
@@ -125,26 +125,26 @@ $ScriptLock $0;
}
}
$LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \
- ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . $Metric->"count" . " checks, " . \
+ ("Host " . $Name . " (" . $HostVal->"host" . ") is down for " . $Metric->"count" . " checks, " . \
[ $IfThenElse ($ParentNotified = false) [ $IfThenElse ($Metric->"notified" = true) ("already notified.") \
($Count - $Metric->"count" . " to go.") ] ("parent host " . $Parent . " is down.") ]) false;
:if ((($Count * 2) - ($Metric->"count" * 3)) / 2 = 0 && [ :typeof ($HostInfo->"pre-down-hook") ] = "str") do={
- $NetwatchNotifyHook $HostName "pre-down" ($HostInfo->"pre-down-hook");
+ $NetwatchNotifyHook $Name "pre-down" ($HostInfo->"pre-down-hook");
}
:if ($ParentNotified = false && $Metric->"count" >= $Count && $Metric->"notified" != true) do={
- :local Message ("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
+ :local Message ("Host " . $Name . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
- :set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $HostName "down" ($HostInfo->"down-hook") ]);
+ :set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $Name "down" ($HostInfo->"down-hook") ]);
}
:if ($HostInfo->"no-down-notification" != true) do={
$SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \
+ subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $Name . " down"); \
message=$Message });
}
:set ($Metric->"notified") true;
}
}
- :set ($NetwatchNotify->$HostName) {
+ :set ($NetwatchNotify->$Name) {
"count"=($Metric->"count");
"notified"=($Metric->"notified");
"parent"=($Metric->"parent");