Linux

check physical memory

Description:

Check physical memory using shell script. Memory is displayed as a percentage.

Current Version

Last Release Date

June 16, 2009

Compatible With


Project Files
Project Notes
Quick and easy to implement, does not require any additional packages. Usage: check_mem [-w|--warning] [-c|--critical] example: check_mem -w 10 -c 5 Gives WARNING on 10% free phsical memory and CRITICAL on 5% free memory
Reviews (4) Add a Review
It's not working on my side
by Kleri, July 31, 2021

Hello all, I have these errors when I try to implement the script on my server: Ubuntu 18 and Nagios 4.4.6 Website: (No output on stdout) stderr: /usr/local/nagios/libexec/check_mem01.sh: 23: /usr/local/nagios/libexec/check_mem01.sh: [[: not found Localhost -> Service define service { use local-service host_name localhost service_description Memory Usage check_command check_memory!95%!97% } "If I change the last line by check_memory -w 10 -c 5 the system shows me: 'check_memory -w 10 -c 5' specified in service 'Memory Usage' for host 'localhost' not defined anywhere! commands.cfg: define command { command_name check_memory command_line $USER1$/check_mem01.sh -w -c } Thanks in advance!



Great, but can't get it to graph properly
by georged, October 31, 2018

I used Foncu method to get graph, but my graph is stuck on 3.96Kb, not able to get it to display proper values for the Memory Graph inside Nagios, what needs to change for it to display properly?



Adding Perfdata
by foncu, December 31, 2017

Good plugin, I added Perfdata for NagiosGraph replacing the final 3 IF by this code: if [[ "$percent" -le $critical ]]; then echo "CRITICAL - $free MB ($percent%) Free Memory | total=${total}MB used=${used}MB" exit $STATE_CRITICAL elif [[ "$percent" -le $warning ]]; then echo "WARNING - $free MB ($percent%) Free Memory | total=${total}MB used=${used}MBÂș" exit $STATE_WARNING elif [[ "$percent" -gt $warning ]]; then echo "OK - $free MB ($percent%) Free Memory | total=${total}MB used=${used}MB" exit $STATE_OK fi



Very useful!
by Tasslehoff, March 31, 2012

Good plugin, on Windows I control paging and physical memory through scripts included into nscclient++, you script is a good way to do the same control on linux. I made a couple of changes because I found more useful control busy memory without considering cache and buffers, so I changed used variable (lin 60) with this: used=`free -m | head -3 |tail -1 | gawk '{print $3}'` I changed the free memory variable (line 62) with this: let free=$total-$used Thanks again for plugin and for your time :)



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.8 (5)
Favorites
1
Views
179,809