Community discussions

MikroTik App
 
mmgareth
just joined
Topic Author
Posts: 18
Joined: Wed Oct 22, 2014 11:48 am

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

Fri Jan 09, 2015 1:03 pm

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
 
timmay2
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Sat Sep 14, 2013 2:18 pm
Location: Kent, UK

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

Fri Jan 09, 2015 5:53 pm

Hi

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

Rgds,
Tim
Last edited by timmay2 on Sat Jan 10, 2015 5:03 pm, edited 1 time in total.
 
User avatar
skot
Long time Member
Long time Member
Posts: 586
Joined: Wed Nov 30, 2011 3:05 am

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

Sat Jan 10, 2015 12:51 am

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.
I don't need any karma... I have Ιησους Χριστος!
 
mmgareth
just joined
Topic Author
Posts: 18
Joined: Wed Oct 22, 2014 11:48 am

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

Tue Jan 13, 2015 5:22 pm

Thanks guys - thats a great help.

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

Many thanks

Who is online

Users browsing this forum: Bing [Bot] and 17 guests