FreeRadius Online Users MRTG Not over SNMP
it was a long time since i was looking for some MRTG Diagram for Users who are On line at our FreeRadius radius system , The FreeRadius maintainer Alan Dekok says that FreeRadius SNMP subsystem have no support for exporting On line users , little search on FreeRadius users list shows that a lot of other users have the same problem , well , this document describe how you can have MRTG of your on line users .
i was running Mysql as database and FreeRadius 1.0.5 as server .
well , MRTG is some sort of cool software , using it isn't that kind of hard that you might imagine , in fact its really easy to create some (easy) Custom Graphs with MRTG .
for this to work you need MRTG installed , not that we are not going to use SNMP at anyway . also note that this document describe using MRTG and Mysql database server , the very little application that i wrote can be tweaked a bit to work over Postgres and other databases .
first we need this little application , you can copy paste or optimize it somehow ( FIXME : always shown +1 on line user ) and put it under /usr/bin/radmrtg for example :
#!/bin/bash
mysql radius -e "select username from radacct where AcctTerminateCause like '';" | wc -l
mysql radius -e "select * from radacct where AcctTerminateCause like '' and Username not like '%@%';" | wc -l
uptime
echo "FreeRadius"
NOTE: the second mysql line just separate Real Users , you can comment or remove that line if you did not have any realm or you have no care about it , just cut of the second line
and your /etc/MRTG.conf must look like this :
######################################################################
# Multi Router Traffic Grapher -- Sample Configuration File
######################################################################
# This file is for use with MRTG-2.5.4c
# Global configuration
WorkDir: /var/www/admin/dialup_admin/htdocs/MRTG
WriteExpires: Yes
Target[load]: `/usr/bin/radmrtg`
MaxBytes[load]: 130
Title[load]: Online Users
WithPeak[load]: wmy
PageTop[load]: Online Users
Options[load]: growright, gauge, nopercent, unknaszero
YLegend[load]: Load
ShortLegend[load]: ;
LegendI[load]: Total Users:
LegendO[load]: Realm Users:
you see that "Target[load]: `/usr/bin/radmrtg`" Line ? The secret of MRTG Custom Graphs lies in this line ;)
now run MRTG , give it a few minute and it will work , as expected .
please , if you have any sort of comment ( specially in patch form ;) ) shot a comment here .