Skip to content

Instantly share code, notes, and snippets.

@mmv-ru
Last active May 23, 2018 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmv-ru/f441a968260f774e10fba5ccf9b0a9c4 to your computer and use it in GitHub Desktop.
Save mmv-ru/f441a968260f774e10fba5ccf9b0a9c4 to your computer and use it in GitHub Desktop.
/system script
add name=test owner=mmv policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source={
:local content [/file get [/file find name=ip.txt] contents] ;
:local contentLen [:len $content];
:local lineEnd 0;
:local line "";
:local lastEnd 0;
:local domail false
:while ($lineEnd < $contentLen) do={
:set lineEnd [:find $content "\n" $lastEnd];
:if ([:len $lineEnd] = 0) do={
:set lineEnd $contentLen;
}
:set line [:pick $content $lastEnd $lineEnd];
:set lastEnd ($lineEnd + 1);
:if ([:find "error" $line != "\n") do={
:if ([/ping $line count=5] = 5) do={
:put "$line"
:set domail true
# /tool e-mail send to=test1@gmail.com subject="Can't ping $line"
# /tool e-mail send to=test2@gmail.com subject="Can't ping $line"
}
}
}
:if $domail do={
:put "Lets send mail!"
# /tool e-mail send to=test1@gmail.com subject="File ip.txt error" body=$content
# /tool e-mail send to=test1@gmail.com subject="File ip.txt error" file=ip.txt
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment