Mailing List Archive

watch your scoreboard file...
I wrote a perl script to monitor the scoreboard file. It is
attached to this mail.

Here's a snapshot of it's output as seen running at Cardiff...

ssssssR_RsRss (3/12)


The first string represent the first 13 entries of the scoreboard
file,
s - sleeping (as good as) waiting for accept
R - running, i.e. not waiting for an accept.
_ - dead process or a free entry in the table.


Fire the script up with a numeric argument and each update will be
that many seconds appart.
It can easily be converted into a scoreboard log file.

Kinda cute,



#!/usr/local/bin/perl

#
# Author: Rob Hartill hartill@lanl.gov
#
# simple script to monitor Apache processes
# If you give it a numeric argument, it's used as a interval
# e.g. script 3
# Will give you an update ever 3 seconds
# If you choose 0, it might chew up lots of CPU time.
# default interval = 1 second


$PID_FILE = "/usr/local/httpd/logs/httpd.pid";
$MAX_PROC = 40; # we never have (or are interested in) more than 40 procs


############ nothing worth looking at beyond this point ##############

select STDOUT; $| = 1;

$delay = @ARGV[0];
$delay = 1 unless $delay =~ /^[0-9]+$/ ;

open (P, "$PID_FILE") || die "Unable to open $PID_FILE";
$PID = <P>;
$ext = sprintf("a%05d", $PID);
close(P);

open (SB, "/tmp/htstatus.$ext") || die "Unable to open scoreboard file /tmp/htstatus.$ext";

$last_len = 0;
while (1) {

if ( ($last_mod = (stat("/tmp/htstatus.$ext"))[9]) != $before) {
open (SB, "/tmp/htstatus.$ext") || die "Unable to open scoreboard file /tmp/htstatus.$ext";
seek(SB, 2 , 0);

$len = 0; $pad =""; $running = 0; $dead = 0; $total=0;
for ( $child=1; $child<=$MAX_PROC; $child++) {

read(SB, $p1, 1); # 2nd word = process number
read(SB, $p2, 1); # 2nd word = process number
$p = hex(sprintf("%02X%02X", ord($p1), ord($p2)));

read(SB, $status, 1); # next byte = status
$status = ord($status);

read(SB, $junk, 5); # skip to next entry

$c = sprintf("%X", $child);

if ($p != 0 && $p != $PID) {
$total++;
if ($status == 1) {
$c = "s";
} else {
$c = "R";
++$running;
}
$printed .= "$pad$c";

$pad = "";
$dead = 0;
} else {
$dead++;
$pad = "_"x$dead;
}
}
$printed .= " ($running/$total)";
$len = length($printed);

if ($last_len > $len) {
print "\010"x$last_len ;
print " "x$last_len ;
print "\010"x$last_len ;
} else {
print "\010"x$len ;
}
print $printed; $printed = "";

$before = $last_mod;
close(SB);
$last_len = $len;
}
sleep($delay) if $delay >0;
}
Re: watch your scoreboard file... [ In reply to ]
> ssssssR_RsRss (3/12)
>
>
> The first string represent the first 13 entries of the scoreboard
> file,
> s - sleeping (as good as) waiting for accept
> R - running, i.e. not waiting for an accept.
> _ - dead process or a free entry in the table.
>

you've probably worked it out, but just in case, the (3/12) means that
of the 12 live processes, 3 are processing request.


rob