May 16 2009
Graph Number of Freeradius Sessions in MRTG
You can easily graph your Freeradius number of active sessions with a simple shell script if you store accounting data in a SQL database.
Use the script below for Mysql:
#!/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=5 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
Some sessions never get closed due to random packet losses, or network disconnections between the NAS and the Radius server. Sessions older than $BACK_DAYS are ignored to get the most accurate value.
The script will display the number of active sessions. Graph this one value in MRTG.