when I have confirmation, I remove the * on the title.
This IS the script, I think for all type of PPP connection, but are tested only for PPPOE, PPTP, L2TP, SSTP, I have not tested this for OVPN and PPP:
The syntax are 6.7+ compatible, I do not know if also is working on 5.x or previous.
What this scheduling do on a "ppp" of any type server:
Each 20 minutes [also from routerboard reboots], check all type of ppp connected, if 2 ping over 2 fail, the connection are closed (and logged). Everytime the script start and ends, write logs.
Simply paste this on terminal
Code: Select all
/system scheduler
add disabled=no interval=20m name=check-ppp-client on-event=":log info message=\"*** start check any ppp client connection ***\";\r\
\n:local pppTest value=[/ppp active find];\r\
\n:local pingNumber value=2;\r\
\n:local pingMin value=1;\r\
\n:foreach userTest in=\$pppTest do={\r\
\n :local pingOk value=[:ping [/ppp active get \$userTest value-name=address] count=\$pingNumber]\r\
\n :if ( \$pingOk < \$pingMin) do={\r\
\n :log warning message=([/ppp active get \$userTest value-name=service] . \" auto disconnected: \". \$pingOk . \" ping ok over \" . \$pingNumber . \" \" . [/ppp active get \$userTest value-name=name] . \" \" . [/ppp active get \$userTest value-\
name=address])\r\
\n /ppp active remove \$userTest\r\
\n }\r\
\n};\r\
\n:log info message=\"*** end check any ppp client connection ***\";\r\
\n" policy=ftp,read,write,test start-date=jan/01/2002 start-time=00:20:00
Code: Select all
:log info message="*** start check any ppp client connection ***";
:local pppTest value=[/ppp active find];
:local pingNumber value=2;
:local pingMin value=1;
:foreach userTest in=$pppTest do={
:local pingOk value=[:ping [/ppp active get $userTest value-name=address] count=$pingNumber]
:if ($pingOk < $pingMin) do={
:log warning message=([/ppp active get $userTest value-name=service] . " auto disconnected: ". $pingOk . " ping ok over " . $pingNumber . " " . [/ppp active get $userTest value-name=name] . " " . [/ppp active get $userTest value-name=address])
/ppp active remove $userTest
}
};
:log info message="*** end check any ppp client connection ***";
Thanks.