Este pequeño script nos permite saber que usuarios PPPoE existentes se encuentran desconectados. A saber: este código funciona con cuentas locales creadas en “/ppp secret” (por ejemplo, no funcionaría en caso de utilizar RADIUS).
Código limpio:
{
:local CuentasDesco 0
:put "TOTAL DE CUENTAS:"
:do {
:local CuentasTotales [/ppp secret print count-only where service=pppoe]
:for i from=0 to=$CuentasTotales do={
:local Cuenta [/ppp secret get $i name]
:if ([/ppp active find where name=$Cuenta]) do={
:nothing;} else={
if ([/ppp secret get $i service] = "pppoe") do={
:put "CUENTA DESCONECTADA: $Cuenta"
:set CuentasDesco ($CuentasDesco+1)
}
}
}
} on-error={:return "\nTOTAL DE CUENTAS DESCONECTADAS: $CuentasDesco"};
:return "\nTOTAL DE CUENTAS DESCONECTADAS: $CuentasDesco"
}
Código para copiar y pegar en el MikroTik:
/system script
add dont-require-permissions=no name=script1 owner=prozcenter policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="{\r\
\n:local CuentasDesco 0\r\
\n:put \"TOTAL DE CUENTAS:\"\r\
\n:do {\r\
\n :local CuentasTotales [/ppp secret print count-only where service=pppoe]\r\
\n :for i from=0 to=\$CuentasTotales do={\r\
\n :local Cuenta [/ppp secret get \$i name]\r\
\n :if ([/ppp active find where name=\$Cuenta]) do={\r\
\n :nothing;} else={\r\
\n if ([/ppp secret get \$i service] = \"pppoe\") do={\r\
\n :put \"CUENTA DESCONECTADA: \$Cuenta\"\r\
\n :set CuentasDesco (\$CuentasDesco+1)\r\
\n }\r\
\n }\r\
\n}\r\
\n} on-error={:return \"\\nTOTAL DE CUENTAS DESCONECTADAS: \$CuentasDesco\"};\r\
\n:return \"\\nTOTAL DE CUENTAS DESCONECTADAS: \$CuentasDesco\"\r\
\n}"
Una vez cargado, este script hace su tarea:

Espero este articulo te haya resultado útil. ¡Hasta al próxima!
