Register
It is currently Wed Oct 01, 2014 4:16 am

Interesting Problem


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Aug 20, 2009 3:45 pm   

Joined: Wed Aug 19, 2009 8:57 am
Posts: 5
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.


Top
 Profile  
 PostPosted: Fri Aug 21, 2009 6:40 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 549
what are you trying to do with
Code:
echo "$MEMGB<1"|bc
?

at the moment, I guess:
Code:
MEMLIMIT=15
MEMKB=$(awk '/VmRSS/ {print $2}' /proc/${PID}/status)
MEMMB=$((MEMKB/1024))
MEMGB=$((MEMGB/1024))

MEMSIZE="${MEMGB}gb
[ $MEMGB -lt 1 ] && MEMSIZE="${MEMMB}mb
[ $MEMMB -lt 1 ] && MEMSIZE="${MEMKB}kb


Top
 Profile  
 PostPosted: Fri Aug 21, 2009 7:50 am   

Joined: Wed Aug 19, 2009 8:57 am
Posts: 5
Watael. That is exactly what I was aiming to do but for some reason it just skipped my mind to use a standard condition. Pretty much that statement is just to display the amount in GB, MB, or KB respectively.


Top
 Profile  
 PostPosted: Tue Aug 25, 2009 3:44 pm   

Joined: Wed Aug 19, 2009 8:57 am
Posts: 5
Any suggestions on what may be causing the problem. I have been unable to figure it out.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP