Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Monitor instances of Apache Web server

by mda2 (Hermit)
on Jun 11, 2005 at 21:13 UTC ( #465848=CUFP: print w/replies, xml ) Need Help??

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

  • Replies are listed 'Best First'.
    Re: Monitor instances of Apache Web server
    by mda2 (Hermit) on Jul 07, 2005 at 13:59 UTC
      This node is my work, to get realtime data from my servers, and to add more information and tools, see Apache-Tools, to monitor your WebServers (Perl too :D ).

      One demo and /server-status from Apache.org are available!

      --
      Marco Antonio
      Rio-PM

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: CUFP [id://465848]
    Approved by ghenry
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (10)
    As of 2019-12-09 19:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?