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.