mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-09-01 08:15:26 +02:00
Merge branch 'check-health' into next
This commit is contained in:
commit
59dc7e6d0c
4 changed files with 16 additions and 13 deletions
|
@ -11,7 +11,8 @@
|
||||||
:global CheckHealthPlugins;
|
:global CheckHealthPlugins;
|
||||||
|
|
||||||
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
||||||
:local FuncName [ :tostr $0 ];
|
:local FuncName [ :tostr $0 ];
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global CheckHealthLast;
|
:global CheckHealthLast;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
@ -32,13 +33,13 @@
|
||||||
:if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
|
:if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
|
||||||
:if ($CheckHealthLast->$Name = "ok" && \
|
:if ($CheckHealthLast->$Name = "ok" && \
|
||||||
$Value != "ok") do={
|
$Value != "ok") do={
|
||||||
$SendNotification2 ({ origin=$FuncName; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
|
subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
|
||||||
message=("The device '" . $Name . "' on " . $Identity . " failed!") });
|
message=("The device '" . $Name . "' on " . $Identity . " failed!") });
|
||||||
}
|
}
|
||||||
:if ($CheckHealthLast->$Name != "ok" && \
|
:if ($CheckHealthLast->$Name != "ok" && \
|
||||||
$Value = "ok") do={
|
$Value = "ok") do={
|
||||||
$SendNotification2 ({ origin=$FuncName; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
||||||
message=("The device '" . $Name . "' on " . $Identity . " recovered!") });
|
message=("The device '" . $Name . "' on " . $Identity . " recovered!") });
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
:global CheckHealthPlugins;
|
:global CheckHealthPlugins;
|
||||||
|
|
||||||
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
||||||
:local FuncName [ :tostr $0 ];
|
:local FuncName [ :tostr $0 ];
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global CheckHealthLast;
|
:global CheckHealthLast;
|
||||||
:global CheckHealthTemperature;
|
:global CheckHealthTemperature;
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
}
|
}
|
||||||
:if ($Value > $CheckHealthTemperature->$Name && \
|
:if ($Value > $CheckHealthTemperature->$Name && \
|
||||||
$CheckHealthTemperatureNotified->$Name != true) do={
|
$CheckHealthTemperatureNotified->$Name != true) do={
|
||||||
$SendNotification2 ({ origin=$FuncName; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
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: " . \
|
||||||
$Value . "\C2\B0" . "C") });
|
$Value . "\C2\B0" . "C") });
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
}
|
}
|
||||||
:if ($Value <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
|
:if ($Value <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
|
||||||
$CheckHealthTemperatureNotified->$Name = true) do={
|
$CheckHealthTemperatureNotified->$Name = true) do={
|
||||||
$SendNotification2 ({ origin=$FuncName; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
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: " . \
|
||||||
$Value . "\C2\B0" . "C") });
|
$Value . "\C2\B0" . "C") });
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
:global CheckHealthPlugins;
|
:global CheckHealthPlugins;
|
||||||
|
|
||||||
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
||||||
:local FuncName [ :tostr $0 ];
|
:local FuncName [ :tostr $0 ];
|
||||||
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global CheckHealthLast;
|
:global CheckHealthLast;
|
||||||
:global CheckHealthVoltageLow;
|
:global CheckHealthVoltageLow;
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
|
|
||||||
:if ($NumLast * (100 + $CheckHealthVoltagePercent) < $NumCurr * 100 || \
|
:if ($NumLast * (100 + $CheckHealthVoltagePercent) < $NumCurr * 100 || \
|
||||||
$NumLast * 100 > $NumCurr * (100 + $CheckHealthVoltagePercent)) do={
|
$NumLast * 100 > $NumCurr * (100 + $CheckHealthVoltagePercent)) do={
|
||||||
$SendNotification2 ({ origin=$FuncName; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
|
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
|
||||||
$NumCurr) "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" . \
|
||||||
|
@ -47,12 +48,12 @@
|
||||||
[ $FormatLine "new value" ($Value . " V") 12 ]) });
|
[ $FormatLine "new value" ($Value . " V") 12 ]) });
|
||||||
} else={
|
} else={
|
||||||
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
|
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
|
||||||
$SendNotification2 ({ origin=$FuncName; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
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 " . $Value . " V below hard limit.") });
|
message=("The " . $Name . " on " . $Identity . " dropped to " . $Value . " V below hard limit.") });
|
||||||
}
|
}
|
||||||
:if ($NumCurr > $CheckHealthVoltageLow && $NumLast <= $CheckHealthVoltageLow) do={
|
:if ($NumCurr > $CheckHealthVoltageLow && $NumLast <= $CheckHealthVoltageLow) do={
|
||||||
$SendNotification2 ({ origin=$FuncName; \
|
$SendNotification2 ({ origin=$ScriptName; \
|
||||||
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 " . $Value . " V above hard limit.") });
|
message=("The " . $Name . " on " . $Identity . " recovered to " . $Value . " V above hard limit.") });
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,16 +92,16 @@
|
||||||
:onerror Err {
|
:onerror Err {
|
||||||
/system/script/run $Plugin;
|
/system/script/run $Plugin;
|
||||||
} do={
|
} do={
|
||||||
$LogPrint error $ScriptName ("Plugin '" . $ScriptVal->"name" . "' failed to run: " . $Err);
|
$LogPrint error $ScriptName ("Plugin '" . $PluginVal->"name" . "' failed to run: " . $Err);
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrint error $ScriptName ("Plugin '" . $ScriptVal->"name" . "' failed syntax validation, skipping.");
|
$LogPrint error $ScriptName ("Plugin '" . $PluginVal->"name" . "' failed syntax validation, skipping.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach PluginName,Discard in=$CheckHealthPlugins do={
|
:foreach PluginName,Discard in=$CheckHealthPlugins do={
|
||||||
($CheckHealthPlugins->$PluginName) \
|
($CheckHealthPlugins->$PluginName) \
|
||||||
("\$CheckHealthPlugins->\"" . $PluginName . "\"");
|
("\$CheckHealthPlugins->\"" . $PluginName . "\"") $ScriptName;
|
||||||
}
|
}
|
||||||
|
|
||||||
:set CheckHealthPlugins;
|
:set CheckHealthPlugins;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue