Memory check ubuntu

Hi All

I am quite new to nagios and am having an issue with memory checking using nrpe on an ubuntu 10.4 server. I have a script which works on a centos box but can’t get anything to work on the ubuntu box.

I found a site with a script and details of config (main script at bottom) serverfault.com/questions/195815 … figuration

I have it all setup but I can’t get any repsonce if i run command[check_memory]=/usr/lib/nagios/plugins/check_memory.sh -w 85 -c 90
i get this -w: command not found

Can anyone help here

Thanks

Glenn

#!/bin/bash

Script to check memory usage on Linux. Ignores memory used by disk cache.

Requires the bc command

print_help() {
echo "Usage:"
echo "-w] Warning level as a percentage"
echo "-c] Critical level as a percentage"
exit 0
}

while test -n “$1”; do
case “$1” in
–help|-h)
print_help
exit 0
;;
-w)
warn_level=$2
shift
;;
-c)
critical_level=$2
shift
;;
*)
echo "Unknown Argument: $1"
print_help
exit 3
;;
esac
shift
done

if “$warn_level” == “” ]; then
echo "No Warning Level Specified"
print_help
exit 3;
fi

if “$critical_level” == “” ]; then
echo "No Critical Level Specified"
print_help
exit 3;
fi

free=free -m | grep "buffers/cache" | awk '{print $4}'
used=free -m | grep "buffers/cache" | awk '{print $3}'

total=$(($free+$used))

result=$(echo “$used / $total * 100” |bc -l|cut -c -2)

if “$result” -lt “$warn_level” ]; then
echo "Memory OK. $result% used."
exit 0;
elif “$result” -ge “$warn_level” ] && “$result” -le “$critical_level” ]; then
echo "Memory WARNING. $result% used."
exit 1;
elif “$result” -gt “$critical_level” ]; then
echo "Memory CRITICAL. $result% used."
exit 2;
fi

can you run the script locally on the ubuntu server?

No I get the same error -w: command not found but not sure if the is an issue with the scrip or something else

if you can’t run it locally it’s a problem with the script which isn’t accepting the parametrs you are passing for some reason…