Forum Discussion
External monitor snmp - Member UP/DOWN
This external monitor uses the threshold of CPU and Memory for classify the pool member as available or down. I calculated the results of snmp to have the desired percentage.
Follow the steps:
1. Create the arquive called "script_snmp" in "/config/monitors/" and copy the script below:
!/bin/sh
IPv6/IPv4 compatibility prefix (LTM passes addresses in IPv6 format)
IP=`echo ${1} | sed 's/::ffff://'`
PIDFILE="/var/run/`basename ${0}`.${IP}_${PORT}.pid"
kill of the last instance of this monitor if hung and log current pid
if [ -f $PIDFILE ]
then
kill -9 `cat $PIDFILE` > /dev/null 2>&1
fi
echo "$$" > $PIDFILE
send request & check for expected response
snmpwalk -v 2c -c community ${IP} .1.3.6.1.4.1.2021.4.5.0 > /var/tmp/monitor/mem_size_${IP}.log
snmpwalk -v 2c -c community ${IP} .1.3.6.1.4.1.2021.4.6.0 > /var/tmp/monitor/mem_avail_${IP}.log
snmpwalk -v 2c -c community ${IP} .1.3.6.1.4.1.2021.11.11 > /var/tmp/monitor/cpu_${IP}.log
mark node UP if expected response was received
size=`cat /var/tmp/monitor/mem_size_${IP}.log | cut -f4 -d" "`
avail=`cat /var/tmp/monitor/mem_avail_${IP}.log | cut -f4 -d" "`
expr $avail \* 100 / $size > /var/tmp/monitor/percentage_${IP}
memory=`cat /var/tmp/monitor/percentage_${IP}`
cpu=`cat /var/tmp/monitor/cpu_${IP}.log | cut -f4 -d" "`
if [ "$memory" -le "85" ]; then
if [ "$cpu" -ge "20" ]; then
echo "UP"
rm -f $PIDFILE
elif [ "$DEBUG" -eq "1" ]; then
echo "The threshold CPU has reached for $IP - DOWN" | logger -p local0.debug
rm -f $PIDFILE
fi
else
echo "The threshold MEMORY has reached for $IP - DOWN" | logger -p local0.debug
rm -f $PIDFILE
fi
2. Give permission by execution: chmod 755 script_snmp;
3. Create folder called "monitors" in "/var/tmp";
4. In LTM/Monitors, click in "CREATE"
5. write the monitor name
6. Choice the monitor external type
7. Set the runtime
8. Set the path of script
9. In variable, set the value: DEBUG=1
10. Click in "FINISH"
11. Set the monitor the Pool
Feel free to improve the script
- hooleylistCirrostratusHi Luis,
- Luis_Araujo_560Nimbostratus
Hi Aaron,
Thank for reponse!!!
I insert the PIDFILE in end script because not was functioning the script.
I think that "echo" was classify the pool member as "UP"
You can add thus script in codeshare.
Thanks!!!!
- nanbee_109009NimbostratusGreat script, thanks for sharing.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com