Build precise queries to find exactly what you need
Press ESC to close
Join our next live webinar: “Advanced Nagios Monitoring Techniques” – Register Now
Your review has been submitted and is pending approval.
Different take on Lars Michelsen’s original plugin/script to accommodate monitoring of all available DHCP scopes on your monitored Windows server. You no longer need to add separate service definitions to monitor all available scopes.
Current Version
1.0
Last Release Date
2013-04-22
Owner
JR Morgan
Website
http://liveaverage.com
Download URL
https://gist.githubusercontent.com/liveaverage/82016e5ca00aac2109ac/raw/a1e5a84c8a0ffacf1cf81057a90c071d9a85aa68/check_dhcp_all_pools.sh
License
GPL
Compatible With
It's worth noting a couple of important details: - Nagios 3.x or above is required for the multi-line output generated by this command. - This service check will alarm if any scope is nearing the critical or warning threshold(s) specified command call. If you require per-scope or per-pool alarm configuration, you should use the original plugin created by Lars Michelsen. - Performance Data has been commented out, but is available if you'd like to add it. - Scopes that exist but are not in use (e.g. scopes exclusively used for reservations) are left out of this check.
Some customizing für usage with a Windows Server 2008 R2 (SNMP feature installed): if [ $# -lt 2 ]; then echo "check_dhcp_all_pools" echo "Usage: $0 " echo "Example: WARN at 50 & CRIT at 30 will WARN you when the percentage of free DHCP addresses" echo "is less than or equal to 50% of available addresses and alarm CRITICAL whe the percentage" echo "of free addresses is less than or equal to 30% of available addresses." exit 3 fi IP="$1" COMMUNITY="$2" WARN="$3" CRIT="$4" RET=0 RETW=0 RETC=0 Z=0 STAT=( ) i=0 RESULT="" if [ ${#WARN} -lt 1 ] then WARN=20 fi if [ ${#CRIT} -lt 1 ] then CRIT=10 fi #Get the list of all scopes/subnets from the server: TEMP=($( snmpwalk -v2c -c $COMMUNITY $IP .1.3.6.1.4.1.311.1.3.2.1.1.1 | cut -d " " -f4 )) #Traverse array and get usage information per scope: for i in ${!TEMP[*]};do POOL=${TEMP[$i]} FREEOID=".1.3.6.1.4.1.311.1.3.2.1.1.3.$POOL" USEDOID=".1.3.6.1.4.1.311.1.3.2.1.1.2.$POOL" SNMP_RESULT=`snmpget -v 2c -c $COMMUNITY $IP $FREEOID` FREE=`echo $SNMP_RESULT|cut -d " " -f4` SNMP_RESULT=`snmpget -v 2c -c $COMMUNITY $IP $USEDOID` USED=`echo $SNMP_RESULT|cut -d " " -f4` MAX=`echo "$FREE+$USED" |bc` if [ "$MAX" -ne 0 ]; then PERCFREE=`echo "$FREE*100/$MAX" |bc` PERCUSED=`echo "$USED*100/$MAX" |bc` #Debug: echo "FREE: $FREE USED: $USED MAX: $MAX PERC: $PERCFREE,$PERCUSED" if [ "$PERCFREE" -le "$WARN" -a "$PERCFREE" -gt "$CRIT" ]; then let "RETW += 1" STAT=( "${STAT[@]}" "Warning: $POOL - $PERCFREE% free - $PERCUSED% used - $USED/$MAX - Threshold is $WARN% freen" ) elif [ "$PERCFREE" -le "$CRIT" ]; then let "RETC += 1" STAT=( "${STAT[@]}" "Critical: $POOL - $PERCFREE% free - $PERCUSED% used - $USED/$MAX - Threshold is $CRIT% freen" ) else STAT=( "${STAT[@]}" "OK: $POOL - $PERCUSED% used - $USED/$MAXn" ) fi # elif [ "$MAX" -eq 0 ]; then #Debug for detecting 100% excluded ranges (reservations only): # STAT=( "${STAT[@]}" "OK: $POOL Nothing used, could be excluded" ) fi # Performance-Data PERFDATA="${PERFDATA} | 'Scope Usage' $POOL=$PERCUSED%;$WARN;$CRIT;0;$MAX" # PERFDATA="${PERFDATA} | $POOL OK - Usage: $PERCUSED% ($FREE Addresses of $MAX in pool free) n" done #Evaluate return code: if [ "$RETC" -eq 0 -a "$RETW" -eq 0 ]; then RET=0 RESULT="${RESULT} OK: All scopes finenn" elif [ "$RETW" -ne 0 -a "$RETC" -eq 0 ]; then RET=1 RESULT="${RESULT} Warning: One or more scopes is nearing capacitynn" elif [ "$RETC" -ne 0 ]; then RET=2 RESULT="${RESULT} Critical: One or more scopes is nearing capacitynn" fi ###### Second loop for long service output: for i in ${!STAT[*]};do RESULT="${RESULT} ${STAT[$i]}" done #Echo the total amount of scopes available vs those shown: RESULT="${RESULT} nShowing ${#STAT[@]} of ${#TEMP[@]} configured scopes" echo "$RESULT|$PERFDATA" exit $RET
Only two correction for this, using v1: in line: TEMP=($( snmpwalk -c $COMMUNITY $IP .1.3.6.1.4.1.311.1.3.2.1.1.1 | cut -d " " -f4 )) To: TEMP=($( snmpwalk $IP -v1 -c $COMMUNITY .1.3.6.1.4.1.311.1.3.2.1.1.1 | cut -d " " -f4 )) And in line:76 an 79 From: SNMP_RESULT=`snmpget -v 2c -c $COMMUNITY $IP $USEDOID` To:SNMP_RESULT=`snmpget -v1 -c $COMMUNITY $IP $USEDOID` Thanks.
You must be logged in to submit a review.
To:
From: