I am working on a system monitor that watches instances of jboss and check the RAM and CPU usage. The scrip works great however every once in a while I get:
/root/monitor/bin/gmonitor: line 177: [: too many arguments
I have not figured out why I am getting this and I cannot ever get it to happen when I use any form of verbose output. Only when it is running silently in the background. Here is the portion of the script that is returning the error. The last line is the line in question:
Code:
let MEMLIMIT=15
let MEMKB=`cat /proc/${PID}/status | awk '/VmRSS/ {print $2}'`
let MEMMB=`echo "$MEMKB/1024"|bc`
let MEMGB=`echo "$MEMGB/1024"|bc`
if [ `echo "$MEMGB<1"|bc` -eq 1 ]; then
MEMSIZE="${MEMMB}mb"
elif [ `echo "$MEMMB<1"|bc` -eq 1 ]; then
MEMSIZE="${MEMKB}kb"
else
MEMSIZE="${MEMGB}gb"
fi
if [ `echo "a=$MEMUSAGE;b=$MEMLIMIT;r=-1;if(a>b)r=0;r"|bc` -eq 0 ]; then
Any help would be greatly appreciated as this is really delaying our launch of this monitor. I am very new to bash scripting and I am alone on this project.