mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
Merge branch 'routeros-v7' into next
This commit is contained in:
commit
db4afe28f0
11 changed files with 83 additions and 82 deletions
21
README.md
21
README.md
|
@ -118,30 +118,15 @@ to be updated automatically!
|
||||||
|
|
||||||
### Changes for RouterOS v6
|
### Changes for RouterOS v6
|
||||||
|
|
||||||
RouterOS v6 will become deprecated at some time in the future, but to date
|
RouterOS v7 is the way to go, let's consider RouterOS v6 deprecated.
|
||||||
it is still the default for these scripts (in branch `main`). This will
|
If you want to stay with RouterOS v6 for some time add these lines
|
||||||
change however, so if you want to stay with RouterOS v6 for some time add
|
to your `global-config-overlay`, if missing:
|
||||||
these lines to your `global-config-overlay`, if missing:
|
|
||||||
|
|
||||||
# Use branch routeros-v6 with RouterOS v6:
|
# Use branch routeros-v6 with RouterOS v6:
|
||||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
||||||
|
|
||||||
Then reload the configuration.
|
Then reload the configuration.
|
||||||
|
|
||||||
### Changes for RouterOS v7
|
|
||||||
|
|
||||||
RouterOS v7 is developed in paralled to RouterOS v6. The former brings some
|
|
||||||
shiny new features, the latter provides proven stability.
|
|
||||||
|
|
||||||
The changes require incompatible changes to scripts, so these changes go to
|
|
||||||
a separate branch. If you decide to run RouterOS v7 please switch to branch
|
|
||||||
`routeros-v7` by adding these lines to your `global-config-overlay`:
|
|
||||||
|
|
||||||
# Use branch routeros-v7 with RouterOS v7:
|
|
||||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v7";
|
|
||||||
|
|
||||||
Then reload the configuration and continue below to update scripts.
|
|
||||||
|
|
||||||
Updating scripts
|
Updating scripts
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ $WaitFullyConnected;
|
||||||
|
|
||||||
# create configuration export
|
# create configuration export
|
||||||
:if ($BackupSendExport = true) do={
|
:if ($BackupSendExport = true) do={
|
||||||
/ export terse file=$FilePath;
|
/ export terse show-sensitive file=$FilePath;
|
||||||
$WaitForFile ($FilePath . ".rsc");
|
$WaitForFile ($FilePath . ".rsc");
|
||||||
:set ConfigFile ($FileName . ".rsc");
|
:set ConfigFile ($FileName . ".rsc");
|
||||||
:set Attach ($Attach, ($FilePath . ".rsc"));
|
:set Attach ($Attach, ($FilePath . ".rsc"));
|
||||||
|
|
|
@ -76,7 +76,7 @@ $WaitFullyConnected;
|
||||||
|
|
||||||
# create configuration export
|
# create configuration export
|
||||||
:if ($BackupSendExport = true) do={
|
:if ($BackupSendExport = true) do={
|
||||||
/ export terse file=$FilePath;
|
/ export terse show-sensitive file=$FilePath;
|
||||||
$WaitForFile ($FilePath . ".rsc");
|
$WaitForFile ($FilePath . ".rsc");
|
||||||
|
|
||||||
:do {
|
:do {
|
||||||
|
|
88
check-health
88
check-health
|
@ -24,98 +24,108 @@
|
||||||
:global SendNotification2;
|
:global SendNotification2;
|
||||||
:global SymbolForNotification;
|
:global SymbolForNotification;
|
||||||
|
|
||||||
:local FormatVoltage do={
|
:local TempToNum do={
|
||||||
:local Voltage [ :tonum $1 ];
|
:global CharacterReplace;
|
||||||
:return (($Voltage / 10) . "." . [ :pick $Voltage ([ :len $Voltage ] - 1) ] . "V");
|
:local T [ :toarray [ $CharacterReplace $1 "." "," ] ];
|
||||||
|
:return ($T->0 * 10 + $T->1);
|
||||||
}
|
}
|
||||||
|
|
||||||
:local CheckHealthCurrent [ / system health get ];
|
:if ([ :len [ / system health find ] ] = 0) do={
|
||||||
|
|
||||||
:if ([ :len $CheckHealthCurrent ] = 0) do={
|
|
||||||
$LogPrintExit2 error $0 ("Your device does not provide any health values.") true;
|
$LogPrintExit2 error $0 ("Your device does not provide any health values.") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:if ([ :typeof $CheckHealthLast ] != "array") do={
|
||||||
|
:set CheckHealthLast [ :toarray "" ];
|
||||||
|
}
|
||||||
:if ([ :typeof $CheckHealthTemperatureNotified ] != "array") do={
|
:if ([ :typeof $CheckHealthTemperatureNotified ] != "array") do={
|
||||||
:set CheckHealthTemperatureNotified [ :toarray "" ];
|
:set CheckHealthTemperatureNotified [ :toarray "" ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $0;
|
||||||
|
|
||||||
:foreach Name,Voltage in=$CheckHealthCurrent do={
|
:foreach Voltage in=[ / system health find where type="V" ] do={
|
||||||
:if ($Name ~ "(battery|voltage)" && \
|
:local Name [ / system health get $Voltage name ];
|
||||||
[ :typeof ($CheckHealthLast->$Name) ] = "num" && \
|
:local Value [ / system health get $Voltage value ];
|
||||||
[ :typeof $Voltage ] = "num") do={
|
|
||||||
:if ($CheckHealthLast->$Name * (100 + $CheckHealthVoltagePercent) < $Voltage * 100 || \
|
:if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
|
||||||
$CheckHealthLast->$Name * 100 > $Voltage * (100 + $CheckHealthVoltagePercent)) do={
|
:local NumCurr [ $TempToNum $Value ];
|
||||||
|
:local NumLast [ $TempToNum ($CheckHealthLast->$Name) ];
|
||||||
|
|
||||||
|
:if ($NumLast * (100 + $CheckHealthVoltagePercent) < $NumCurr * 100 || \
|
||||||
|
$NumLast * 100 > $NumCurr * (100 + $CheckHealthVoltagePercent)) do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($CheckHealthLast->$Name < \
|
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
|
||||||
$Voltage) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
|
$NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
|
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
|
||||||
"old value: " . [ $FormatVoltage ($CheckHealthLast->$Name) ] . "\n" . \
|
"old value: " . ($CheckHealthLast->$Name) . " V\n" . \
|
||||||
"new value: " . [ $FormatVoltage $Voltage ]) });
|
"new value: " . $Value . " V") });
|
||||||
} else={
|
} else={
|
||||||
:if ($Voltage <= $CheckHealthVoltageLow && $CheckHealthLast->$Name > $CheckHealthVoltageLow) do={
|
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "high-voltage-sign,chart-decreasing" ] . "Health warning: Low " . $Name); \
|
subject=([ $SymbolForNotification "high-voltage-sign,chart-decreasing" ] . "Health warning: Low " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " dropped to " . [ $FormatVoltage $Voltage ] . " below hard limit.") });
|
message=("The " . $Name . " on " . $Identity . " dropped to " . $Value . " V below hard limit.") });
|
||||||
}
|
}
|
||||||
:if ($Voltage > $CheckHealthVoltageLow && $CheckHealthLast->$Name <= $CheckHealthVoltageLow) do={
|
:if ($NumCurr > $CheckHealthVoltageLow && $NumLast <= $CheckHealthVoltageLow) do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "high-voltage-sign,chart-increasing" ] . "Health recovery: Low " . $Name); \
|
subject=([ $SymbolForNotification "high-voltage-sign,chart-increasing" ] . "Health recovery: Low " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " recovered to " . [ $FormatVoltage $Voltage ] . " above hard limit.") });
|
message=("The " . $Name . " on " . $Identity . " recovered to " . $Value . " V above hard limit.") });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
:set ($CheckHealthLast->$Name) $Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Name,PSU in=$CheckHealthCurrent do={
|
:foreach PSU in=[ / system health find where name~"^psu.*-state\$" ] do={
|
||||||
:if ($Name ~ "psu.*-state" && \
|
:local Name [ / system health get $PSU name ];
|
||||||
[ :typeof ($CheckHealthLast->$Name) ] = "str" && \
|
:local Value [ / system health get $PSU value ];
|
||||||
[ :typeof $PSU ] = "str") do={
|
|
||||||
|
:if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
|
||||||
:if ($CheckHealthLast->$Name = "ok" && \
|
:if ($CheckHealthLast->$Name = "ok" && \
|
||||||
$PSU != "ok") do={
|
$Value != "ok") do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
|
subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
|
||||||
message=("The power supply unit '" . $Name . "' on " . $Identity . " failed!") });
|
message=("The power supply unit '" . $Name . "' on " . $Identity . " failed!") });
|
||||||
}
|
}
|
||||||
:if ($CheckHealthLast->$Name != "ok" && \
|
:if ($CheckHealthLast->$Name != "ok" && \
|
||||||
$PSU = "ok") do={
|
$Value = "ok") do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
||||||
message=("The power supply unit '" . $Name . "' on " . $Identity . " recovered!") });
|
message=("The power supply unit '" . $Name . "' on " . $Identity . " recovered!") });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
:set ($CheckHealthLast->$Name) $Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Name,Temperature in=$CheckHealthCurrent do={
|
:foreach Temperature in=[ / system health find where type="C" ] do={
|
||||||
:if ($Name ~ "temperature" && \
|
:local Name [ / system health get $Temperature name ];
|
||||||
[ :typeof $Temperature ] = "num") do={
|
:local Value [ / system health get $Temperature value ];
|
||||||
|
|
||||||
|
:if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
|
||||||
:if ([ :typeof ($CheckHealthTemperature->$Name) ] != "num" ) do={
|
:if ([ :typeof ($CheckHealthTemperature->$Name) ] != "num" ) do={
|
||||||
$LogPrintExit2 info $0 ("No threshold given for " . $Name . ", assuming 50C.") false;
|
$LogPrintExit2 info $0 ("No threshold given for " . $Name . ", assuming 50C.") false;
|
||||||
:set ($CheckHealthTemperature->$Name) 50;
|
:set ($CheckHealthTemperature->$Name) 50;
|
||||||
}
|
}
|
||||||
:local Validate [ / system health get $Name ];
|
:local Validate [ / system health get [ find where name=$Name ] value ];
|
||||||
:while ($Temperature != $Validate) do={
|
:while ($Value != $Validate) do={
|
||||||
:set Temperature $Validate;
|
:set Value $Validate;
|
||||||
:set Validate [ / system health get $Name ];
|
:set Validate [ / system health get [ find where name=$Name ] value ];
|
||||||
}
|
}
|
||||||
:if ($Temperature > $CheckHealthTemperature->$Name && \
|
:if ($Value > $CheckHealthTemperature->$Name && \
|
||||||
$CheckHealthTemperatureNotified->$Name != true) do={
|
$CheckHealthTemperatureNotified->$Name != true) do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "fire" ] . "Health warning: " . $Name); \
|
subject=([ $SymbolForNotification "fire" ] . "Health warning: " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " is above threshold: " . \
|
message=("The " . $Name . " on " . $Identity . " is above threshold: " . \
|
||||||
$Temperature . "\C2\B0" . "C") });
|
$Value . "\C2\B0" . "C") });
|
||||||
:set ($CheckHealthTemperatureNotified->$Name) true;
|
:set ($CheckHealthTemperatureNotified->$Name) true;
|
||||||
}
|
}
|
||||||
:if ($Temperature <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
|
:if ($Value <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
|
||||||
$CheckHealthTemperatureNotified->$Name = true) do={
|
$CheckHealthTemperatureNotified->$Name = true) do={
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " dropped below threshold: " . \
|
message=("The " . $Name . " on " . $Identity . " dropped below threshold: " . \
|
||||||
$Temperature . "\C2\B0" . "C") });
|
$Value . "\C2\B0" . "C") });
|
||||||
:set ($CheckHealthTemperatureNotified->$Name) false;
|
:set ($CheckHealthTemperatureNotified->$Name) false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
:set ($CheckHealthLast->$Name) $Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
:set CheckHealthLast $CheckHealthCurrent;
|
|
||||||
|
|
|
@ -32,11 +32,9 @@ place the required packages to CAPsMAN package path (see
|
||||||
function `$DownloadPackage`, use something like this to download latest
|
function `$DownloadPackage`, use something like this to download latest
|
||||||
packages to directory `routeros`:
|
packages to directory `routeros`:
|
||||||
|
|
||||||
$DownloadPackage system "" arm routeros;
|
$DownloadPackage routeros "" arm routeros;
|
||||||
$DownloadPackage security "" arm routeros;
|
$DownloadPackage routeros "" arm64 routeros;
|
||||||
[...]
|
$DownloadPackage routeros "" mipsbe routeros;
|
||||||
$DownloadPackage system "" mipsbe routeros;
|
|
||||||
$DownloadPackage security "" mipsbe routeros;
|
|
||||||
[...]
|
[...]
|
||||||
|
|
||||||
Usage and invocation
|
Usage and invocation
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
:global GlobalConfigVersion 74;
|
:global GlobalConfigVersion 75;
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
|
@ -159,14 +159,11 @@
|
||||||
# alternative urls - main: stable code - next: currently in development
|
# alternative urls - main: stable code - next: currently in development
|
||||||
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/main/";
|
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/main/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/next/";
|
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/next/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/routeros-v7/";
|
|
||||||
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/main/";
|
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/main/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/next/";
|
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/next/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/routeros-v7/";
|
|
||||||
:global ScriptUpdatesUrlSuffix "";
|
:global ScriptUpdatesUrlSuffix "";
|
||||||
# use next or routeros-v7 branch with default url (git.eworm.de)
|
# use next branch with default url (git.eworm.de)
|
||||||
#:global ScriptUpdatesUrlSuffix "\?h=next";
|
#:global ScriptUpdatesUrlSuffix "\?h=next";
|
||||||
#:global ScriptUpdatesUrlSuffix "\?h=routeros-v7";
|
|
||||||
|
|
||||||
# Use this for defaults with $ScriptRunOnce
|
# Use this for defaults with $ScriptRunOnce
|
||||||
# Install module with:
|
# Install module with:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
# Comment or remove to disable news and change notifications.
|
# Comment or remove to disable news and change notifications.
|
||||||
:global GlobalConfigVersion 74;
|
:global GlobalConfigVersion 75;
|
||||||
|
|
||||||
# Copy configuration from global-config here and modify it.
|
# Copy configuration from global-config here and modify it.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
# Copyright (c) 2019-2022 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2019-2022 Christian Hesse <mail@eworm.de>
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
||||||
|
|
||||||
|
:global IfThenElse;
|
||||||
|
:global RequiredRouterOS;
|
||||||
|
|
||||||
# Changes for global-config to be added to notification on script updates
|
# Changes for global-config to be added to notification on script updates
|
||||||
:global GlobalConfigChanges {
|
:global GlobalConfigChanges {
|
||||||
1="Moved variables from 'global-config' to 'global-functions' for independence";
|
1="Moved variables from 'global-config' to 'global-functions' for independence";
|
||||||
|
@ -73,11 +76,14 @@
|
||||||
67="Moved modules to directory with shorter name.";
|
67="Moved modules to directory with shorter name.";
|
||||||
68="Reintroduced 'global-wait' for functions in scheduler.";
|
68="Reintroduced 'global-wait' for functions in scheduler.";
|
||||||
69="Support hard lower limit for voltage in 'check-health'.";
|
69="Support hard lower limit for voltage in 'check-health'.";
|
||||||
70="MikroTik started pushing RouterOS v7. Changes are required if you run it, see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v7";
|
70="MikroTik started pushing RouterOS v7. Changes are no longer required.";
|
||||||
71="MikroTik is pushing RouterOS v7 even more, in parallel branches. If you want to keep RouterOS v6 for some time see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6";
|
71="MikroTik is pushing RouterOS v7 even more, in parallel branches. If you want to keep RouterOS v6 for some time see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6";
|
||||||
72="Introduced new script 'netwatch-dns' to manage DNS and DoH servers from netwatch.";
|
72="Introduced new script 'netwatch-dns' to manage DNS and DoH servers from netwatch.";
|
||||||
73="Renamed backup scripts ('cloud-backup' -> 'backup-cloud', 'email-backup' -> 'backup-email', 'upload-backup' -> 'backup-upload').";
|
73="Renamed backup scripts ('cloud-backup' -> 'backup-cloud', 'email-backup' -> 'backup-email', 'upload-backup' -> 'backup-upload').";
|
||||||
74="Extended 'hotspot-to-wpa', it can now read additional configuration from templates and hotspot users.";
|
74="Extended 'hotspot-to-wpa', it can now read additional configuration from templates and hotspot users.";
|
||||||
|
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") ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
# Migration steps to be applied on script updates
|
# Migration steps to be applied on script updates
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 74;
|
:global ExpectedConfigVersion 75;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
@ -1257,12 +1257,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for required RouterOS version
|
# check for required RouterOS version
|
||||||
$RequiredRouterOS "global-functions" "6.47" true;
|
|
||||||
|
|
||||||
# ... and give a hint on RouterOS v7.
|
|
||||||
:if ([ $RequiredRouterOS "global-functions" "7.0" false ] = true) do={
|
:if ([ $RequiredRouterOS "global-functions" "7.0" false ] = true) do={
|
||||||
$LogPrintExit2 warning $0 ("RouterOS v7 brings some incompatible changes. Please switch to branch " . \
|
$RequiredRouterOS "global-functions" "7.1" true;
|
||||||
"'routeros-v7', see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v7") false;
|
} else={
|
||||||
|
$LogPrintExit2 warning $0 ("Still running RouterOS v6, please switch to branch " . \
|
||||||
|
"'routeros-v6', see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6") false;
|
||||||
}
|
}
|
||||||
|
|
||||||
# signal we are ready
|
# signal we are ready
|
||||||
|
|
14
ospf-to-leds
14
ospf-to-leds
|
@ -18,12 +18,18 @@
|
||||||
:local LED ([ $ParseKeyValueStore ($InstanceVal->"comment") ]->"leds");
|
:local LED ([ $ParseKeyValueStore ($InstanceVal->"comment") ]->"leds");
|
||||||
:local LEDType [ / system leds get [ find where leds=$LED ] type ];
|
:local LEDType [ / system leds get [ find where leds=$LED ] type ];
|
||||||
|
|
||||||
:if ($InstanceVal->"state" = "running" && $LEDType = "off") do={
|
:local NeighborCount 0;
|
||||||
$LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " is running, led on!") false;
|
:foreach Area in=[ / routing ospf area find where instance=($InstanceVal->"name") ] do={
|
||||||
|
:local AreaName [ / routing ospf area get $Area name ];
|
||||||
|
:set NeighborCount ($NeighborCount + [ :len [ / routing ospf neighbor find where area=$AreaName ] ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ($NeighborCount > 0 && $LEDType = "off") do={
|
||||||
|
$LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " has " . $NeighborCount . " neighbors, led on!") false;
|
||||||
/ system leds set type=on [ find where leds=$LED ];
|
/ system leds set type=on [ find where leds=$LED ];
|
||||||
}
|
}
|
||||||
:if ($InstanceVal->"state" = "down" && $LEDType = "on") do={
|
:if ($NeighborCount = 0 && $LEDType = "on") do={
|
||||||
$LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " is down, led off!") false;
|
$LogPrintExit2 info $0 ("OSPF instance " . $InstanceVal->"name" . " has no neighbors, led off!") false;
|
||||||
/ system leds set type=off [ find where leds=$LED ];
|
/ system leds set type=off [ find where leds=$LED ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,4 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$LogPrintExit2 info $0 ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false;
|
$LogPrintExit2 info $0 ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false;
|
||||||
/ system ntp client set primary-ntp=$Ntp1 secondary-ntp=$Ntp2;
|
/ system ntp client set servers=($Ntp1, $Ntp2);
|
||||||
|
|
Loading…
Reference in a new issue