netwatch-notify: support dynamic address update
This commit is contained in:
parent
9d19313eee
commit
cfb31e844c
|
@ -52,6 +52,15 @@ suppress notification if the parent host is down:
|
|||
Note that every configured parent in a chain increases the check count
|
||||
threshould by one.
|
||||
|
||||
The host address can be updated dynamically. Give extra parameter `resolve`
|
||||
with a resolvable name:
|
||||
|
||||
/ tool netwatch add comment="notify, hostname=example.com, resolve=example.com";
|
||||
|
||||
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.
|
||||
|
||||
Also notification settings are required for e-mail and telegram.
|
||||
|
||||
Tips & Tricks
|
||||
|
|
|
@ -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 49;
|
||||
:global GlobalConfigVersion 50;
|
||||
|
||||
# This is used for DNS and backup file.
|
||||
:global Domain "example.com";
|
||||
|
|
|
@ -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 49;
|
||||
:global GlobalConfigVersion 50;
|
||||
|
||||
# Copy configuration from global-config here and modify it.
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
47="Removed obsolete intermediate certificate 'Let's Encrypt Authority X3' from store.";
|
||||
48="Added support for overriding e-mail and Telegram settings for every script.";
|
||||
49="Dropped '\$EmailBackupTo' & '\$EmailBackupCc' from configuration, use settings override if required.";
|
||||
50="Added support for dynamic address update in 'netwatch-notify'.";
|
||||
};
|
||||
|
||||
# Migration steps to be applied on script updates
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||
|
||||
# expected configuration version
|
||||
:global ExpectedConfigVersion 49;
|
||||
:global ExpectedConfigVersion 50;
|
||||
|
||||
# global variables not to be changed by user
|
||||
:global GlobalFunctionsReady false;
|
||||
|
|
|
@ -33,6 +33,21 @@
|
|||
:set $Metric ($NetwatchNotify->$HostName);
|
||||
}
|
||||
|
||||
:if ([ :typeof ($HostInfo->"resolve") ] = "str") do={
|
||||
:do {
|
||||
:local Resolve [ :resolve ($HostInfo->"resolve") ];
|
||||
:if ($Resolve != $HostVal->"host") do={
|
||||
$LogPrintExit2 info $0 ("Name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . \
|
||||
"' resolves to different address " . $Resolve . ", updating.") false;
|
||||
/ tool netwatch set host=$Resolve $Host;
|
||||
}
|
||||
} on-error={
|
||||
$LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . "' failed.") false;
|
||||
}
|
||||
}
|
||||
|
||||
:if ($HostVal->"status" = "up") do={
|
||||
:local Count ($Metric->"count");
|
||||
:if ($Count > 0) do={
|
||||
|
|
Loading…
Reference in New Issue