3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements. See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
20 # Mark J Cox, UK Web Ltd 1996, mark ukweb.com
22 # This script is designed to be run at a frequent interval by something
23 # like cron. It connects to the server and downloads the status
24 # information. It reformats the information to a single line and logs
25 # it to a file. Make sure the directory $wherelog is writable by the
26 # user who runs this script.
32 my $wherelog = "@exp_logfiledir@/"; # Logs will be like "@exp_logfiledir@/19960312"
33 my $server = "localhost"; # Name of server, could be "www.foo.com"
34 my $port = "@PORT@"; # Port on server
35 my $request = "/server-status/?auto"; # Request to send
37 my @ltime = localtime(time);
41 . sprintf( "%02d", $ltime[4] + 1 )
42 . sprintf( "%02d", $ltime[3] );
45 sprintf( "%02d", $ltime[2] )
46 . sprintf( "%02d", $ltime[1] )
47 . sprintf( "%02d", $ltime[0] );
49 open(OUT,">>$wherelog$day");
51 my $socket = new IO::Socket::INET(
58 print OUT "$time:-1:-1:-1:-1:$@\n";
60 die "Couldn't connect to $server:$port : $@\n";
65 "GET $request HTTP/1.1\r\nHost: $server\r\nConnection: close\r\n\r\n\r\n";
67 my ( $requests, $idle, $number, $cpu );
69 $requests = $1 if (m|^BusyWorkers:\ (\S+)|);
70 $idle = $1 if (m|^IdleWorkers:\ (\S+)|);
71 $number = $1 if (m|sses:\ (\S+)|);
72 $cpu = $1 if (m|^CPULoad:\ (\S+)|);
74 print OUT "$time:$requests:$idle:$number:$cpu\n";