You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2012/04/29 01:08:10 UTC

svn commit: r1331851 - in /httpd/httpd/branches/2.4.x: ./ CHANGES STATUS support/log_server_status.in

Author: sf
Date: Sat Apr 28 23:08:09 2012
New Revision: 1331851

URL: http://svn.apache.org/viewvc?rev=1331851&view=rev
Log:
Merge r1325218,1325227,1325250,1325265,1325275,
add CHANGES entry:

 log_server_status: Bring Perl style forward to the present, use
 standard modules, update for new format of server-status output.

Submitted by: rbowen, Dave Brondsema, igalic, humbedooh
Reviewed by: rbowen, jim, sf

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/support/log_server_status.in

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1325218,1325227,1325250,1325265,1325275

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1331851&r1=1331850&r2=1331851&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Sat Apr 28 23:08:09 2012
@@ -3,6 +3,10 @@
 
 Changes with Apache 2.4.3
 
+  *) log_server_status: Bring Perl style forward to the present, use
+     standard modules, update for new format of server-status output.
+     PR 45424. [Richard Bowen, Dave Brondsema, and others]
+
   *) mod_sed, mod_log_debug: Symbol namespace cleanups. [Joe Orton]
 
   *) core: Prevent "httpd -k restart" from killing server in presence of

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1331851&r1=1331850&r2=1331851&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Sat Apr 28 23:08:09 2012
@@ -88,13 +88,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  * log_server_status: Bring Perl style forward to the present, use
-    standard modules, update for new format of server-status output.
-    Trunk patch: http://people.apache.org/~rbowen/log_server_status.trunk.patch
-      (Revisions r1325218 through r1325275)
-    2.4 patch: Trunk patch works
-    +1: rbowen, jim, sf
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
 

Modified: httpd/httpd/branches/2.4.x/support/log_server_status.in
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/support/log_server_status.in?rev=1331851&r1=1331850&r2=1331851&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/support/log_server_status.in (original)
+++ httpd/httpd/branches/2.4.x/support/log_server_status.in Sat Apr 28 23:08:09 2012
@@ -25,54 +25,52 @@
 # it to a file.  Make sure the directory $wherelog is writable by the
 # user who runs this script.
 #
-require 'sys/socket.ph';
-
-$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
-
-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 "";
+use IO::Socket;
+use strict;
+use warnings;
+
+my $wherelog = "@exp_logfiledir@/";  # Logs will be like "@exp_logfiledir@/19960312"
+my $server   = "localhost";        # Name of server, could be "www.foo.com"
+my $port     = "@PORT@";               # Port on server
+my $request = "/server-status/?auto";    # Request to send
+
+my @ltime = localtime(time);
+
+my $day =
+    $ltime[5] + 1900
+  . sprintf( "%02d", $ltime[4] + 1 )
+  . sprintf( "%02d", $ltime[3] );
+
+my $time =
+    sprintf( "%02d", $ltime[2] )
+  . sprintf( "%02d", $ltime[1] )
+  . sprintf( "%02d", $ltime[0] );
+
+open(OUT,">>$wherelog$day");
+
+my $socket = new IO::Socket::INET(
+    PeerAddr => $server,
+    PeerPort => $port,
+    Proto    => "tcp",
+    Type     => SOCK_STREAM
+  )
+  or do {
+    print OUT "$time:-1:-1:-1:-1:$@\n";
+    close OUT;
+    die "Couldn't connect to $server:$port : $@\n";
+  };
+$| = 1;
+
+print $socket
+  "GET $request HTTP/1.1\r\nHost: $server\r\nConnection: close\r\n\r\n\r\n";
+
+my ( $requests, $idle, $number, $cpu );
+while (<$socket>) {
+    $requests = $1 if (m|^BusyWorkers:\ (\S+)|);
+    $idle     = $1 if (m|^IdleWorkers:\ (\S+)|);
+    $number   = $1 if (m|sses:\ (\S+)|);
+    $cpu      = $1 if (m|^CPULoad:\ (\S+)|);
 }
-
-### 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";
-}
-
+print OUT "$time:$requests:$idle:$number:$cpu\n";
+close OUT;