librenms/get-apache.sh
Super User ff70062aa9 Initial Import
git-svn-id: http://www.observium.org/svn/observer/trunk@2 61d68cd4-352d-0410-923a-c4978735b2b8
2007-04-03 14:10:23 +00:00

44 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/perl
# depends on availability of status and extended status info from your
# Apache webserver -- your httpd.conf needs to include something like the
# following: (uncommented)
#<Location /server-status>
# SetHandler server-status
# Order allow,deny
# Allow from localhost
#</Location>
#ExtendedStatus On
# can return hits or bytes (counters)
@res = `/usr/bin/lynx -dump http://$ARGV[0]:80/server-status`;
foreach $res (@res) {
if ($res =~ /Server uptime: (.*)$/) { $up = $1; last } else { next }
if ($res =~ /Server at/) { $server = $res; last } else { next }
}
@res = `/usr/bin/lynx -dump http://$ARGV[0]:80/server-status?auto`;
foreach $res (@res) {
if ($res =~ /Total Accesses: (\d+)/) { $d1 = $1; next }
if ($res =~ /Total kBytes: (\d+)/) { $d2 = $1 * 1024; next }
}
$d1 = int($d1);
$d2 = int($d2);
#if ($ARGV[1] eq "hits") {
print "$d1\n";
# print "$d1\n";
#} elsif ($ARGV[1] eq "bytes") {
print "$d2\n";
# print "$d2\n";
#}
print "$up\n";
print "$server";