summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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";
}