Forum Discussion

ecce's avatar
ecce
Icon for Cirrostratus rankCirrostratus
Jul 13, 2019

Is this a good way to health monitor SNMP?

I needed a way to check if SNMPd was running on log servers (in my case - Splunk). I understand you need an external monitor for this, so I wrote one and would like input on the script and the complete solution. I didn't want to post this in the code section since I'm not sure if this is a good solution.

 

The script is checking if SNMP returns a value on SNMPGET for an OID you specify in the script file. I used an uptime OID. If anything is returned, the server is considered up. In it times out, it is considered down.

 

Any suggestions you might have is appreciated!

 

#!/bin/sh


# User-defined variables
oid=".iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.0"
community="really-secret-community"


# kill of the last instance of this monitor if hung and log current pid
PIDFILE="/var/run/`basename ${0}`.${IP}_${PORT}.pid"
if [ -f $PIDFILE ]
then
    kill -9 `cat $PIDFILE` > /dev/null 2>&1
fi
echo "$$" > $PIDFILE


# Strip IPv6 prefix off node IP
node_ip=$(echo $1 | sed 's/::ffff://');


# Get SNMP Value
snmpget -O qv -t 1 -r 1 -v 2c -c $community $node_ip:161 $oid &>/dev/null


# Evaluate
status=$?
if [ $status -eq 0 ]
then
    echo "up"
fi


rm -f $PIDFILE
exit


1 Reply

  • SWJO's avatar
    SWJO
    Icon for Cirrostratus rankCirrostratus

    Hi

     

    I`m not familiar with this script.

     

    but I think there is more easy way.

     

    create Health monitor checking snmp. --> support on LTM

     

    And VIP and Pool member`s port are set 514.

     

    then when snmp monitor goes down, syslog traffic to splunk member will be down.

     

    about snmp monitor you have lots of option.

     

    Monitor

    1. create udp monitor and alias port 161

    2. create snmp DCA or snmp DCA base

     

    Virtual server

    when you create virtual server you also have 3 option.

    1. type performance L4

    2. type standard using UDP profile which enabled 'datagram LB'

    3. type stateless