Schedul Script Para Chequeo de la Conección de Internet
Les dejo un SCRIPT para que lo prueben y compartan su opinión
/system scheduler
add disabled=yes interval=5s name=ping_google_link_B on-event=scheduler-B \
policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/1970 start-time=00:00:00
add interval=5s name=ping_google_link_Both on-event=scheduler-Both policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/1970 start-time=00:00:00
add disabled=yes interval=5s name=ping_google_link_A on-event=scheduler-A \
policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/1970 start-time=00:00:00
Schedule 1
#set variables
:local pingcount 3
:local ipA 192.168.89.74
:local ipB 192.168.73.74
#ping gateways with src
:local pingresultA [/ping 8.8.8.8 src-address=$ipA count=$pingcount]
:local pingresultB [/ping 8.8.8.8 src-address=$ipB count=$pingcount]
#if link_A is UP
:if (($pingresultA=3)) do={
#send email
/tool e-mail send subject=($ipA . " is up ") \
body=("the gateway is up now at: " . [/system clock get date]) \ to=("warrior.wifi@gmail.com") tls=yes
#enable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=no
#disablescheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=yes
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=yes
}
Schedule 2
#set variables
:local pingcount 3
:local ipA 192.168.89.74
:local ipB 192.168.73.74
#ping gateways with src
:local pingresultA [/ping 8.8.8.8 src-address=$ipA count=$pingcount]
:local pingresultB [/ping 8.8.8.8 src-address=$ipB count=$pingcount]
#if Link_B is UP
:if (($pingresultB=3)) do={
#send email
/tool e-mail send subject=($ipB . " is up ") \
body=("the gateway is up now at: " . [/system clock get date]) \ to=("warrior.wifi@gmail.com") tls=yes
#enable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=no
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=yes
#disable scheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=yes
}
POR HORARIOS
#set variables
:local pingcount 3
:local ipA 192.168.89.74
:local ipB 192.168.73.74
:global state no
#ping gateways with src
:local pingresultA [/ping 8.8.8.8 src-address=$ipA count=$pingcount]
:local pingresultB [/ping 8.8.8.8 src-address=$ipB count=$pingcount]
#if link_A is DOWN and link_B is UP then:
:if (($pingresultA=0) && ($pingresultB>0)) do={
#send email
/tool e-mail send subject=($ipA . " is down") \
body=("the gateway is down now at: " . [/system clock get date]) \ to=("warrior.wifi@gmail.com") tls=yes
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=no
#disable scheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=yes
#disable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=yes
}
#if link_A is UP and link_B is DOWN then:
:if (($pingresultA>0) && ($pingresultB=0)) do={
#send email
/tool e-mail send subject=($ipB . " is down") \
body=("the gateway is down now at: " . [/system clock get date]) \ to=("warrior.wifi@gmail.com") tls=yes
#disable scheduler-B
/system scheduler set [find name=ping_google_link_B] disabled=no
#disable scheduler-A
/system scheduler set [find name=ping_google_link_A] disabled=yes
#disable scheduler-Both
/system scheduler set [find name=ping_google_link_Both] disabled=yes
}
Post actualizado
Mikrotik alerta por correo electrónico cuando el nuevo usuario se conecte a su hotspot
Les Dejo el Nuevo SCRIPT
/system script add name="new_user" source={
:foreach a in [/ip hotspot active find] do={
:if ([/ip hotspot active get $a uptime]<1m) do={
/tool e-mail send \
to=warrior.wifi@gmail.com \
subject=("'" . [/ip hotspot active get $a user] . "' logged in") \
body=("User:" . [/ip hotspot active get $a user] . " Date:" . \
[/system clock get time] . " IP address:" . \
[/ip hotspot active get $a address] . " MAC address:" . \
[/ip hotspot active get $a mac-address] . " Session timeout:" . \
[/ip hotspot active get $a session-timeout])
}
}
}
No hay comentarios