Problem this snippet solves:
This external monitor script runs an snmpget to pool members and marks the members up or down based upon the result. Specifically created for this GTM/APM use case, but can be modified as needed.
How to use this snippet:
copy the contents of this file into /config/monitors/snmp-check, and then in the external monitor configuration, reference the monitor and provide the following variable key/value pairs:
result=<result>
community=<community>
OID=<oid>
Code :
#!/bin/sh
#
# (c) Copyright 1996-2005 F5 Networks, Inc.
#
# This software is confidential and may contain trade secrets that are the
# property of F5 Networks, Inc. No part of the software may be disclosed
# to other parties without the express written consent of F5 Networks, Inc.
# It is against the law to copy the software. No part of the software may
# be reproduced, transmitted, or distributed in any form or by any means,
# electronic or mechanical, including photocopying, recording, or information
# storage and retrieval systems, for any purpose without the express written
# permission of F5 Networks, Inc. Our services are only available for legal
# users of the program, for instance in the event that we extend our services
# by offering the updating of files via the Internet.
#
# @(#) $Id: sample_monitor,v 1.3 2005/02/04 18:47:17 saxon Exp $
#
#
# these arguments supplied automatically for all external pingers:
# $1 = IP (nnn.nnn.nnn.nnn notation or hostname)
# $2 = port (decimal, host byte order)
# $3 and higher = additional arguments
#
# $MONITOR_NAME = name of the monitor
#
# In this sample script, $3 is the regular expression
#
#These lines are required to control the process ID of the monitor
pidfile="/var/run/$MONITOR_NAME.$1..$2.pid"
if [ -f $pidfile ]
then
kill -9 `cat $pidfile` > /dev/null 2>&1
fi
echo "$$" > $pidfile
#Since version9 uses the ipv6 native version of the IP address, parse that down
#for usage
node_ip=`echo $1 | sed 's/::ffff://'`
#Log the variables for debugging
#echo IP= $node_ip Port =$2 OID= $OID comm= $community result= $result >> /var/tmp/test
#Create a variable called answer that contains the result of the snmpwalk.
answer=`snmpget $node_ip -c $community -O v $OID | awk '{print $2}'`
#Log the answer for debugging
#echo Answer= $answer >> /var/tmp/test
if [ $answer -lt $result ]
then
echo "up"
fi
rm -f $pidfile
Tested this on version:
No Version Found