Custom bandwidth monitoring in Radius Manager

Custom bandwidth monitoring in Radius Manager

“I could not possibly have used so much bandwidth” is a phrase I hear often. Until now it has been cumbersome and sometimes impossible to show hotspot and wireless users their own usage history using the standard radius manager reports.

As a result I decided to write a small set of scripts to monitor and display bandwidth usage of radius manager accounts.

The radius manager database does not contain granular usage records since radius manager does not keep uniform time period records. Each time a session is disconnected a new record is created in the radacct table. Since the time-span of this record depends on the actual connection duration it could span from a few seconds to more than a day.  This means that it is impossible to get granular hourly or daily stats from this table.

My solution is simple. I use a Perl script to process the radacct table on a regular interval. When I read the table I gather the sum of all in and out bytes for each user, irrespective of how many sessions they initiated since my last check.

I then compare the new totals to the previous totals. Since I run the script at a regular interval, say 5 minutes, I thus know how much bandwidth this user has consumed in the last 5 minutes.

I then summarize this data into my own set of tables where I keep hourly, daily and monthly totals for each user. This script is called from a cron task so runs every five minutes, ensuring I have accurate and consistent statistics.

I then wrote some HTML (with some PHP and jQuery) to give me a summary of each user’s usage for a given period (hour, day or month). I then allow the end user to sort this by various columns.

To make the data retrieved more relevant I also read the service details from the rm_users and rm_services tables. This allows me to show what the user’s monthly limit is, and to then show a % used value in the results. User rows that are over a certain threshold (ay 90% used) are then highlighted in a different color.

I also wrote a graph component which will show a highlighted user’s usage at an hourly level over any given day or at a daily level for a given month.finally I show the actual session usage records from the radacct table below the graph

This allows users to monitor their own usage. From an ISP management perspective this view allows admins to quickly bring up usage history for an individual account, and to zero in on accounts about to be capped, etc. Both hotspot and PPoE accounts are monitored, and can be reported on.

15 thoughts on “Custom bandwidth monitoring in Radius Manager

  1. Hi,

    Your Custom bandwidth monitoring in Radius Manager looks like exactly the thing I need, where can I get it and is it free ?


  2. Hi Rolf,

    I will be making these available once I have had a chance to tidy it up a bit.
    Since the original post I have extended the scripts further to include custom notifications per user, annual and previous month comparisons, etc.


  3. At this point, I’m going to hack Bandwidthd to accomplish the same thing, but I would much rather get the information straight from the source instead of having to rely on accurate DHCP leases.

  4. I started writing my own script, but I’ve only managed to do the polling in Python, some very basic graphing in PHP and some very basic input with jQuery. It’s taking me a while to develop since I’m new to all this. Let me know if you want the code I have so far to take my hacked together solution to the next level.

  5. Can you pls provide scripts done already…
    It looks fantastic, and I want to test this in my system.

  6. Hi Imel

    I had the same problem with clients: “I could not possibly have used so much bandwidth.”

    So I have decided to write a custom help desk software package in java which works fantastic and way faster than the actual radius manager web application. It links up with it’s own database (MySQL), radius manager’s database (MySQL) and the ready desk database (MSSQL). It uses an automated process when topping up client profiles, logging new support tickets on ready desk and has a lot of tools included to do troubleshooting on client connections as well as tools to do remote support to client computers on the same network.

    I have also written a separate automation tool in java to build a daily usage report. It sends out client cap usage notifications via e-mail and if a profile is out of cap, an sms is sent to the client.

    I have discovered lately that some of the total limits (10% of the client profiles), when calculated based on the client’s usage, does not match up with the total limits in radius manager when viewing the client’s profile there. For eg.: In the help desk software a client profile may show that he/she has 1.14 Gb left but that same profile on radius manager shows 305 Mb cap left. The other 90% of profiles displays correctly. Can you please advise me on where to start looking to get this resolved?

    Thank you very much for your post above. I knew I was not the only one with this issue.

  7. Hi Kobus, radius manager is not perfect when it comes to counting traffic, nor is it real time.
    I use another means to record actual traffic usage as it leaves and enters the network.
    This gives me realtime 100% accurate usage, and allows me to capture usage by protocol, destination, etc, irrespective of port, protocol, etc.

  8. Hi,

    Is it possible to graph the usage for regular users(not hotspot(prepaid).


  9. shiva :Can you pls provide scripts done already…It looks fantastic, and I want to test this in my system.

    Are you planning to share it? I am interested in it.

  10. Hi,

    Will you upload your script to help us out? I see its already been a year and it seems we are still struggling.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.