From: Niall O Broin (niall at domain linux.ie)
Date: Mon 17 Sep 2001 - 10:58:44 IST
I manage a box which provides web and mail services for a number of
companies. The load average lately has on occasion gone sky high and I need
to get a handle on what's going on. Of course I can use top, ps or vmstat at
any given moment to see what's happening but I'd like to get a look at
trends or the ongoing situation, particularly WRT memory and CPU usage by
apache and Communigate Pro (a commercial SMTP server). I tried this
#!/usr/bin/perl
open TOP, "top -n1 -b|";
while (<TOP>) {
if ($header_done) {
($cpu, $mem, $command) = unpack("x50 A4 x A4 x8 A*", $_);
$cpu{$command} += $cpu;
$mem{$command} += $mem;
}
$header_done = ($header_done || /PID/)
}
print "Process\tCPU\tMemory\n";
foreach ("httpd", "httpdcomet", "CGServer", "mysqld") {
print "$_\t$cpu{$_}\t$mem{$_}\n";
}
which I intended to run every minute or so, but it's not producing accurate
results - CGServer (the Communigate Pro process, of which there may be ~100
running) uses 112% of CPU - obviously the figures from top are not accurate
enough to do this with them. Does any know of tools which might help ? I
have looked around, but tend to find various things like GUIs for top etc.
which don't really help. I really want to find on a continuous basis how
much of a load the above 4 processes (and there may of course be multiple
instances of each) are producing (BTW httpdcomet is a special version of
apache).
Niall
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:10 GMT