Commit graph

43 commits

Author SHA1 Message Date
Christian Hesse
fefe59751f netwatch-notify: :do ... on-error=... -> :onerror ... do=... 2025-05-22 10:13:52 +02:00
Christian Hesse
5b40380cd2 netwatch-notify: check for global config to be ready 2025-05-08 09:51:08 +02:00
Christian Hesse
446aa3d7ff netwatch-notify: fail if global functions do not become ready 2025-05-08 09:51:07 +02:00
Christian Hesse
0df4170a2e netwatch-notify: use :onerror for outer block 2025-05-08 09:51:07 +02:00
Christian Hesse
b63e0fcb2f netwatch-notify: check matching address type only 2025-03-12 11:26:22 +01:00
Christian Hesse
1555426687 netwatch-notify: increase the timeout even more
This interacts with the number of addresses in the address-list. Having
a lot of addresses there (for exemple from script 'fw-addr-lists' 😜)
makes the 'find' take longer. We have to make sure that 'find' succeeds
before the address times out.

As this does not hurt... Let's just bump to 10 seconds to be safe.
2025-03-12 11:18:18 +01:00
Christian Hesse
97b99316b2 netwatch-notify: increase timeout...
... as a timeout of one second expires immediately. 🤨
2025-03-12 10:31:11 +01:00
Christian Hesse
563aeb8f71 netwatch-notify: use short url rsc.eworm.de 2025-01-29 14:14:27 +01:00
Christian Hesse
9e3729c279 update copyright for 2025 2025-01-02 00:04:06 +01:00
Christian Hesse
bdc15eaefb netwatch-notify: use $ExitError to indicate unintentional error 2024-12-09 11:49:50 +01:00
Christian Hesse
209c37664b netwatch-notify: do not switch type when resolving
This requires RouterOS 7.15beta4, but let's bump the required version
to next stable release instead.
2024-07-25 09:15:41 +02:00
Christian Hesse
6fbafe76ba bump RouterOS requirement for all scripts and modules...
... now that global-functions requires RouterOS 7.14 anyway.
2024-07-16 13:50:22 +02:00
Christian Hesse
63786b7814 netwatch-notify: log to debug...
... instead of discarding the message completely.
2024-04-23 10:44:59 +02:00
Christian Hesse
b0cd53f813 netwatch-notify: allow to suppress resolve failure 2024-04-19 11:25:18 +02:00
Christian Hesse
009674b5bc bump RouterOS requirement for all scripts and modules...
... now that global-functions requires RouterOS 7.13 anyway.
2024-04-07 22:51:24 +02:00
Christian Hesse
6628d9f966 netwatch-notify: pass script name into local functions 2024-03-20 13:59:44 +01:00
Christian Hesse
3d4a14d449 netwatch-notify: pass link to notification
This is pass verbatim below the notification text.
2024-03-13 09:02:04 +01:00
Christian Hesse
030105cc2e netwatch-notify: switch to $LogPrint 2024-03-12 20:37:57 +01:00
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 28da1da49e275fef6089a103edf6c158bbff317f.

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