Helpful cPanel application "cpuwatch"

Here you can find tutorials and notes for server-side maintenance/configuration

Helpful cPanel application "cpuwatch"

Postby lik » Wed Jan 14, 2009 3:52 am

With every cPanel installation, there is a binary located at /usr/local/cpanel/bin/cpuwatch, what cpuwatch does is that it executes the command and monitors the load, if the load goes past the set limit, it will stop the application and resume it after the load averages are below the threshold for a few seconds, the usage for it is very simply

Code: Select all
# /usr/local/cpanel/bin/cpuwatch
Usage: cpuwatch <maxload> (<-p PID>|<command> [arguments])
  maxload : system load at which throttling should commence
  command : command to run under cpuwatch
  -p PID  : monitor and throttle the existing process PID


Another neat feature is that it can fork a new process or attach itself to a running process, here is an example of deleting an account using SSH and setting the load average threshold to 4.0 :
Code: Select all
/usr/local/cpanel/bin/cpuwatch 4.0 /scripts/killacct username

The load average will go past 4 however the process will stop running as it goes past that limit, if you already have a process running and you do not want to restart it all, you can run the following command to attach it to the process, in this case, the process ID of my process is 18274.
Code: Select all
/usr/local/cpanel/bin/cpuwatch 4.0 -p 18274

It’s a very simple but very neat utility that has saved a few times when we had to do major file operations and did not want the server to have high load averages, this same binary is also used when the logs are running for cPanel and as well as when the cPanel backups are running. For example:
Code: Select all
/usr/local/cpanel/bin/cpuwatch 5.0 /scripts/pkgacct nccsupp /backup/cpbackup/daily backup
lik
Founder
Founder
 
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Return to Server Side Actions

 


  • Related topics
    Replies
    Views
    Last post
cron