#!/bin/sh
#
#
# This required the radclient utility:
#
# http://www.freeradius.org
#
## Add to the hobbitserver.cfg in the TEST2RRD section: radius=tcp, this will show a graph of respond time.
## Built on Solaris 10.
COLUMN=radius
### Radius User here
RADIUSUSER=<USERNAME>
### Radius Password here
RADIUSPASS=<passwd>
### Radius shared password here
RADIUSSECRET=<shared passwd>
TIMEOUT=10
$BBHOME/bin/bbhostgrep --no-down ${COLUMN} |
while read L
do
set $L
IP="$1"
HOSTNAME="$2"
COLOR=green
/bin/ptime /usr/local/bin/radclient -t $TIMEOUT $IP auth $RADIUSSECRET >$BBTMP/${COLUMN}.out 2>&1 <<EOF
User-Name = $RADIUSUSER
User-Password = $RADIUSPASS
EOF
SECONDS=`egrep "^real" $BBTMP/${COLUMN}.out | awk '{printf $2}'`
if test $? -ne 0
then
COLOR=red
MSG="Radius query failed
`cat $BBTMP/${COLUMN}.out`
Seconds: ${SECONDS}
"
else
COLOR=green
MSG="Radius query succeeded
`cat $BBTMP/${COLUMN}.out`
Seconds: ${SECONDS}
"
fi
$BB $BBDISP "status $HOSTNAME.$COLUMN $COLOR `date`
$MSG"
$RM $BBTMP/${COLUMN}.out
done
exit 0