mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-13 03:24:28 +02:00
ospf-to-leds: introduce script to visualize ospf state via leds
This commit is contained in:
parent
ebbc40e3a0
commit
ae5570325b
7 changed files with 63 additions and 3 deletions
|
@ -171,6 +171,7 @@ Available Scripts
|
||||||
* [Mode button with multiple presses](doc/mode-button.md)
|
* [Mode button with multiple presses](doc/mode-button.md)
|
||||||
* [Notify on host up and down](doc/netwatch-notify.md)
|
* [Notify on host up and down](doc/netwatch-notify.md)
|
||||||
* [Manage remote logging](doc/netwatch-syslog.md)
|
* [Manage remote logging](doc/netwatch-syslog.md)
|
||||||
|
* [Visualize OSPF state via LEDs](doc/ospf-to-leds.md)
|
||||||
* [Manage system update](doc/packages-update.md)
|
* [Manage system update](doc/packages-update.md)
|
||||||
* [Run scripts on ppp connection](doc/ppp-on-up.md)
|
* [Run scripts on ppp connection](doc/ppp-on-up.md)
|
||||||
* [Rotate NTP servers](doc/rotate-ntp.md)
|
* [Rotate NTP servers](doc/rotate-ntp.md)
|
||||||
|
|
34
doc/ospf-to-leds.md
Normal file
34
doc/ospf-to-leds.md
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
Visualize OSPF state via LEDs
|
||||||
|
=============================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Physical interfaces have their state LEDs, software-defined connectivity
|
||||||
|
does not. This script helps to visualize whether or not an OSPF instance
|
||||||
|
is running.
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the script:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate ospf-to-leds;
|
||||||
|
|
||||||
|
... and add a scheduler to run the script periodically:
|
||||||
|
|
||||||
|
/ system scheduler add interval=20s name=ospf-to-leds on-event="/ system script run ospf-to-leds;" start-time=startup;
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The configuration goes to OSPF instance's comment. To visualize state for
|
||||||
|
instance `default` via LED `user-led` set this:
|
||||||
|
|
||||||
|
/ routing ospf instance set default comment="ospf-to-leds, leds=user-led";
|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
|
@ -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 33;
|
:global GlobalConfigVersion 34;
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
|
|
|
@ -9,7 +9,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 change notifications.
|
# Comment or remove to disable change notifications.
|
||||||
:global GlobalConfigVersion 33;
|
:global GlobalConfigVersion 34;
|
||||||
|
|
||||||
# Copy configuration from global-config here and modify it.
|
# Copy configuration from global-config here and modify it.
|
||||||
|
|
||||||
|
|
|
@ -37,4 +37,5 @@
|
||||||
31="Switched Telegram notifications to fixed-width font, with opt-out.";
|
31="Switched Telegram notifications to fixed-width font, with opt-out.";
|
||||||
32="Merged mode (& reset) button scripts in single new script 'mode-button'.";
|
32="Merged mode (& reset) button scripts in single new script 'mode-button'.";
|
||||||
33="Added configurable deviation on health temperature recovery threshold against notification flooding.";
|
33="Added configurable deviation on health temperature recovery threshold against notification flooding.";
|
||||||
|
34="Introduced script 'ospf-to-leds' to visualize OSPF instance state via LEDs.";
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 33;
|
:global ExpectedConfigVersion 34;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
|
24
ospf-to-leds
Normal file
24
ospf-to-leds
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#!rsc by RouterOS
|
||||||
|
# RouterOS script: ospf-to-leds
|
||||||
|
# Copyright (c) 2020 Christian Hesse <mail@eworm.de>
|
||||||
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
||||||
|
#
|
||||||
|
# visualize ospf instance state via leds
|
||||||
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ospf-to-leds.md
|
||||||
|
|
||||||
|
:global LogPrintExit;
|
||||||
|
:global ParseKeyValueStore;
|
||||||
|
|
||||||
|
:foreach Instance in=[ / routing ospf instance find where comment~"^ospf-to-leds," ] do={
|
||||||
|
:local InstanceVal [ / routing ospf instance get $Instance ];
|
||||||
|
:local LED ([ $ParseKeyValueStore ($InstanceVal->"comment") ]->"leds");
|
||||||
|
:local LEDType [ / system leds get [ find where leds=$LED ] type ];
|
||||||
|
|
||||||
|
$LogPrintExit debug ("OSPF instance " . $InstanceVal->"name" . " is " . $InstanceVal->"state" . ".") false;
|
||||||
|
:if ($InstanceVal->"state" = "running" && $LEDType = "off") do={
|
||||||
|
/ system leds set type=on [ find where leds=$LED ];
|
||||||
|
}
|
||||||
|
:if ($InstanceVal->"state" = "down" && $LEDType = "on") do={
|
||||||
|
/ system leds set type=off [ find where leds=$LED ];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue