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 Tue 21 Oct 2014, 14:48
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 Posts_count  
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 MSNM 
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_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 MSNM 
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_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 MSNM 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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