Community discussions

MikroTik App
 
deanMKD1
Member
Member
Topic Author
Posts: 366
Joined: Fri Dec 12, 2014 12:06 am
Location: Macedonia
Contact:

Save Monthly Traffic on local server

Wed Feb 07, 2018 8:26 pm

Hi Mikrotik, i want somehow to monitor / save all traffic that pass via router, to local linux server. Is somehow possible to store into Mysql database or? I searched for many sollutions, but unabled to find working one.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 10840
Joined: Mon Dec 04, 2017 9:19 pm

Re: Save Monthly Traffic on local server

Thu Feb 08, 2018 10:48 am

The question is too vague. Do you want to record traffic volume or every single packet?
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1782
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: Save Monthly Traffic on local server

Thu Feb 08, 2018 1:42 pm

You could enable SNMP on routerboard, and setup some scripting on your server to insert the reported numbers (for any interface you chose to expose) into mysql db.
 
deanMKD1
Member
Member
Topic Author
Posts: 366
Joined: Fri Dec 12, 2014 12:06 am
Location: Macedonia
Contact:

Re: Save Monthly Traffic on local server

Thu Feb 08, 2018 2:58 pm

The question is too vague. Do you want to record traffic volume or every single packet?
I want just to monitor monthly WAN traffic nothing more. Is there any tutorial how to get that?
You could enable SNMP on routerboard, and setup some scripting on your server to insert the reported numbers (for any interface you chose to expose) into mysql db.
Any example for that, or tutorial?
 
User avatar
CZFan
Forum Guru
Forum Guru
Posts: 2098
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
Contact:

Re: Save Monthly Traffic on local server

Thu Feb 08, 2018 4:22 pm

You can enable graphing on the WAN interface which will give you the utilization, but again, it depends on what details you want
 
warda
just joined
Posts: 1
Joined: Thu Feb 08, 2018 12:49 pm

Re: Save Monthly Traffic on local server

Fri Feb 09, 2018 7:34 am

Your question is incomplete do you have to save whole data packet or individually.
 
deanMKD1
Member
Member
Topic Author
Posts: 366
Joined: Fri Dec 12, 2014 12:06 am
Location: Macedonia
Contact:

Re: Save Monthly Traffic on local server

Tue Feb 13, 2018 9:23 pm

You can enable graphing on the WAN interface which will give you the utilization, but again, it depends on what details you want
Graphing not show monthly traffic. So its not usefull for me.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 10840
Joined: Mon Dec 04, 2017 9:19 pm

Re: Save Monthly Traffic on local server

Tue Feb 13, 2018 11:14 pm

You can enable graphing on the WAN interface which will give you the utilization, but again, it depends on what details you want
Graphing not show monthly traffic. So its not usefull for me.
That was why I was asking you to state in deeper detail what you want. So if I get you right, as the "monthly" graph readily available does not satsify you because it gives a number of bytes per each day per each direction, you want the total number of bytes (or packets or both) which passed through the router to and/or from a particular interface or IP address during a given month. And it is enough to you to get the value(s) after the month has ended.

So as @Sebastia has suggested, you need to pick up the data from the RouterBoard yourself. The possible ways to do that are:
  • SNMP
  • ssh with key authentication (i.e. without password)
  • the Mikrotik API
  • an e-mail sent by the Mikrotik itself
The next point is how to collect the data. There are two possibilities:
  • if it is enough for you to collect data on an interface, you can just read the existing items
  • if you need to collect data of a particular device which is not the only one connected to an interface, you need to create a pair of raw firewall rules matching the device's IP address, one as source and the other one as destination, and pick up the statistics of these rules. I'm not sure whether this is possible via SNMP, though.
The last point is presentation of the data. The statistics are just growing unless someone resets them. So you can either read them at the "morning midnight" of the first day of each month and reset them right after, or you may subtract the value retrieved previously before saving the new value, or you may save the value without correction and correct it during presentation.

Who is online

Users browsing this forum: benache, Flanger, JokubasGer and 54 guests