mrtg/webstat.pl

Thu, 09 Apr 2009 01:03:24 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 09 Apr 2009 01:03:24 +0200
changeset 151
d176107091ef
child 176
7ed48a3146ba
permissions
-rw-r--r--

Update to new vendor version, integrate flag pictures, and correct URLs.

michael@135 1 #!@l_prefix@/bin/perl
michael@135 2 ##
michael@135 3 ## webstats.pl: return HTTP server hits and bytes
michael@135 4 ##
michael@135 5 ## Configure Apache HTTP server like so:
michael@135 6 ## <Location /server-status>
michael@135 7 ## SetHandler server-status
michael@135 8 ## Order allow,deny
michael@135 9 ## Allow from localhost
michael@135 10 ## </Location>
michael@135 11 ## ExtendedStatus On
michael@135 12 ##
michael@135 13
michael@135 14 @res = `@l_prefix@/bin/lynx -dump http://localhost/server-status`;
michael@135 15
michael@135 16 foreach $res (@res) {
michael@135 17 if ($res =~ /Server uptime: (.*)$/) {
michael@135 18 $up = $1;last
michael@135 19 }
michael@135 20 else
michael@135 21 next
michael@135 22
michael@135 23 if ($res =~ /Server at/) {
michael@135 24 $server = $res;
michael@135 25 last
michael@135 26 }
michael@135 27 else
michael@135 28 next
michael@135 29 }
michael@135 30
michael@135 31 @res = `@l_prefix@/bin/lynx -dump http://localhost/server-status?auto`;
michael@135 32
michael@135 33 foreach $res (@res) {
michael@135 34 if ($res =~ /Total Accesses: (\d+)/) {
michael@135 35 $d1 = $1;
michael@135 36 next
michael@135 37 }
michael@135 38
michael@135 39 if ($res =~ /Total kBytes: (\d+)/) {
michael@135 40 $d2 = $1 * 1024;
michael@135 41 next
michael@135 42 }
michael@135 43 }
michael@135 44
michael@135 45 $d1 = int($d1);
michael@135 46 $d2 = int($d2);
michael@135 47
michael@135 48 if ($ARGV[0] eq "hits") {
michael@135 49 print "$d1\n";
michael@135 50 print "$d1\n";
michael@135 51 } elsif ($ARGV[0] eq "bytes") {
michael@135 52 print "$d2\n";
michael@135 53 print "$d2\n";
michael@135 54 }
michael@135 55
michael@135 56 print "$up\n";
michael@135 57 print "$server";
michael@135 58

mercurial