Better Apache server-status script

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

Moderators: Developers, Moderators

Post Reply
Buckbeak
Posts: 14
Joined: Tue Nov 15, 2005 8:57 am

Better Apache server-status script

Post by Buckbeak »

I took the stock apachehits.pl script and augmented it and modified it to work with the http://www.xxxx.xxx/server-status/?auto form. <---note the "auto" keyword.

The auto keyword makes the output from apache simpler and more "machine readable".

See: http://webauthv3.stanford.edu/manual/mo ... tatus.html for more information about mod_status and the auto keyword.

Code is also shown here:

Code: Select all

#!/usr/bin/perl

# Script to get the requests per second and the requests currently being
# processed from an Apache webserver.
# 
# Requires the following statement in Apache:
#  ExtendedStatus on
#  <Location /server-status>
#     SetHandler server-status
#     Order deny,allow
#     Deny from all
#     Allow from xxx.xxx.xxx.xxx
#  </Location>
# 
# Idea stolen from: http://www.cacti.net/downloads/scripts/apachehits.pl.txt
# 
# Written by Buckbeak
#

$output = `/usr/local/bin/bash -c '/usr/local/bin/wget --quiet -O - \"http:\/\/$ARGV[0]\/server-status\?auto"'`;
$output =~ /Total Accesses:\ (.*)/ && print "TotalAccesses:".$1." ";
$output =~ /Total kBytes:\ (.*)/ && print "TotalkBytes:".$1." ";
$output =~ /CPULoad:\ (.*)/ && print "CPULoad:".$1." ";
$output =~ /Uptime:\ (.*)/ && print "Uptime:".$1." ";
$output =~ /ReqPerSec:\ (.*)/ && print "ReqPerSec:".$1." ";
$output =~ /BytesPerSec:\ (.*)/ && print "BytesPerSec:".$1." ";
$output =~ /BytesPerReq:\ (.*)/ && print "BytesPerReq:".$1." ";
$output =~ /BusyServers:\ (.*)/ && print "BusyServers:".$1." ";
$output =~ /IdleServers:\ (.*)/ && print "IdleServers:".$1." ";
print "\n";
Attachments
apachehitsauto.pl.txt
(1.12 KiB) Downloaded 744 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Thank you for posting this.
If you're interested in more statistics, please have a look at [XML] ApacheStats version 0.4 or my [XML] successor to apachestats 0.4
The Data Template and Graph Template are included...
happy cacti-ing
Reinhard
pico
Posts: 1
Joined: Tue Mar 22, 2011 8:19 am

Re: Better Apache server-status script

Post by pico »

There is a problem in the script :

Code: Select all

$output =~ /BusyServers:\ (.*)/ && print "BusyServers:".$1." ";
$output =~ /IdleServers:\ (.*)/ && print "IdleServers:".$1." ";
Should be replace by :

Code: Select all

$output =~ /BusyWorkers:\ (.*)/ && print "BusyWorkers:".$1." ";
$output =~ /IdleWorkers:\ (.*)/ && print "IdleWorkers:".$1." ";
Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests