Community discussions

MikroTik App
 
Diamont
just joined
Topic Author
Posts: 19
Joined: Sun Aug 18, 2013 6:48 pm

Syslog monitor

Wed Jul 23, 2014 8:22 pm

Hi ALL. I need to monitor some phrase in syslog (for example "device changed") and once it found, send SMS via USB modem. So how can i monitor RB`s syslog using script?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12594
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Syslog monitor

Wed Jul 23, 2014 8:25 pm

:put [/log find where message~"device changed"]
 
Diamont
just joined
Topic Author
Posts: 19
Joined: Sun Aug 18, 2013 6:48 pm

Re: Syslog monitor

Wed Jul 23, 2014 8:44 pm

:put /log find where message~"device changed" do={
/tool sms send usb1 "XXXXXXXXX" \ message="WARNING"
}

Does not work.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12594
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Syslog monitor

Wed Jul 23, 2014 8:59 pm

Is like you do not know how scripting...

It's only one hint how write new script.

Use my hint ahd find on the forum using search function the already present solutions.
 
Diamont
just joined
Topic Author
Posts: 19
Joined: Sun Aug 18, 2013 6:48 pm

Re: Syslog monitor

Wed Jul 23, 2014 9:21 pm

Looks like you misspelled too. :) Working script is:
:foreach i in=[/log find where message~"device changed"] do={
  /tool sms send usb1 "XXXXXXXXX" \ message="WARNING"
}
Anyway thanks.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12594
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Syslog monitor

Wed Jul 23, 2014 9:24 pm

I do not misspelled anything.

:put [/log find where message~"device changed"]

simply print one list of ID of each finded log.

Thinking you know srcripting, I'm aspect you to simple put the "getting" part ([/log find where message~"device changed"]) on "foreach"...

Like what you have done now.

BUT OBVIOUSLY IF YOU DO NOT CHECK WHAT IS THE LAST LOG YOU HAVE SENT, YOU CONTINUOSLY RECEIVE THE SAME WARNING ON EACH SCRIPT RUN...

And is why I suggest you to use search function....
 
Diamont
just joined
Topic Author
Posts: 19
Joined: Sun Aug 18, 2013 6:48 pm

Re: Syslog monitor

Wed Jul 23, 2014 9:33 pm

If i would know scripting, i wouldn`t post this thread.

Probably, i will edit the scipt so it will delete it`s own shedule once the first SMS sent.

Who is online

Users browsing this forum: No registered users and 21 guests