Код: Выделить всё
:local scheduleName "on_login"
:local startBuf [:toarray [/log find message~"logged in" || message~"login failure"]]
:local removeThese {"telnet";"192.168.88.27"}
:if ([:len [/system scheduler find name="$scheduleName"]] = 0) do={
/log warning "[LOGMON] ERROR: Schedule does not exist. Create schedule and edit script to match name"
}
:local lastTime [/system scheduler get [find name="$scheduleName"] comment]
:local currentTime
:local message
:local output
:local keepOutput false
:if ([:len $lastTime] = 0) do={
:set keepOutput true
}
:local counter 0
:foreach i in=$startBuf do={
:local keepLog true
:foreach j in=$removeThese do={
:if ([/log get $i message] ~ "$j") do={
:set keepLog false
}
}
:if ($keepLog = true) do={
:set message [/log get $i message]
:set currentTime [ /log get $i time ]
:if ([:len $currentTime] = 8 ) do={
:set currentTime ([:pick [/system clock get date] 0 11]." ".$currentTime)
} else={
:if ([:len $currentTime] = 15 ) do={
:set currentTime ([:pick $currentTime 0 6]."/".[:pick [/system clock get date] 7 11]." ".[:pick $currentTime 7 15])
}
}
:if ($keepOutput = true) do={
:set output ($output.$currentTime." ".$message."\r\n")
}
:if ($currentTime = $lastTime) do={
:set keepOutput true
:set output ""
}
}
:if ($counter = ([:len $startBuf]-1)) do={
:if ($keepOutput = false) do={
:if ([:len $message] > 0) do={
:set output ($output.$currentTime." ".$message."\r\n")
}
}
}
:set counter ($counter + 1)
}
if ([:len $output] > 0) do={
/system scheduler set [find name="$scheduleName"] comment=$currentTime
/tool e-mail send to=***@gmail.com subject="MikroTik alert $currentTime" body="$output"
/log info "[LOGMON] New logs found, send email"
}
Код: Выделить всё
/tool fetch url="https://api.vk.com/method/messages.send\?message=$output&peer_id=1823&v=5.67&access_token=***" keep-result=no
Код: Выделить всё
:local time [/system clock get time]
:local pingcount 5
:local ip [ip firewall address-list get [/ip firewall address-list find list="WAKEPC"] address]
:local hostping 192.168.0.23
:local pingresultA [/ping $hostping count=$pingcount]
:local WAKEPC [/ip firewall address-list find where list="WAKEPC"]
:if ($WAKEPC!="" and $pingresultA > 0) do={
/tool fetch url="https://api.vk.com/method/messages.send\?message=$ip%0A$time&peer_id=123&v=5.67&access_token=***" keep-result=no
/ip firewall address-list remove [find where list="WAKEPC"]
}
:if ($WAKEPC!="" and $pingresultA <= 0) do={
/tool wol mac=**-**-**-**-**-** interface=ether4
/tool fetch url="https://api.vk.com/method/messages.send\?message=$ip%0A$time&peer_id=123&v=5.67&access_token=***" keep-result=no
/ip firewall address-list remove [find where list="WAKEPC"]
}
Благодарен за любую помощь.