Commit graph

25 commits

Author SHA1 Message Date
Christian Hesse
18ed12e3f7 netwatch-notify: drop main function, use :do with on-error 2024-03-12 15:27:15 +01:00
Christian Hesse
1e8918fdaa global-functions: $ScriptLock: do not exit from global function 2024-03-12 15:27:15 +01:00
Christian Hesse
3c76738915 netwatch-notify: move code into function 2024-03-04 21:40:34 +01:00
Christian Hesse
64aa6ef124 netwatch-notify: check one after another
This can bring an extra delay, but saves a check in most cases.
2024-03-03 20:32:23 +01:00
Christian Hesse
4869d74edf netwatch-notify: handle IPv6 / AAAA resolving 2024-03-02 22:08:40 +01:00
Christian Hesse
50a6914907 netwatch-notify: (mis-)use firewall address-list for lookup...
... and drop the racy code querying dns cache. 😁
2024-03-01 12:30:18 +01:00
Christian Hesse
a924de274c netwatch-notify: handle CNAME to multiple records 2024-02-28 23:01:43 +01:00
Christian Hesse
6f29c640e4 netwatch-notify: move check in DNS cache to local function 2024-02-28 23:01:43 +01:00
Christian Hesse
01d2c3ea7e netwatch-notify: try another workaround
The last one did not make it... Perhaps the cache just needs
a moment to settle?
2024-02-28 23:01:43 +01:00
Christian Hesse
93bed1b081 netwatch-notify: work around race condition
This used to crash every now and then with:

> script;error script error: no such item (4)

I guess this is caused by querying the dns cache just exactly when a
record expires. The chance is maximized: The script is started by
scheduler every minute, and the record's ttl is a multiple of a minute.

Let's query records that are not about to expire immediately, and
try again.
2024-02-28 23:01:43 +01:00
Christian Hesse
c2f5272f18 netwatch-notify: restore the check 🥴
This reverts commit 28da1da49e.

Chances are that we have to resolve a CNAME, that does not match when
querying the cache.

How to handle CNAME do multiple A records? 🤨
2024-02-28 23:01:43 +01:00
Christian Hesse
45875ad68e netwatch-notify: simplify the check 2024-02-28 23:01:43 +01:00
Christian Hesse
b1199ca50a netwatch-notify: ... and switch state to "unknown" on host update 2024-02-28 23:01:43 +01:00
Christian Hesse
1344694708 netwatch-notify: handle status "down" in its own condition...
... instead of else-branch.

This makes sure to skip hosts that just became "unknown".
(Possible soon!)
2024-02-28 23:01:43 +01:00
Christian Hesse
1c2048628d netwatch-notify: use logical operator, no literal "and"
Just like we do everywhere else.
2024-02-28 23:01:43 +01:00
Christian Hesse
b286cb6803 netwatch-notify: do not update with record in cache
Using `:resolve` we have just one address, but chances are several
records do exist. These end up in cache, so we are happy to find them
there - no need to update then.
2024-02-19 11:03:17 +01:00
Christian Hesse
45fda69d3b netwatch-notify: use :jobname to get script name 2024-01-30 00:52:21 +01:00
Christian Hesse
9a73fc526f update copyright for 2024 2024-01-01 15:25:25 +01:00
Christian Hesse
4321d8fa54 netwatch-notify: match on word boundary 2023-10-27 22:55:40 +02:00
Christian Hesse
eef0662aa7 netwatch-notify: allow to give different origin for hosts...
... to use differing notification settings.

Add an origin name in netwatch configuration:

    /tool/netwatch/add comment="notify, name=dns-google, origin=netwatch-notify-google" address=8.8.8.8;
    /tool/netwatch/add comment="notify, name=dns-cloudflare, origin=netwatch-notify-cloudflare" address=1.1.1.1;

Then configure the notification settings in `global-config-overlay`:

    :global EmailGeneralToOverride {
      "netwatch-notify-google"="google@example.com";
      "netwatch-notify-cloudflare"="cloudflare@example.com";
    }

I think it is best to handle this as a hidden setting...
Handle with care!
2023-09-29 14:15:41 +02:00
Christian Hesse
c04bf2c9b7 netwatch-notify: drop RouterOS version dependency
... as global-functions depend on RouterOS 7.9beta already.
2023-08-18 15:23:20 +02:00
Christian Hesse
6247b739a1 netwatch-notify: drop the delay on startup...
... now that in RouterOS 7.9 netwatch itself comes with a startup-delay.
Hosts in state 'unknown' are just ignored.
2023-06-28 11:29:02 +02:00
Christian Hesse
f416b0e59d netwatch-notify: ignore status 'unknown' 2023-05-31 15:13:14 +02:00
Christian Hesse
650c362ed9 netwatch-notify: support note in notification 2023-03-20 12:35:34 +01:00
Christian Hesse
a832fd04ef rename scripts and add file extension ".rsc"
No functional change for the user... The migration is done
automatically.
2023-03-07 22:26:01 +01:00