Check Memory Usage 94% used

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
shean71
Posts: 10
Joined: Fri Mar 25, 2011 9:14 am

Check Memory Usage 94% used

Post by shean71 »

Hi All,

Please help on this.
I'm using Nagios Core v3.2.0 installed in SLES10. And the Remote Client installed in RHEL.
And i found that the Monitoring of Service Status for Memory Usage in Nagios is inccorrect.

Nagios Monitoring:
Host:mypc001 OS:Linux:Memory:-:Usage:- OK: 94 % Memory used

OS Level:
But the actual memory usual in OS level is 40% Memory used
# free -m
total used free shared buffers cached
Mem: 7829 3149 4680 0 179 2074
-/+ buffers/cache: 895 6934
Swap: 10015 0 10015


and currently I'm using check_memory.sh as below:
=====================================================================
#!/bin/sh
#
# Prueft Memory-Auslastung anhand free


# Uebergabevariablen:
#
# $1 Warning-Schwellenwert %
# $2 Critical-Schwellenwert %
#
# -----------------------------------------------------

if [ $# -lt 2 ]; then
echo "Usage: $0 with params for warning in % and critical in % : $0 90 95"
exit 2
fi


mem_total=`free -m | grep Mem: | awk '{ print $2}'`
mem_used=`free -m | grep Mem: | awk '{ print $3}'`

let perc_used=100*$mem_used/$mem_total

if [ $perc_used -gt $2 ]
then
echo "Critical: $perc_used % Memory used"
exit 2
fi

if [ $perc_used -gt $1 ]
then
echo "Warning: $perc_used % Memory used"
exit 1
else
echo "OK: $perc_used % Memory used"
exit 0
fi

=====================================================================
Attachments
OS Level memory used
OS Level memory used
check memory02.JPG (15.32 KiB) Viewed 3131 times
Nagios Monitoring Memory used
Nagios Monitoring Memory used
check memory01.JPG (27.58 KiB) Viewed 3131 times
Thanks & Regards,
SHEAN
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Check Memory Usage 94% used

Post by mguthrie »

I'm not a huge shell scripter, but I'd add a few debugging checks to see what the actual values are that it's figuring. I'm guessing it's just a simple logic error.

Code: Select all

echo "Var 2 is $2"
echo "Used is $perc_used"  

if [ $perc_used -gt $2 ]
then
echo "Critical: $perc_used % Memory used"
exit 2
fi
shean71
Posts: 10
Joined: Fri Mar 25, 2011 9:14 am

Re: Check Memory Usage 94% used

Post by shean71 »

Hi mGuthrie,

The result show as below:
OS:Linux:Memory:-:Usage:- Var 2 is -w



The current shell script as below:
=====================================================================
if [ $# -lt 2 ]; then
echo "Usage: $0 with params for warning in % and critical in % : $0 90 95"
exit 2
fi


mem_total=`free -m | grep Mem: | awk '{ print $2}'`
mem_used=`free -m | grep Mem: | awk '{ print $3}'`

let perc_used=100*$mem_used/$mem_total

echo "Var 2 is $2"
echo "Used is $perc_used"


if [ $perc_used -gt $2 ]
then
echo "Critical: $perc_used % Memory used"
exit 2
fi



if [ $perc_used -gt $1 ]
then
echo "Warning: $perc_used % Memory used"
exit 1
else
echo "OK: $perc_used % Memory used"
exit 0
fi
=====================================================================
Attachments
Var 2 is -w
Var 2 is -w
check memory03.JPG (10.65 KiB) Viewed 3103 times
Thanks & Regards,
SHEAN
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Check Memory Usage 94% used

Post by mguthrie »

Ok, I think I see the problem. If you can show me what you actually passed this command as an argument I could confirm it. Right now your script is asking: Is '-w' less than 2?. You probably don't need the -w or -c arguments, just pass it the integers and see if that works better.
shean71
Posts: 10
Joined: Fri Mar 25, 2011 9:14 am

Re: Check Memory Usage 94% used

Post by shean71 »

Same result: OK: 90 % Memory used
Thanks & Regards,
SHEAN
jwoon
Posts: 11
Joined: Tue Jan 19, 2010 10:47 am

Re: Check Memory Usage 94% used

Post by jwoon »

Hi,

Anyone here can share those scripts to monitor cpus and memory?

Are there already built in templates I can use?

It is a little frustrating and time wasting from my side to keep on searching and not finding any.

It just gives an impression that Nagios is not that user friendly.

Appreciate your help.
shean71
Posts: 10
Joined: Fri Mar 25, 2011 9:14 am

Re: Check Memory Usage 94% used

Post by shean71 »

You may refer to this site: http://nagios.manubulon.com/
Thanks & Regards,
SHEAN
jwoon
Posts: 11
Joined: Tue Jan 19, 2010 10:47 am

Re: Check Memory Usage 94% used

Post by jwoon »

Ah... am giving up on nagios already. Looks like good stuff don't come cheap. lol.

Enjoy your nagios journey.
Locked