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 Thu 18 Dec 2014, 21:43
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 [2 Posts]  
Author Message
MU


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

PostPosted: Sun 22 Nov 2009, 09:49    Post subject:  logcpu and monitorcpu
Subject description: 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  129 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  138 Time(s) 

_________________
my recommended links
Back to top
View user's profile Send private message Visit poster's 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  124 Time(s) 

_________________
my recommended links
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
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.0518s ][ Queries: 12 (0.0037s) ][ GZIP on ]