Last Updated: 23-JUN-2016 / 11:20 am
Recently at a network where multiple NAS were implemented with single centralized billing system(radius Manager with Free radius as backend engine) , I configured MRTG to create graphs for each NAS and added Mikrotik 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 system, 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 # Script to query online conencted users in freeradius # Syed Jahanzaib / aacable at hotmail dot com # http://aacable . wordpress . com SQLUSER="root" SQLPASS="PASSWORD" SQL_DB=radius SQL_SERVER=127.0.0.1 SQL_ACCOUNTING_TABLE=radacct # acquire online users whose accnt-stop time is null so consider it online : ) SESSIONS=<code>mysql -u$SQLUSER -p$SQLPASS --skip-column-names -e "use radius; SELECT username FROM $SQL_ACCOUNTING_TABLE WHERE acctstoptime IS NULL;" |wc -l`</code> 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 by ZAIB (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