aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/netwatch-notify.md10
-rw-r--r--global-config2
-rw-r--r--global-config-overlay2
-rw-r--r--global-config.changes1
-rw-r--r--global-functions2
-rw-r--r--netwatch-notify16
6 files changed, 23 insertions, 10 deletions
diff --git a/doc/netwatch-notify.md b/doc/netwatch-notify.md
index 9b504f7..dc107f2 100644
--- a/doc/netwatch-notify.md
+++ b/doc/netwatch-notify.md
@@ -78,6 +78,16 @@ But be warned: Dynamic updates will probably cause issues if the name has
more than one record in dns - a high rate of configuration changes (and flash
writes) at least.
+### No notification on host down
+
+Also suppressing the notification on host down is possible with parameter
+`no-down-notification`. This may be desired for devices that are usually
+powered off, but accessibility is of interest.
+
+ / tool netwatch add comment="notify, hostname=printer, no-down-notification" host=10.0.0.30;
+
+Go and get your coffee ☕️ before sending the print job.
+
Also notification settings are required for e-mail, matrix and/or telegram.
Tips & Tricks
diff --git a/global-config b/global-config
index 454e5bf..37a60e8 100644
--- a/global-config
+++ b/global-config
@@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
-:global GlobalConfigVersion 75;
+:global GlobalConfigVersion 76;
# This is used for DNS and backup file.
:global Domain "example.com";
diff --git a/global-config-overlay b/global-config-overlay
index 562d7b5..8e1a664 100644
--- a/global-config-overlay
+++ b/global-config-overlay
@@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
# Comment or remove to disable news and change notifications.
-:global GlobalConfigVersion 75;
+:global GlobalConfigVersion 76;
# Copy configuration from global-config here and modify it.
diff --git a/global-config.changes b/global-config.changes
index d1058e4..271d232 100644
--- a/global-config.changes
+++ b/global-config.changes
@@ -84,6 +84,7 @@
75=("Finally merged the RouterOS v7 code into the main branch. " . [ $IfThenElse ([ $RequiredRouterOS "global-config.changes" "7.0" false ] = true) \
("You may now drop '\$ScriptUpdatesUrlSuffix' from 'global-config-overlay'.") \
("Still running RouterOS v6, so last reminder to see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6") ]);
+ 76="Added an option to suppress notifications on host down with 'netwatch-notify'.";
};
# Migration steps to be applied on script updates
diff --git a/global-functions b/global-functions
index a9b409b..0bdbb48 100644
--- a/global-functions
+++ b/global-functions
@@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
-:global ExpectedConfigVersion 75;
+:global ExpectedConfigVersion 76;
# global variables not to be changed by user
:global GlobalFunctionsReady false;
diff --git a/netwatch-notify b/netwatch-notify
index ae89cfb..e82cea6 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -122,10 +122,10 @@ $ScriptLock $0;
:set Parent ($NetwatchNotify->$Parent->"parent");
}
}
- $LogPrintExit2 info $0 ("Host " . $HostName . " (" . $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;
+ $LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \
+ ("Host " . $HostName . " (" . $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");
}
@@ -134,9 +134,11 @@ $ScriptLock $0;
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
:set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $HostName "down" ($HostInfo->"down-hook") ]);
}
- $SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \
- message=$Message });
+ :if ($HostInfo->"no-down-notification" != true) do={
+ $SendNotification2 ({ origin=$0; \
+ subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \
+ message=$Message });
+ }
:set ($Metric->"notified") true;
}
}