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 Mon 25 May 2015, 07:54
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
logcpu and monitorcpu
Moderators: deshlab, Flash, GuestToo, Ian, JohnMurga, Lobster
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
MU


Joined: 24 Aug 2005
Posts: 13644
Location: Karlsruhe, Germany

PostPosted: Sun 22 Nov 2009, 09:49    Post_subject:  logcpu and monitorcpu
Sub_title: 2 Bash scripts to monitor/kill programs
 

I attach two scripts I wrote.
License: GPL

They can help on servers to keep track of problematic programs, that use a high CPU load.

The numbers I use are examples, you can edit the scripts, to modify intervall, duration, and CPU usage.


logcpu checks every hour, if a program uses more than 70% CPU load.
If yes, a second script is run, logprocess.
It checks for an hour every minute, if the CPU load continuously remains over the desired value.
If yes, it is added to /root/cpulog.txt.

Example (with shorter timings for testing):
Quote:
So 22. Nov 14:30:42 GMT-8 2009 - 20% - 16396 tty1 SLl 29:42 ./PuppyBrowser
So 22. Nov 14:30:43 GMT-8 2009 - 19% - 28824 pts/1 SLl+ 3:06 mplayer-mt.bin -lavdopts threads=2 /mnt/sda6/filme-sda6/gesehen/Starship_Troopers_09.09.20_23-15_pro7_135_TVOON_DE.mpg.HQ.avi
So 22. Nov 14:32:50 GMT-8 2009 - 20% - 16396 tty1 SLl 30:03 ./PuppyBrowser
So 22. Nov 14:32:50 GMT-8 2009 - 19% - 28824 pts/1 SLl+ 3:30 mplayer-mt.bin -lavdopts threads=2 /mnt/sda6/filme-sda6/gesehen/Starship_Troopers_09.09.20_23-15_pro7_135_TVOON_DE.mpg.HQ.avi
So 22. Nov 14:34:57 GMT-8 2009 - 20% - 16396 tty1 SLl 30:24 ./PuppyBrowser



Almost the same is achieved with "monitorcpu".
But here the program is not added to a logfile, but instead it will be killed.


To stop them, type:
killall logcpu
killall logprocess


or:
killall monitorcpu
killall monitorprocess


I also included start/stop scripts for /etc/init.d (to run them when Puppy starts).
So if you copy those, you could use
/etc/init.d/logcpu start
/etc/init.d/logcpu stop


Mark
cpu-process-monitor-11.21.2009-22.58.51.tar.gz
Description 
gz

 Download 
Filename  cpu-process-monitor-11.21.2009-22.58.51.tar.gz 
Filesize  1.17 KB 
Downloaded  134 Time(s) 
cpu-process-logger-11.22.2009-14.32.24.tar.gz
Description 
gz

 Download 
Filename  cpu-process-logger-11.22.2009-14.32.24.tar.gz 
Filesize  1.22 KB 
Downloaded  142 Time(s) 

_________________
my recommended links
Back to top
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13644
Location: Karlsruhe, Germany

PostPosted: Tue 24 Nov 2009, 16:43    Post_subject:  

here is a modified version, "cpukillflash".

It checks the OVERALL CPU-usage every 30 seconds.
If it is higher than "limit" (95%), then it runs "cpukillflash2" in background.

This one checks for 5 minutes every 30 seconds, if the usage remains over the limit. If yes, then "killall flashplayer" is executed.


Instead of "killall flashplayer" you could add your own command, e.g. write to a logfile, or send an email to alert the administrator of the server.

Mark
cpu-killflash-11.24.2009-21.45.53.tar.gz
Description 
gz

 Download 
Filename  cpu-killflash-11.24.2009-21.45.53.tar.gz 
Filesize  1.06 KB 
Downloaded  131 Time(s) 

_________________
my recommended links
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
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.0432s ][ Queries: 12 (0.0035s) ][ GZIP on ]