Created
December 31, 2018 16:36
-
-
Save TerAnYu/88c822ea82c621962a9f10c969bd8151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/system script add dont-require-permissions=no name=bgp_watchdog_script owner=adminos policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="local state 0;\r\ | |
\nlocal scriptName \"bgp_watchdog_script\";\r\ | |
\n\r\ | |
\n:local nameif \"VPN_NAME_INTERFACE\"\r\ | |
\n:local namebgp \"BGP_PEER_NAME\"\r\ | |
\n:local timeout 30s\r\ | |
\n\r\ | |
\n:local token \"bot342410789:AAE4UDFGDFGDFDFHDFHDFGSvaZYIabGwx4gPHc\"\r\ | |
\n:local tokenchat \"-00000000000\"\r\ | |
\n\r\ | |
\n:local text \"BGP - \$namebgp does`t work! Restart!\"\r\ | |
\n:local text1 \"BGP - \$namebgp restart!\"\r\ | |
\n:local text2 \"BGP - \$namebgp work!\"\r\ | |
\n\r\ | |
\nif ( [len [/system script job find where script=\$scriptName]] > 1) do= { error \"single instance\" };\r\ | |
\ndelay 15;\r\ | |
\n\r\ | |
\n\r\ | |
\nwhile (true) do {\r\ | |
\n:if ([/interface get number=[find where name=\$nameif] running]=true) do={\r\ | |
\n[/routing bgp peer enable numbers=[find where name=\$namebgp disabled=yes]];\r\ | |
\n\r\ | |
\nif ( [/routing bgp peer get value-name=prefix-count number=[find where name=\$namebgp disabled=no]] ~\"^\\\$\" ) do= {\r\ | |
\n:local dt [/system clock get date];\r\ | |
\n:local tm [/system clock get time];\r\ | |
\n:log info (\"\$text\");\r\ | |
\n[/tool fetch keep-result=no url=\"https://api.telegram.org/\$token/sendMessage\\\?chat_id=\$tokenchat&text=\$dt - \$tm %0A \$text\"];\r\ | |
\n\r\ | |
\n:log info (\"\$text1\");\r\ | |
\n[/routing bgp peer disable numbers=[find where name=\$namebgp disabled=no]];\r\ | |
\n:delay \$timeout;\r\ | |
\n[/routing bgp peer enable numbers=[find where name=\$namebgp disabled=yes]];\r\ | |
\n:delay \$timeout;\r\ | |
\n\r\ | |
\nif ( [/routing bgp peer get value-name=prefix-count number=[find where name=\$namebgp disabled=no]] > 0 ) do= {\r\ | |
\n:local dt [/system clock get date];\r\ | |
\n:local tm [/system clock get time];\r\ | |
\n:log info (\"\$text2\");\r\ | |
\n[/tool fetch keep-result=no url=\"https://api.telegram.org/\$token/sendMessage\\\?chat_id=\$tokenchat&text=\$dt - \$tm %0A \$text2\"];\r\ | |
\n};\r\ | |
\n};\r\ | |
\n};\r\ | |
\n:delay \$timeout;\r\ | |
\n};\r\ | |
\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VPN_NAME_INTERFACE - Интерфейс, например VPN, откауда получаем анонсы
BGP_PEER_NAME - /routing/bgp/peers - название пира
bot342410789:AAE4UDFGDFGDFDFHDFHDFGSvaZYIabGwx4gPHc - токен бота Telegram
-00000000000 - токен чата