Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 28 Nov 2014, 04:35
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
a bash script to check cpu usage?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
divisionmd


Joined: 14 Jul 2007
Posts: 606

PostPosted: Mon 25 Mar 2013, 14:59    Post subject:  a bash script to check cpu usage?  

Hello,

Working on a few test programs here... html5 apps that are a bit buggy.. .anyone know how to:

Make a bash script to detect when cpu usage is 80% or more- then run a killall chrome command.?

thanks for help,
Johan
Back to top
View user's profile Send private message MSN Messenger 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Mon 25 Mar 2013, 15:40    Post subject:  

while i_know_what_i_am_doing; do
Code:
IDLE=`top -n1| grep -o -e '[0-9]*\% idle' |sed 's%[^[:digit:]]%%g'`
echo $IDLE
#45

sleep 1
done
Back to top
View user's profile Send private message Visit poster's website 
divisionmd


Joined: 14 Jul 2007
Posts: 606

PostPosted: Mon 25 Mar 2013, 17:04    Post subject:  

hello Karl Godt,

thanks for input - Got an error on char 19... but might be a typo doublechecking tomorrow first thing after coffeee...


best regards,
Johan
Back to top
View user's profile Send private message MSN Messenger 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Tue 26 Mar 2013, 01:15    Post subject:  

code should work, but that above was on Racy-5.5,
which has Busybox-1.19.x or above
and my current 1.18.3 seems to need the -b option passed to top additionally
and does not show correct values: 95% of the time it is 100% idle or 0% though top without options in another console shows 80% idle.

check busybox version by issuing busybox in the console.
Back to top
View user's profile Send private message Visit poster's website 
divisionmd


Joined: 14 Jul 2007
Posts: 606

PostPosted: Tue 26 Mar 2013, 07:02    Post subject:  

Hello Karl,

- Worked perfectly - just made a typo...

Thanks for help,

Best regards,
Johan
Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0418s ][ Queries: 11 (0.0029s) ][ GZIP on ]