# External Health monitor - check SNMP info from servers

**URL:** <https://community.a10networks.com/t/external-health-monitor-check-snmp-info-from-servers/329>\
**Category:** System\
**Tags:** snmp, health-monitor\
**Created:** [September 16, 2015, 7:22pm UTC](https://community.a10networks.com/t/external-health-monitor-check-snmp-info-from-servers/329 "2015-09-16T19:22:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WilsonBT](https://avatars.discourse-cdn.com/v4/letter/w/c67d28/32.png) [@WilsonBT](https://community.a10networks.com/u/WilsonBT)\
**Post date:** [September 16, 2015, 7:22pm UTC](https://community.a10networks.com/t/external-health-monitor-check-snmp-info-from-servers/329/1 "2015-09-16T19:22:39Z")

</div>

Hello, I´m having the following requierement: Need to get the snmp information of the servers I´m load balancing, and when the CPU and MEMORY pass over 90%, put this server on maintenance mode, so won´t receives new clients, but still maintains the connection for currents clients. Then, after the CPU and memory decreases below 70%, the server will pass again to a Enable status. I have this template, but is only for enable - disable servers. #! /bin/bash CPU\_OID=.1.3.6.1.4.1.22610.2.4.1.3.5.0 MEM\_USAGE\_OID=.1.3.6.1.4.1.22610.2.4.1.2.2.0 MEM\_TOTAL\_OID=.1.3.6.1.4.1.22610.2.4.1.2.1.0 CPU=`/usr/bin/snmpget -v2c -c public -OqUv ${HM_SRV_IPADDR} ${CPU_OID}` MEM\_USAGE=`/usr/bin/snmpget -v2c -c public -OqUv ${HM_SRV_IPADDR} ${MEM_USAGE_OID}` MEM\_TOTAL=`/usr/bin/snmpget -v2c -c public -OqUv ${HM_SRV_IPADDR} ${MEM_TOTAL_OID}` MEM\_USAGE=`expr $MEM_USAGE \* 100` MEM=`expr $MEM_USAGE / $MEM_TOTAL` THRESH\_CPU=80 THRESH\_MEM=90 echo “$CPU” echo “$MEM” if [$CPU -lt ${THRESH\_CPU} -a $MEM -lt ${THRESH\_MEM}] ; then #up exit 0 else #down exit 1 fi

---

<div class="post-metadata">

**Author:** ![dshin](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dshin](https://community.a10networks.com/u/dshin)\
**Post date:** [September 21, 2015, 9:47pm UTC](https://community.a10networks.com/t/external-health-monitor-check-snmp-info-from-servers/329/2 "2015-09-21T21:47:34Z")

</div>

The script you provided above is based on server side configuration. I do not think we will be able to control from the ADC perspective. We have another solution to your requirements and its called “SNMP-based load balancing”. This feature is available in 2.7.1 and above which offers the ability to query CPU utilization or memory utilization and dynamically set the weight values of the servers.

Here is an example of a Shell script for SNMP-based load balancing. This script uses the results from queries to the UC-SNMP-MIB MIB module.

#!/bin/sh

dst=“$HM\_SRV\_IPADDR”

#dst=“$HM\_SRV\_IPADDR:$HM\_SRV\_PORT”

# Community String

community=“public”

# UC-SNMP-MIB::extResult.1

oid=“.1.3.6.1.4.1.2021.8.1.100.1” (Note: This has to be updated based on server OID information)

function check\_value {

echo “$output”

value=`echo $output | sed 's/INTEGER: //'`

echo “value” = “$value”

if [[“$value” =~ “\[1\]\*$” ]]; then

# echo “digit string”

if [$value -ge 0 -a $value -lt 125]; then

echo “Good”

exit $value

fi

fi

}

echo “/usr/bin/snmpget -v2c -c "$community" -Ov "$dst" $oid”

output=$(/usr/bin/snmpget -v2c -c “$community” -Ov “$dst” $oid)

if [0 != $?]; then

exit -1

fi

check\_value

# success

echo “Mark server down”

exit -1

* * *

1. [:digit:]
