Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Directory
macko003
bymacko003, November 2, 2021
First of all, thanks your work!
As I see if you use --cmdpattern, the script counts only the first process' mem usage. So if you run httpd or other services with fork/child calculate with it.
I prefer to send back the warning and critical in perform data. So I modified the script a bit.
if [ "$memVmRSS" -ge "$4" ]; then
echo "Memory: CRITICAL VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));$(($2*1024*1024));$(($4*1024*1024));;"
$(exit 2)
elif [ "$memVmRSS" -ge "$2" ]; then
echo "Memory: WARNING VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));$(($2*1024*1024));$(($4*1024*1024));;"
$(exit 1)
else
echo "Memory: OK VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));$(($2*1024*1024));$(($4*1024*1024));;"
$(exit 0)
fi
As I see if you use --cmdpattern, the script counts only the first process' mem usage. So if you run httpd or other services with fork/child calculate with it.
I prefer to send back the warning and critical in perform data. So I modified the script a bit.
if [ "$memVmRSS" -ge "$4" ]; then
echo "Memory: CRITICAL VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));$(($2*1024*1024));$(($4*1024*1024));;"
$(exit 2)
elif [ "$memVmRSS" -ge "$2" ]; then
echo "Memory: WARNING VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));$(($2*1024*1024));$(($4*1024*1024));;"
$(exit 1)
else
echo "Memory: OK VIRT: $memVmSize MB - RES: $memVmRSS MB used!|RES=$(($memVmRSS*1024*1024));$(($2*1024*1024));$(($4*1024*1024));;"
$(exit 0)
fi