#!/usr/bin/perl # $Revision: 2 $ # $Date: 2008-09-12 15:11:40 +0300 (Fri, 12 Sep 2008) $ my %opt = ( # http link to apache server-status, be sure turn on "ExtendedStatus On" in httpd.conf apache_status => 'http://localhost:80/server-status?auto', # path for program what may dump web page, normaly lynx -dump # lynx => 'lynx -dump', lynx => 'wget -q -Y off -O -', ); my $var = $ARGV[0]; if ($var eq "bytes" or !defined($var)) { $do = `$opt{lynx} $opt{apache_status}`; $do=~/Total kBytes: (\d+)/ or warn "Error! Can't find data!\nIN :\n$do"; $d1 = $d2 = $1 * 1024; $up = "$1 sec" if $do=~/Uptime: (\d+)/; } elsif ($var eq "req") { $do = `$opt{lynx} $opt{apache_status}`; $do=~/Total Accesses: (\d+)/ or warn "Error! Can't find data!\nIN :\n$do"; $d2 = $d1 = $1; $up = "$1 sec" if $do=~/Uptime: (\d+)/; } elsif ($var eq "servers") { $do = `$opt{lynx} $opt{apache_status}`; $do=~/Busy(?:Servers|Workers): (\d+)/ or warn "Error! Can't find data!\nIN :\n$do"; $d1 = $1; $do=~/Idle(?:Servers|Workers): (\d+)/ or warn "Error! Can't find data!\nIN :\n$do"; $d2 = $1; $up = "$1 sec" if $do=~/Uptime: (\d+)/; } else { warn "Error ! Please read the help\n"; } print "$d1\n"; print "$d2\n"; print "$up\n" if $up; print "Apache $var\n";