Recently at a network where multiple NAS were implemented with single centralized billing system(radius Manager with Free radius as backend engine) , I had many mrtg base graphs for each NAS, and DUDE system to monitor various instances of the target systems, but there was no single graph to monitor overall ONLINE users of all NASES. MRTG was configured on main Billing ssytem, to sort this I used the following bash script and tag it with the mrtg cfg script.
SCRIPT TO PRINT ONLINE SESSIONS IN FREERADIUS
First create the script
chmod +x /temp/online.sh
Now paste the following code, [make sure to change the IP, ID and Password]
Note: I used this script for Radius Manager base freeradius billing system.
#!/bin/bash SQL_USERNAME=radius_username SQL_DATABASE=radius SQL_PASSWORD=your_password SQL_SERVER=127.0.0.1 SQL_ACCOUNTING_TABLE=radacct BACK_DAYS=3 SESSIONS=`mysql -BN -u$SQL_USERNAME -p$SQL_PASSWORD -h $SQL_SERVER $SQL_DATABASE -e \ "SELECT COUNT(*) FROM $SQL_ACCOUNTING_TABLE \ WHERE acctstoptime IS NULL \ AND Acctstarttime > NOW() - INTERVAL $BACK_DAYS DAY;"` echo $SESSIONS echo $SESSIONS
Save & Exit.
MRTG.CFG FILE TO GENERATE MRTG GRAPH
Now create a MRTG cfg file and tag it with your master mrtg config file or run it as individual , its up to you and your local design.
#Radius.cfg # Total Radius Users Target[Radius.users]: `/temp/online.sh` Title[Radius.users]: Central Billing System Logged in Users (Total) PageTop[Radius.users]: <H1> Central Billing System Logged in Users (Total)</H1> MaxBytes[Radius.users]: 1000 Colours[Radius.users]: B#8888ff,B#8888ff,B#5398ff,B#5398ff Options[Radius.users]: gauge,nopercent,noo,integer,growright LegendI[Radius.users]: Radius Logged in Users LegendO[Radius.users]: YLegend[Radius.users]: Radius Logged in Users (Total) Legend1[Radius.users]: Radius Logged in Users (Total) Legend2[Radius.users]: Unscaled[Radius.users]: ymwd