I need a script that create email with the amount of up and download traffic every 1st day in month after that action the script resets the traffic counter of each pppoe-user.
i woul suggest you to use some accounting software to accomplish this. You are welcome to take a look at our application called HotSpot Manager: http://www.mikrotik.com/download.html#hotspot
the mikrotik hotspot manager have no option to count the amount of traffic up and download together. And my ISP count the traffic in MB not in online-time.I have only 8 User to count and so i think a radius server is too complex.
you are wrong! HS Manager supports such a feature. Select necessary users, click on the Sessions button. Then press Print Logs, make sure that Download and Upload are checked and you will be able to the to total count of TX and RX traffic at the bottom of the table.
but in that way i have no automatical report of user-traffic.
My ISP calculate from the 1st to the next 1st in month.
In my opinion is a script the better way to count the traffic.
So i have a minimum of Expenditure.
ok, added!
It’s placed right there when you will click Print Logs button. In the next window check advanced logs check-box and you will see selected users’ logs during specified time period.
i’ve checked that but it is not correct.
example: User1 logged in at 23:00 and have a amount of traffic in the first hour of 100 MB and in the next 1 hour only 1MB
after that hour the user1 logged out.
in the logfile the amount uf 101MB is calculated in the next day and thats not correct because the amount of 100 MB is caused in the day before.
thats my problem
The reason for this is that normally accouting data is from the Accounting-Stop packets that the NAS (here: RouterOS) sends to the RADIUS server. And this packet does contains the complete user session (i.e. all online time and data transfer) and is timestamped just when the connection is dropped. That is, the RADIUS server (where the accounting data is collected) doesn’t get to know anything about the session until it’s finished. This leads to the effect you see.
There’ not much to do about it, though. You could use Interim RADIUS packets to update the stats while the connection still is active (i.e. every 5 minutes or so), but I’m not sure if this could be easily (i.e. out-of-the-box) used to split accounting data the way you want it.
Basically all ISPs (at least those doing tarifs by data volume) have this effect, but none of those I know do have a problem with it. That’s a kind of “jitter” that will level out over some months. It’s right that in theory this could lead to users not using up their “free” volumen for a day or so…
While I’m typing this I come up with an idea how you could do accurate accounting, though (at least if you operate your own RADIUS server):
You could set the Session-Timeout for each session so that the session ultimately is closed (forcefully, from the NAS) just before midnight. Then all accounting data is “billed” to the correct day, and the user could instantly login again. If that’s a feasible solution, is up to you…
I have another idea to drop all user connections at midnight
Is it possible to disconnect all leases per script at midnight (timer or something else)??
You could remotely execute command removing all the interfaces of your connected users with a cronjob.
Login with ssh/telnet → remove ifaces and wait for calls from angry customers.
I wrote a shell script for remote login and command execution.
It works with both ssh and telnet.
It’s bit fancy since I also included dialog menus (I had some spare time).
The whole thing can be easly changed to make it more suitable for running within a cronjob.
Just read the connect_ssh and connect_telnet functions.