DHCP and BOOTP

check_dhcp_all_pools.sh

Description:

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

Compatible With

  • Nagios 3.x
  • Nagios 4.x

Owner

License

GPL


Project Files
Project Photos
Project Notes
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.
Reviews (2) Add a Review
Customized for better PERFDATA and STATUS output
by Goldie2009, June 30, 2015

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



Very Good
by Pereira, September 30, 2014

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.



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.7 (3)
Favorites
0
Views
28,918