creating e-mail every 1st of month with amount of each user

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.

Thank you for help!

I hope my English is good enough to understand…

Nobbe

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

Edgars

i don`t want to use a Radius Server

what’s the problem with that? it will only make your life easier

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. :unamused:

bluenobbe,

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.

Edgars

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.

we will add a new field where you will be able to choose time period when exporting logs to the PDF.

Edgars

It sounds good!!!
When do implement that feature?

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.

Edgars

Fine - but there is no download link … how should I use a software without download?

The MikroTik HotSpot Manager is not an application you can download and install - it’s an online service you just use.

  1. Count the traffic and pay for traffic ($ per MB) in the section “hour cost”
  2. Count the traffic amount from 00:000 to 23:59 every day (one option is to disconnect all users at midnight)

1.there is an idea to implement also MB based cost table;
2.you can see it in the reports if are choosing to show the report for some specific day.

Edgars

  1. 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.

The script is avaliable at:
http://yazzy.yazzy.org/coding/shell/routeros/routeros.txt

I tested it with sh on FreeBSD and Gentoo Linux (where /bin/sh → bash).

Enjoy.