michael@176: #! @l_prefix@/bin/perl michael@135: ## michael@135: ## webstats.pl: return HTTP server hits and bytes michael@135: ## michael@135: ## Configure Apache HTTP server like so: michael@135: ## michael@135: ## SetHandler server-status michael@135: ## Order allow,deny michael@135: ## Allow from localhost michael@135: ## michael@135: ## ExtendedStatus On michael@135: ## michael@135: michael@135: @res = `@l_prefix@/bin/lynx -dump http://localhost/server-status`; michael@135: michael@135: foreach $res (@res) { michael@135: if ($res =~ /Server uptime: (.*)$/) { michael@135: $up = $1;last michael@135: } michael@176: else { michael@135: next michael@176: } michael@135: michael@135: if ($res =~ /Server at/) { michael@135: $server = $res; michael@135: last michael@135: } michael@176: else { michael@135: next michael@176: } michael@135: } michael@135: michael@135: @res = `@l_prefix@/bin/lynx -dump http://localhost/server-status?auto`; michael@135: michael@135: foreach $res (@res) { michael@135: if ($res =~ /Total Accesses: (\d+)/) { michael@135: $d1 = $1; michael@135: next michael@135: } michael@135: michael@135: if ($res =~ /Total kBytes: (\d+)/) { michael@135: $d2 = $1 * 1024; michael@135: next michael@135: } michael@135: } michael@135: michael@135: $d1 = int($d1); michael@135: $d2 = int($d2); michael@135: michael@135: if ($ARGV[0] eq "hits") { michael@135: print "$d1\n"; michael@135: print "$d1\n"; michael@135: } elsif ($ARGV[0] eq "bytes") { michael@135: print "$d2\n"; michael@135: print "$d2\n"; michael@135: } michael@135: michael@135: print "$up\n"; michael@135: print "$server"; michael@176: print "$null\n"; michael@176: print "$null\n"; michael@135: