gethttpstats
上传用户:shbosideng
上传日期:2013-05-04
资源大小:1555k
文件大小:1k
- #!/usr/bin/perl
- #######################################################
- # Get Web stats from Apache 1.1.1 and better
- #######################################################
- # Author: Anthony Rumble <anthony@rumble.waratah.id.au>
- #
- # Revision: $Revision: 1.1.1.1 $
- #######################################################
- use strict;
- use Socket;
- my($request) = "/status/?auto"; # Request to send
- my($host) = "enterprise.ce.com.au"; # Host to send it to
- my($p) = 80; # Port no
- my ($sin, $port, $iaddr, $paddr, $proto, $line, $uptime, $bytes);
- $proto = getprotobyname('tcp');
- if (!$proto)
- {
- die("getsockbyname");
- }
- socket(S, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
- $port = shift || $p;
- $iaddr = gethostbyname($host);
- if (!$iaddr)
- {
- die("gethostbyname");
- }
- $sin = sockaddr_in($port, $iaddr);
- if (!$sin)
- {
- die("sockaddr_in");
- }
- connect(S, $sin) || die "connect: $!";
- select(S);
- $| = 1;
- select(STDOUT);
- print S "GET $requestn";
- while (<S>)
- {
- $bytes=$1 if (m|^Total Bytes: (S+)|);
- $uptime=$1 if (m|^Uptime: (S+)|);
- }
- close(S);
- print "0n$bytesn$uptimenenterprisen";