Page 1 of 1

Script needed to send log data by HTTP POST (or GET)

Posted: Fri Jan 09, 2015 1:03 pm
by mmgareth
Hi

I would like my Mikrotik router to send a HTTP POST/GET to a local webserver every time a "caps,info" event occurs...

I would like to send the date time and log message, like...
10:09:13 caps,info 61:77:BA:6E:B3:F3@cap116 connected
10:10:30 caps,info 61:77:BA:6E:B3:F3@cap116 disconnected, received disassoc: sending station leaving (8)

Does anyone have a script like this, or one that I could adapt?

Thanks

Re: Script needed to send log data by HTTP POST (or GET)

Posted: Fri Jan 09, 2015 5:53 pm
by timmay2
Hi

You could adapt my gps-to-url script to do this. It's on GitHub:- https://github.com/timmay2/mikrotik-gps/

Rgds,
Tim

Re: Script needed to send log data by HTTP POST (or GET)

Posted: Sat Jan 10, 2015 12:51 am
by skot
You could adapt my gpt-to-url script to do this. It's on GitHub:- https://github.com/timmay2/mikrotik-gps/
In addition to the URL code from Tim's script, you will also need a script that monitors the logs and keeps track of new and old entries. The following script was created for that purpose, except it checks for strings within the log message. It could easily be adapted to check for topics instead.
http://wiki.mikrotik.com/wiki/Monitor_l ... run_script

Follow the instructions in the article to configure the schedule and script, with these modifications:

In the setup part of the script at the top, change the last two options to:
:local startBuf [:toarray [/log find topics=caps,info]]
:local removeThese
And, then at the bottom of the script, replace the line
/tool email...
with
The desired URL code...
...
/tool fetch url=...
...and that gets it basically working.

Re: Script needed to send log data by HTTP POST (or GET)

Posted: Tue Jan 13, 2015 5:22 pm
by mmgareth
Thanks guys - thats a great help.

I will post my script up here when (if!?) I get it working.

Many thanks