Commit graph

443 commits

Author SHA1 Message Date
Christian Hesse 75bd14267e check-health: monitor CPU load
---- ✂️ ----
🧮📈️ Health warning: CPU load

The average CPU load on MikroTik is at 76%!
---- ✂️ ----
🧮📉️ Health recovery: CPU load

The average CPU load on MikroTik decreased to 64%.
---- ✂️ ----
2023-01-20 23:13:27 +01:00
Christian Hesse 2694f8d2b1 global-functions: $RequiredRouterOS: check for valid version string 2023-01-20 11:26:53 +01:00
Christian Hesse 9033e16921 global-functions: use new functionality for version check 2023-01-20 11:26:53 +01:00
Christian Hesse de9dde1b14 global-functions: $ScriptInstallUpdate: add a version check for scripts
New RouterOS releases bring new features, and thus new syntax.
Installing a new script on old RouterOS results in syntax errors. We
want to give clear warning messages, so by adding an extra comment into
the script...

    # requires RouterOS, version=7.8beta3

... installing on unsupported RouterOS version is mitigated.
2023-01-20 11:26:53 +01:00
Christian Hesse b834517baa global-functions: implement $Grep...
... that returns the first line that matches a pattern.
2023-01-20 11:26:53 +01:00
Christian Hesse 23e5c01a42 global-functions: $MkDir: no early continue for dir "tmpfs"...
... as we want a RAM disk.
2023-01-12 23:43:38 +01:00
Christian Hesse f67dc0218b global-functions: $ScriptInstallUpdate: handle config version decrease...
... and log a warning.
2023-01-12 15:40:05 +01:00
Christian Hesse 47a657d25c mod/notification-*: support extra text (or emojis 🚀) in notification tags 2023-01-12 15:40:05 +01:00
Christian Hesse a953a8fa59 mod/notification-email: move $QuotedPrintable (from global-functions)
This is used for e-mail only...
2023-01-11 12:28:31 +01:00
Anatoly Bubenkov ea09a18d3f sms-forward: support hooks 2023-01-10 08:58:33 +01:00
Christian Hesse 2f774f723d update copyright for 2023 2023-01-02 23:49:26 +01:00
Christian Hesse 16bfe4de7e global-functions: $MkDir: create a tmpfs (RAM disk)...
... if the path starts with "tmpfs/". This helps to mitigate flash wear.
2022-12-13 21:50:32 +01:00
Christian Hesse 1579330864 global-functions: $MkDir: create directories recursively 2022-12-13 21:25:07 +01:00
Christian Hesse 58f769ac00 global-functions: $MkDir: rename internal variable 2022-12-13 10:37:56 +01:00
Christian Hesse 446d5c89fc global-functions: $MkDir: fail if non-directory path exists 2022-12-13 10:31:41 +01:00
Christian Hesse 9c42263988 global-functions: check RouterOS version before loading modules 2022-12-12 15:16:36 +01:00
Christian Hesse 7f7c3a7a70 global-functions: $SymbolByUnicodeName: append variation selector-16...
... to specify that the preceding character should be displayed with emoji
presentation.

https://unicode-table.com/en/FE0F/
2022-12-06 16:41:14 +01:00
Christian Hesse 8854d03ea2 global-functions: introduce $IsMacLocallyAdministered...
... and use it in $GetMacVendor.
2022-11-29 17:07:40 +01:00
Christian Hesse ad85f22540 global-functions: $IsTimeSync: no cloud on x86 2022-11-22 22:24:59 +01:00
Christian Hesse ef7360453f global-functions: $IsTimeSync: no cloud with CHR free license 2022-11-22 22:23:51 +01:00
Christian Hesse c2a29da9f2 global-functions: $ScriptLock: use shorter random string
... but with all characters from alphabet with $GetRandom20CharAlNum.
2022-11-22 19:05:29 +01:00
Christian Hesse 3c4595e82b global-functions: $MkDir: use shorter random string
... but with all characters from alphabet with $GetRandom20CharAlNum.
2022-11-22 19:05:02 +01:00
Christian Hesse 10182949ea global-functions: $ScriptInstallUpdate: disable notification only...
... if requested, but keep output and logs.
2022-09-28 09:17:32 +02:00
Christian Hesse b18ca62dbd global-functions: $ScriptInstallUpdate: drop dead code... 2022-09-28 09:17:12 +02:00
Christian Hesse 5120aa096f global-functions: $ScriptInstallUpdate: drop code for permission workaround
This is no longer used as 'netwatch-syslog' is gone.
2022-09-25 22:18:44 +02:00
Christian Hesse bfe2cbf575 drop 'netwatch-syslog'
To filter in firewall you should use something like this:

/ip/firewall/filter/add action=reject chain=output out-interface-list=WAN port=514 protocol=udp reject-with=icmp-admin-prohibited;
/ip/firewall/filter/add action=reject chain=forward out-interface-list=WAN port=514 protocol=udp reject-with=icmp-admin-prohibited;
2022-09-25 22:18:44 +02:00
Christian Hesse eccc187014 introduce 'mod/notification-email', split off from global-functions 2022-09-25 22:10:05 +02:00
Christian Hesse 562c565fcf global-functions: $FlushEmailQueue: do not flush if sending 2022-09-25 18:44:14 +02:00
Christian Hesse 84b5e77860 global-functions: $GetMacVendor: detect locally administered addresses
https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local_(U/L_bit)
2022-09-20 09:30:33 +02:00
Christian Hesse 3f92edb5c1 global-functions: $FlushEmailQueue: use $0 for scheduler name 2022-09-15 22:25:59 +02:00
Christian Hesse f245751339 global-functions: $FlushEmailQueue: do not flush with resolver issues
Flushing the mail queue with resolver issues can flood the log with
messages like:

e-mail;error Error sending e-mail <=?utf-8?Q?[MikroTik] =F0=9F=92=BE=E2=98=81 Cloud backup?=>: DNS resolve failed

Try to avoid this...
2022-09-15 22:03:19 +02:00
Christian Hesse e927c6b08b global-functions: $GetMacVendor: switched to Let's Encrypt (R3)
So let's check for the correct one, and drop the other.
2022-09-13 15:18:28 +02:00
Christian Hesse a1af9577ca global-functions: $ScriptInstallUpdate: prepare for future certificate chain 2022-09-09 14:02:02 +02:00
Christian Hesse 8f32887a1a global-functions: introduce $GetRandom20CharAlNum 2022-09-07 12:28:45 +02:00
Christian Hesse ff0b05ea20 global-functions: $GetRandom20CharHex: add optional parameter for length 2022-09-07 12:22:45 +02:00
Christian Hesse 8f7a0c2a06 global-functions: $SymbolByUnicodeName: add 'earth' 2022-08-25 12:51:07 +02:00
Michael Gisbers 28be6d097d global-functions: $GetRandomNumber: use :rndnum
This is available in RouterOS 7.x...

Signed-off-by: Christian Hesse <mail@eworm.de>
2022-08-05 22:58:55 +02:00
Michael Gisbers 0562198c55 global-functions: $GetRandom20CharHex: use :rndstr
This is available in RouterOS 7.x...

Signed-off-by: Christian Hesse <mail@eworm.de>
2022-08-05 22:58:55 +02:00
Christian Hesse 82f27268b3 global-functions: $IsTimeSync: cache a positive result
The functions do not rely on perfectly synced time. About the right time
is fine, that should make sure certificates are valid and mails are sent
with reasonable headers. So cache the result if system is fine for later
use.
2022-07-21 14:04:44 +02:00
Christian Hesse 329e606b93 global-functions: $IsTimeSync: drop the extra condition...
... as ddns is not required to be enabled. The public address is
available anyway, but not set in DNS.
2022-07-21 14:04:44 +02:00
Christian Hesse ed7b48061a global-functions: $IsTimeSync: drop old code
In RouterOS 7.x the ntp client and server are bundled and unique and
can not be unavailable.
Also it does no longer have a 'last-adjustment' property...
2022-07-21 14:03:11 +02:00
Christian Hesse 518cc24108 global-functions: $IsFullyConnected: remove trailing space 2022-07-21 13:21:51 +02:00
Christian Hesse 9a89cd5407 global-functions: update initialization of empty array
Having the parenthesis here is important for valid syntax!
2022-07-13 11:32:44 +02:00
Christian Hesse a1606402d1 global-config: new setting to disable news and change notifications...
... and also drop the version from global-config and
global-config-overlay.
2022-07-06 21:46:52 +02:00
Christian Hesse 19103cd345 netwatch-notify: rename parameter: hostname -> name
Starting with RouterOS 7.4 the netwatch tool has been extended, it can
now do tcp and http probes. Rename the parameter for reasonable naming
with services.
2022-07-06 11:37:02 +02:00
Christian Hesse eda75f0bbc global-functions: introduce function $PrettyPrint
... to add trailing carriage return when printing to terminal:

[admin@MikroTik] > $PrettyPrint [ $DeviceInfo ]
Hostname:       MikroTik
Board name:     hAP ac^2
Architecture:   arm
Model:          RouterBOARD D52G-5HacD2HnD-TC
Serial number:  8A2A09A221A1
RouterOS:
    Channel:    testing
    Installed:  7.4rc1
RouterOS-Scripts:
    Current:    81
2022-07-05 12:43:57 +02:00
Christian Hesse fcd6e61849 global-functions: $ScriptInstallUpdate: remove script on failure when installing 2022-06-28 21:40:00 +02:00
Christian Hesse d8d7ace5e5 global-functions: introduce function $IsFullyConnected 2022-06-20 11:29:49 +02:00
Christian Hesse b1ad89b1b5 global-functions: rename internal function: $TimeIsSync -> $IsTimeSync 2022-06-20 11:29:49 +02:00
Christian Hesse 9aa82316c8 global-functions: rename internal function: $DNSIsResolving -> $IsDNSResolving 2022-06-20 11:29:49 +02:00