summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorRich Bowen <rbowen@apache.org>2012-04-12 14:25:48 +0200
committerRich Bowen <rbowen@apache.org>2012-04-12 14:25:48 +0200
commit02e55748c1b8b3261ba04f2ea974187cfed3f364 (patch)
tree5849840d516462a86164fc35dacbb76b3aeb3a04 /support
parentxforms (diff)
downloadapache2-02e55748c1b8b3261ba04f2ea974187cfed3f364.tar.xz
apache2-02e55748c1b8b3261ba04f2ea974187cfed3f364.zip
Updates patch provided by Dave Brondsema (brondsem AT apache org) four
years ago, makes the script strict/warnings compliant, and updates to current output format of server-status. Partially fixes https://issues.apache.org/bugzilla/show_bug.cgi?id=45424 The script now actually produces output. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1325218 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support')
-rw-r--r--support/log_server_status.in82
1 files changed, 43 insertions, 39 deletions
diff --git a/support/log_server_status.in b/support/log_server_status.in
index b788ab1913..6f0505f05d 100644
--- a/support/log_server_status.in
+++ b/support/log_server_status.in
@@ -25,54 +25,58 @@
# it to a file. Make sure the directory $wherelog is writable by the
# user who runs this script.
#
-require 'sys/socket.ph';
+use Socket;
+use strict;
+use warnings;
-$wherelog = "/var/log/graph/"; # Logs will be like "/var/log/graph/19960312"
-$server = "localhost"; # Name of server, could be "www.foo.com"
-$port = "80"; # Port on server
-$request = "/status/?auto"; # Request to send
+my $wherelog = "/var/log/httpd/"; # Logs will be like "/var/log/graph/19960312"
+my $server = "localhost"; # Name of server, could be "www.foo.com"
+my $port = "80"; # Port on server
+my $request = "/server-status/?auto"; # Request to send
sub tcp_connect
{
- local($host,$port) =@_;
- $sockaddr='S n a4 x8';
- chop($hostname=`hostname`);
- $port=(getservbyname($port, 'tcp'))[2] unless $port =~ /^\d+$/;
- $me=pack($sockaddr,&AF_INET,0,(gethostbyname($hostname))[4]);
- $them=pack($sockaddr,&AF_INET,$port,(gethostbyname($host))[4]);
- socket(S,&PF_INET,&SOCK_STREAM,(getprotobyname('tcp'))[2]) ||
- die "socket: $!";
- bind(S,$me) || return "bind: $!";
- connect(S,$them) || return "connect: $!";
- select(S);
- $| = 1;
- select(stdout);
- return "";
+ my ( $host, $port ) = @_;
+ my $sockaddr = 'S n a4 x8';
+ chop( my $hostname = `hostname` );
+ $port = ( getservbyname( $port, 'tcp' ) )[2] unless $port =~ /^\d+$/;
+ my $me = pack( $sockaddr, &AF_INET, 0, ( gethostbyname($hostname) )[4] );
+ my $them = pack( $sockaddr, &AF_INET, $port, ( gethostbyname($host) )[4] );
+ socket( S, &PF_INET, &SOCK_STREAM, ( getprotobyname('tcp') )[2] )
+ || die "socket: $!";
+ bind( S, $me ) || return "bind: $!";
+ connect( S, $them ) || return "connect: $!";
+ select(S);
+ $| = 1;
+ select(STDOUT);
+ return "";
}
### Main
{
- $year=`date +%y`;
- chomp($year);
- $year += ($year < 70) ? 2000 : 1900;
- $date = $year . `date +%m%d:%H%M%S`;
- chomp($date);
- ($day,$time)=split(/:/,$date);
- $res=&tcp_connect($server,$port);
- open(OUT,">>$wherelog$day");
- if ($res) {
- print OUT "$time:-1:-1:-1:-1:$res\n";
- exit 1;
- }
- print S "GET $request\n";
- while (<S>) {
- $requests=$1 if ( m|^BusyServers:\ (\S+)|);
- $idle=$1 if ( m|^IdleServers:\ (\S+)|);
- $number=$1 if ( m|sses:\ (\S+)|);
- $cpu=$1 if (m|^CPULoad:\ (\S+)|);
- }
- print OUT "$time:$requests:$idle:$number:$cpu\n";
+ my $year = `date +%y`;
+ chomp($year);
+ $year += ( $year < 70 ) ? 2000 : 1900;
+ my $date = $year . `date +%m%d:%H%M%S`;
+ chomp($date);
+ my ( $day, $time ) = split( /:/, $date );
+ my $res = &tcp_connect( $server, $port );
+ open( OUT, ">>$wherelog$day" );
+
+ if ($res) {
+ print OUT "$time:-1:-1:-1:-1:$res\n";
+ exit 1;
+ }
+ print S "GET $request\n";
+ my ( $requests, $idle, $number, $cpu );
+ while (<S>) {
+ $requests = $1 if (m|^BusyWorkers:\ (\S+)|);
+ $idle = $1 if (m|^IdleWorkers:\ (\S+)|);
+ $number = $1 if (m|sses:\ (\S+)|);
+ $cpu = $1 if (m|^CPULoad:\ (\S+)|);
+ }
+ print OUT "$time:$requests:$idle:$number:$cpu\n";
}