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.

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

mercurial