diff -r 17a161a7989c -r cd68ee26852b mrtg/webstat.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mrtg/webstat.pl Sat Apr 04 22:28:28 2009 +0200 @@ -0,0 +1,58 @@ +#!@l_prefix@/bin/perl +## +## webstats.pl: return HTTP server hits and bytes +## +## Configure Apache HTTP server like so: +## +## SetHandler server-status +## Order allow,deny +## Allow from localhost +## +## ExtendedStatus On +## + +@res = `@l_prefix@/bin/lynx -dump http://localhost/server-status`; + +foreach $res (@res) { + if ($res =~ /Server uptime: (.*)$/) { + $up = $1;last + } + else + next + + if ($res =~ /Server at/) { + $server = $res; + last + } + else + next +} + +@res = `@l_prefix@/bin/lynx -dump http://localhost/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[0] eq "hits") { + print "$d1\n"; + print "$d1\n"; +} elsif ($ARGV[0] eq "bytes") { + print "$d2\n"; + print "$d2\n"; +} + +print "$up\n"; +print "$server"; +