[Xymon] OpenVPN Monitoring
Oliver
r.oliver at web.de
Thu Aug 16 14:14:38 CEST 2012
Dear All,
I have tried to find a way to Monitor my OpenVPN Servers. The hard thing
was that OpenVPN is a service that is running via UDP by default. So
here is the script I've come up with:
-----------
#!/bin/sh
BBHTAG=openvpn # What we put in bb-hosts to trigger this test
COLUMN=$BBHTAG # Name of the column, often same as tag in bb-hosts
OPENVPNPORT=1194
$BBHOME/bin/bbhostgrep $BBHTAG | while read L
do
set $L # To get one line of output from bbhostgrep
HOSTIP="$1"
MACHINEDOTS="$2"
MACHINE=`echo $2 | $SED -e's/\./,/g'`
COLOR=green
MSG="$BBHTAG status for host $MACHINEDOTS"
#... do the test, perhaps modify COLOR and MSG
PROGCHECK=`which nc`
if [ -z "$PROGCHECK" ]; then
MSG="${MSG}
`echo "Program \"nc\" not found."`
"
fi
/bin/echo -ne
"\x38\x01\x01\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00" | /bin/nc
$MACHINEDOTS $OPENVPNPORT -u -w 1 | /usr/bin/hexdump -v -e '"\\""x" 1/1
"%02x" ""' | $GREP -q
'\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00'
if [ "$?" != "0" ]; then
COLOR=red
MSG="${MSG}
`echo "OpenVPN offline"`
"
else
MSG="${MSG}
`echo "OpenVPN online"`
"
fi
$BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date`
${MSG}
"
done
exit 0
-----------
Could someone try this out whether it works?
Thanks in advance!
More information about the Xymon
mailing list