Wrong output of unix_apachestats.pl

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
Guest

Wrong output of unix_apachestats.pl

Post by Guest »

I am running Apache 1.3.29 on a redhat 7.3 Box.
I always got strange numbers of busy/idle Servers.

I got BusyServers: 1 IdleServers: 6 when I run
/usr/bin/lynx -dump http://localhost/server-status?auto | /usr/bin/head -9
so I had to change the unix_apachestats.pl like this

#!/usr/bin/perl

# Copyright - Rolf Poser - rolf@stasolutions.co.za
# 07 December 2003 under the GPL license agreement!
#
# Version 0.2 - PLEASE SEE README.txt for more information.
#
# USAGE:
#
# perl unix_apachestats.pl <hostname>
#
# <hostname> is optional and can be an IP address or host name.
# If none is given, "localhost" is assumed.
#
# LOCAL SETTINGS:
#
# Change the values below to point to the right places for your installation
#

$BASH="/bin/bash";

$LYNX="/usr/bin/lynx";

$HEAD="/usr/bin/head";

#
# YOU SHOULDN"T NEED TO CHANGE ANYTHING BEYOND THIS POINT..
#
#$hostname = "www.mailkast.com";
$hostname = "localhost";
#my $hostname = $ARGV[0];

chomp $hostname;

if ($hostname eq '') {
$hostname = "localhost";
}

$URL = "http:\/\/".$hostname."\/server-status?auto";

$output = `$BASH -c '$LYNX -dump $URL | $HEAD -9'`;

$output =~ /Total Accesses: (.*)/;
print "apache_total_hits:".$1." ";
$output =~ /Total kBytes: (.*)/;
print "apache_total_kbytes:".$1." ";
$output =~ /BusyServers: (.*)/;
print "apache_busy_workers:".$1." ";
$output =~ /IdleServers: (.*)/;
print "apache_idle_workers:".$1;
dude4you
Posts: 15
Joined: Wed Nov 19, 2003 5:11 pm

Post by dude4you »

I didn't get the data on my server for some reason (Redhat 7.3).
I had to replace the lynx command with the wget command and after that everything went fine.


$output = `/bin/bash -c 'wget --quiet -O - \"http:\/\/localhost\/server-status"'`;

$output =~ /Total accesses: (.*) - Total Traffic: (.*) MB/;
$tt= $2*1000;
print "apache_total_hits:".$1." ";
print "apache_total_kbytes:".$tt." ";

$output =~ /(.*) requests currently being processed, (.*) idle servers/;
print "apache_busy_workers:".$1." ";
print "apache_idle_workers:".$2." ";
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests