From 50874b17606fa6988306036c847655d2d04b77b3 Mon Sep 17 00:00:00 2001 From: Grzegorz Budny Date: Sat, 3 Aug 2019 10:48:07 +0200 Subject: [PATCH] Update. --- README.md | 22 +++++++++++++++++ RouterOS_Reset_Interface.rsc | 22 +++++++++++++++++ RouterOS_String_Generator.rsc | 45 +++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 RouterOS_Reset_Interface.rsc create mode 100644 RouterOS_String_Generator.rsc diff --git a/README.md b/README.md index 1b1bc12..8c7affa 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ ## Change log + - 8/3/2019 + - RouterOS_String_Generator.rsc + - Generates 6 char string based on dictionary + - RouterOS_Reset_Interface.rsc + - Resets interface if particular IP does not respond + - 7/29/2019 - RouterOS_Modulo.rsc - Modulo operation @@ -162,6 +168,22 @@ $Modulo number=number_to_be_devided modulo=modulo_value; $LoadScript scriptName=scriptName.rsc; ``` +### RouterOS_String_Generator.rsc + +> Generates 6 char string based on dictionary + +``` +$GenerateString; +``` + +### RouterOS_Reset_Interface.rsc + +> Resets interface if particular IP does not respond + +``` +$ResetInterface ipAddress=ipAddress_To_Monitor interfaceName=interface_name; +``` + ## Authors - Grzegorz Budny diff --git a/RouterOS_Reset_Interface.rsc b/RouterOS_Reset_Interface.rsc new file mode 100644 index 0000000..1a5fb46 --- /dev/null +++ b/RouterOS_Reset_Interface.rsc @@ -0,0 +1,22 @@ +# RouterOS Function +# Copyright (c) Grzegorz Budny +# Reset interface if particular IP does not respond + +:global ResetInterface do={ + + :if ([/ping $ipAddress interval=1 count=4] > 0) do={ + + :log info "...:::Interface healthcheck. Status OK:::..." + + }\ + else={ + + :log error ("...:::Monitor detected ".$interfaceName." down. Resetting:::..."); + /interface ethernet disable $interfaceName; + :delay 3; + /interface ethernet enable $interfaceName; + + } +} + +$ResetInterface ipAddress=ipAddress_To_Monitor interfaceName=interface_name; \ No newline at end of file diff --git a/RouterOS_String_Generator.rsc b/RouterOS_String_Generator.rsc new file mode 100644 index 0000000..a3a8809 --- /dev/null +++ b/RouterOS_String_Generator.rsc @@ -0,0 +1,45 @@ +# RouterOS Function +# Copyright (c) Grzegorz Budny +# Generates random string based on dictionary of six chars length + +:global GenerateString do={ + + :global generatedString; + + :local characters q,w,e,r,t,y,u,i,o,p,l,k,j,h,g,f,1,2,3,4,5,6,7,8,9,0,d,s,a,z,x,c,v,b,n,m,M,N,B,V,C,X,Z,A,S,D,F,G,H,J,K,L,P,O,I,U,Y,T,R,E,W,Q; + + :local hour [:pick [/system clock get time] 0 2]; + :local minute [:pick [/system clock get time] 3 5]; + :local second [:pick [/system clock get time] 6 8]; + + :if ((:pick $hour 0) = 0) do={ + + :set $hour [:pick $hour 1]; + + } + :if ((:pick $minute 3) = 0) do={ + + :set $minute [:pick $minute 4]; + + } + :if ((:pick $second 6) = 0) do={ + + :set $second [:pick $second 7]; + + }\ + else={ + + :log warning "Something's wrong with system time. Check system time and NTP settings."; + + } + + :set $generatedString ($generatedString.([:pick $characters $hour].[:pick $characters $minute].[:pick $characters $second].\ + [:pick $characters ($hour/2)].[:pick $characters ($minute/2)].[:pick $characters ($second/2)])); + + :log info "...:::Random string generated:::..." + + :return ($generatedString); + +} + +$GenerateString; \ No newline at end of file