Community discussions

MikroTik App
 
abbio90
Member Candidate
Member Candidate
Topic Author
Posts: 251
Joined: Fri Aug 27, 2021 9:16 pm
Contact:

foreach log message

Fri Apr 12, 2024 12:33 pm

Good morning, I would like to capture this log message in a variable:
a.png
I set the script like this, but the message doesn't appear when I do the :put and I don't have an output.
where am I wrong?
{
:local logMessage ""
:local logIp ""
:local cont1 0
:local cont2 0
/log

:foreach i in=[find where message~"login failed: password is not chap encrypted" or where message~"login failed: RADIUS server is not responding"] do={
    :set logMessage [get $i message]
     }
    :if ($logMessage~"login failed: password is not chap encrypted") do={
        :set $cont1 ($cont1 + 1)
        }
    :if ($logMessage~"login failed: RADIUS server is not responding") do={
        :set $cont2 ($cont2 + 1)
        }
:put $logMessage

}
You do not have the required permissions to view the files attached to this post.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12032
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: foreach log message

Fri Apr 12, 2024 5:22 pm

The script is full of error.
Eg.
where .. or where
} closed too early
set $cont

Who is online

Users browsing this forum: slimmerwifi and 8 guests