Some weeks ago we have performance problems with 4 apache webservers. When start investigate my question is arround of the number of clients connecting and your states. To determine it, I quickly think... count it from Apache-status (previously enabled). For the code like this:
#!/usr/local/bin/perl -w # # $|++; use LWP::Simple; my $server = shift || 'wks%02s.click21.com.br'; my $count = shift || 4; my @Status = qw( _ S R K D L G . ); my ( %Info, %Status ); my @Info = qw( BusyServers IdleServers CPULoad ReqPerSec ); my $data; my $n; my $Mask = "http://$server/server-status?auto"; printf " " x 14; map { printf(" %s ", $_ ) } @Status; print "\t"; map { printf(" %4s", substr($_,0,4) ) } @Info; print "\n"; for( $n = 1; $n <= $count; $n++ ) { $data = get(sprintf($Mask, $n)); foreach my $l ( split(/\n/, $data) ) { $Info{$1} = $2 if ( $l =~ m/^([^:]+):\s+(.*)/ ); } # Define group status foreach ( @Status ) { $Status{$_} = ( $Info{Scoreboard} =~ s/$_//g ) || '-'; } printf "%10s: ", substr( sprintf($server, $n), 0, 10 ); map { printf(" %3s", $Status{$_}) } @Status; print "\t"; map { printf(" %-4s", substr($Info{$_},0,4) ) } @Info; print "\n"; }

Data samples:

Data sample from /apache-status?auto Total Accesses: 2144860 Total kBytes: 6671882 CPULoad: .38901 Uptime: 170975 ReqPerSec: 12.5449 BytesPerSec: 39959.1 BytesPerReq: 3185.29 BusyServers: 49 IdleServers: 23 Scoreboard: WWWWW___WR__WW_W_WWWWWD_R__WWWW_WWWWWWRWW__WW____W_W_WWWWR +RWWWWW_R___WRR....

Results:

--- on demand result -- _ S R K D L G . Busy Idle CPUL ReqP wks01.clic: 25 - 14 - 1 - - 216 44 25 .449 12.6 wks02.clic: 31 - 3 - 1 - - 221 28 31 .398 12.0 wks03.clic: 15 - 2 - 1 - - 238 22 15 .814 11.0 wks04.clic: 17 - 4 - 1 - - 1002 22 17 .535 10.8 Or, to other server: Or: $ ./monitor webmail%s.click21.com.br 8 _ S R K D L G . Busy Idle CPUL ReqP webmail1.c: 6 - 4 22 - 1 - 223 47 6 3.27 11.7 webmail2.c: 8 - 5 37 - - - 206 70 8 1.70 14.0 webmail3.c: 11 - 4 43 - - - 198 68 11 1.82 13.7 webmail4.c: 14 - 2 33 - 2 - 205 60 14 2.61 12.5 webmail5.c: 9 - 3 22 - - - 222 51 9 1.50 14.2 webmail6.c: 2 - 6 75 - - - 173 111 2 2.33 12.9 webmail7.c: 11 - - 26 - - 1 218 54 11 .044 10.9 webmail8.c: 9 - 1 31 - - 2 213 59 9 .051 11.1
More info about:
  • Apache Status module
  • LWP::Simple

    This code provide some data to diagnostics configuration problems.

    More resources are great, if needs to explain by slot/child of apache, but itīs more hard to do, and need HTML::Parser.

    --
    Marco Antonio
    Rio-PM


    In reply to Monitor instances of Apache Web server by mda2

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.