Nagios Exchange
  • Home
  • Directory
  • About

Advanced Search

Build precise queries to find exactly what you need

Search Logic

Select compatible versions

Press ESC to close

Sign In Sign Up
Plugins4387Themes and Skins11Add-ons732Documentation283Graphics and Logos36View All Categories
LinuxSecuritySNMPFile SystemCloud
New Listings Recently Updated Listings Most Favored Listings Most Popular Listings Most Rated Listings Most Reviewed Listings
Random Project
Other Tutorials And HOWTOs How To Configure NAGIOS Monitoring Server On Ubuntu
0.0 (0)
69K
RSS Feed
Newest Listings Updated Listings
Top Contributors
LAMY (7)Julien DESMAREST (6)deskwork_itunes142 (4)Davide Lemma (4)Joerg Hoerter (3)
See More
Newest Contributors
Guillaume8723 (1)Salvo (1)SOHA-IT (1)Tsvetomir Tsvetanov (1)Igor Ru (1)
See More
Home > collin hayden
ch

collin hayden

@collinhayden

User Stats

Favorites0

Views

Projects0

No Projects Found
check_proc_mem.sh: check process memory usage

A few suggested changes.

Hi and thanks for a great plugin. I ran into an issue because I had renamed the file from check_proc_mem.sh to just check_proc_mem as I like them w/ no file extension since that is how they commonly are in the plugin directory. This caused an issue in the grep -v portion. I added some things to accommodate this changes, here is the modified script that will work just in case someone else happens to rename it: #!/bin/bash -e ##------------------------------------------------------------------- ## File: check_proc_mem.sh ## Author : Denny ## Description : ## -- ## ## Link: http://www.dennyzhang.com/nagois_monitor_process_memory ## ## Created : ## Updated: Time-stamp: ##------------------------------------------------------------------- SCRIPTNAME=$(basename $0) if [ "$1" = "-w" ] && [ "$2" -gt "0" ] && [ "$3" = "-c" ] && [ "$4" -gt "0" ]; then pidPattern=${5?"specify how to get pid"} if [ "$pidPattern" = "--pidfile" ]; then pidfile=${6?"pidfile to get pid"} pid=$(cat $pidfile) elif [ "$pidPattern" = "--cmdpattern" ]; then cmdpattern=${6?"command line pattern to find out pid"} pid=$(ps -ef | grep "$cmdpattern" | grep -v grep | grep -v ${SCRIPTNAME} | head -n 1 | awk -F' ' '{print $2}') elif [ "$pidPattern" = "--pid" ]; then pid=${6?"pid"} else echo "ERROR input for pidpattern" exit 2 fi if [ -z "$pid" ]; then echo "ERROR: no related process is found" exit 2 fi memVmSize=`grep 'VmSize:' /proc/$pid/status | awk -F' ' '{print $2}'` memVmSize=$(($memVmSize/1024)) memVmRSS=`grep 'VmRSS:' /proc/$pid/status | awk -F' ' '{print $2}'` memVmRSS=$(($memVmRSS/1024)) if [ "$memVmRSS" -ge "$4" ]; then echo "Memory: CRITICAL VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));;;;" $(exit 2) elif [ "$memVmRSS" -ge "$2" ]; then echo "Memory: WARNING VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));;;;" $(exit 1) else echo "Memory: OK VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));;;;" $(exit 0) fi else echo "${SCRIPTNAME}" echo "" echo "Usage:" echo "${SCRIPTNAME} -w -c " echo "" echo "Below: If tomcat use more than 1024MB resident memory, send warning" echo "${SCRIPTNAME} -w 1024 -c 2048 --pidfile /var/run/tomcat7.pid" echo "${SCRIPTNAME} -w 1024 -c 2048 --pid 11325" echo "${SCRIPTNAME} -w 1024 -c 2048 --cmdpattern "tomcat7.*java.*Dcom"" echo "" echo "Copyright (C) 2014 DennyZhang ([email protected])" exit fi ## File - check_proc_mem.sh ends

Reviewed 10 years ago

No Favorites Found

Copyright © 2009-2025 Nagios Enterprises, LLC. All rights reserved.

Privacy PolicyTerms of UseTrademarks