Save Monthly Traffic on local server

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.

The question is too vague. Do you want to record traffic volume or every single packet?

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.

I want just to monitor monthly WAN traffic nothing more. Is there any tutorial how to get that?

Any example for that, or tutorial?

You can enable graphing on the WAN interface which will give you the utilization, but again, it depends on what details you want

Your question is incomplete do you have to save whole data packet or individually.

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.