Memory

Check memory and swap usage on Windows or Linux Server using SNMP queries

Description:

This plugin can check memory and swap usage on Windows or Linux Server using SNMP v1 queries.

Current Version

2.0

Last Release Date

2018-06-02

Compatible With

  • Nagios 3.x
  • Nagios 4.x

Owner

License

GPL


Project Photos
Project Notes
check_snmp_memory is written in Bash and is distributed under the GPLv2 license. This plugin have been created by Yoann LAMY. Usage: ./check_snmp_memory -H xxx.xxx.xxx.xxx -C public -w 80 -c 90 -H ADDRESS Name or IP address of host (default: 127.0.0.1) -C STRING Community name for the host's SNMP agent (default: public) -w INTEGER Warning level for memory in percent (default: 0) -c INTEGER Critical level for memory in percent (default: 0) -h Print this help screen -V Print version and license information This plugin uses the 'snmpget' command included with the NET-SNMP package. This plugin support performance data output. If the percentage of the warning and critical levels are set to 0, then the script returns a OK state. This nagios plugins comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of the plugins under the terms of the GNU General Public License v2.
Reviews (6) Add a Review
not very helpful
by nereid, December 31, 2014

On linux system this plugin creates false alerts by exceeding thresholds without any reason. The way the memory usage is calclulated is just plain wrong. It tries to tell us that most systems have 98% usage just because the buffers for I/O are using them but they have to be subtracted before taking the thresholds into account.



Works Great, Quick Question
by adbrennick, December 31, 2013

I have this plugin up and running and it works really well. One issue that I am having is that I cannot get the Warning and Critical state to trigger an alarm. I have -w 80 -c 90 set and I have a server at 98% ram utilization, but the status in Nagios shows as Green status. Any suggestions?



Upgrade to support Windows 2000
by cristiano.caruso, June 30, 2013

I do some change to the script to support faulty Windows 2000. Defined 2 new OID: OID_TOTAL_W2K="HOST-RESOURCES-MIB::hrMemorySize" OID_USED_W2K="HOST-RESOURCES-MIB::hrSWRunPerfMem" and then added after MEMORY_USED_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME $OID_TAGMEMORY | $CMD_GREP -i 'Physical Memory|Real Memory' | $CMD_AWK '{ print $1}' | $CMD_AWK -F "." '{print $NF}'` this test: if [ -z "$MEMORY_USED_ID" ]; then MEMORY_USED_ID="0" fi finally, in main block: if [ $MEMORY_USED_ID != "0" ]; then MEMORY_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${MEMORY_USED_ID}` SWAP_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${SWAP_USED_ID}` MEMORY_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${MEMORY_USED_ID}` SWAP_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${SWAP_USED_ID}` MEMORY_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${MEMORY_USED_ID}` SWAP_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${SWAP_USED_ID}` else # Windows 2000 MEMORY_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL_W2K}.0` SWAP_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${SWAP_USED_ID}` MEMORY_UNIT=1024 SWAP_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${SWAP_USED_ID}` MEMORY_USED=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_USED_W2K} | cut -f 4 -d " " |paste -sd+|bc` SWAP_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${SWAP_USED_ID}` fi Maybe isn't best way, but t works. Regards Cristiano



Very cool
by luckyz, March 31, 2012

It needs only one change when deciding whether to notify for WARNING or CRITICAL status: ------------------------ instead of: if [ $MEMORY_USED_REAL_POURCENT -gt $WARNING ] && [ $WARNING != 0 ]; then STATE=$STATE_WARNING this line shall be like this: if [ $MEMORY_USED_REAL_POURCENT -gt $WARNING ] && [ $MEMORY_USED_REAL_POURCENT -lt $CRITICAL ] && [ $WARNING != 0 ]; then STATE=$STATE_WARNING ---------------------------- Also, the value for size should be changed from Go to GB.



produces error.
by Majed, December 31, 2011

on a 12 GB memory produces an error: ./check_snmp_memory.txt -H 172.16.1.100 -C snmp -w 80 -c 90 ./check_snmp_memory.txt: line 123: /usr/bin/bc: No such file or directory ./check_snmp_memory.txt: line 123: /usr/bin/bc: No such file or directory ./check_snmp_memory.txt: line 123: /usr/bin/bc: No such file or directory ./check_snmp_memory.txt: line 123: /usr/bin/bc: No such file or directory Memory usage : Go used for a total of Go (92%), SWAP usage : Go used for a total of Go (45%)| total=12873891840B;10299113472;11586502656;0 used=11957960704B;0;0;0 swap=12575440896B;0;0;0 buffer=0B;0;0;0 cache=0B;0;0;0



Support procotol verson
by n0ts, July 31, 2011

This plugins is very useful. I support procotol version. https://gist.github.com/1097533 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
3.6 (9)
Favorites
2
Views
245,843