BIG-IP Remote Poll And Mail Script

Problem this snippet solves:

This script monitors the CPU temperature, sending email when the temperature exceeds the threshold or the polling cycle fails.

How to use this snippet:

  1. Install script on remote system with appropriate permissions.
  2. Edit the THRESHOLD, COMMUNITY, BIGIP_ADDR, and MAILTO variable values to match your environment
  3. Configure cron to run the script at the desired interval.

Code :

#! /bin/bash
#
# This code is not supported by F5 Network and is offered under the GNU General Public License.  Use at your own risk.

THRESHOLD=70
COMMUNITY="commstring"
BIGIP_ADDR="192.168.1.100"
MAILTO="sysadmin"

T=`snmpget -v2c -c $COMMUNITY -Ov -Ot -Oe -Oq -OU $BIGIP_ADDR F5-BIGIP-SYSTEM-MIB::sysCpuTemperature.1`
if [ $? -eq 1 ]; then
  mail $MAILTO -s "The snmpget command to BIG-IP at $BIGIP_ADDR failed" << EOF
The snmpget command failed. Verify the system  and network path are viable and that the snmpd service is running
EOF
else
  if [ $T -gt $THRESHOLD ]; then
    mail $MAILTO -s "BIG-IP $BIGIP_ADDR reports CPU temp $T exceeds threshold $THRESHOLD" << EOF 
BIG-IP $BIGIP_ADDR reports CPU temp $T has exceeded the notification threshold $THRESHOLD.  Please investigate ASAP.
EOF
  fi
fi
Published Mar 12, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment