ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/shell.pl
(Generate patch)

Comparing Coro/myhttpd/shell.pl (file contents):
Revision 1.15 by root, Sun Aug 19 23:57:52 2001 UTC vs.
Revision 1.22 by pcg, Thu Feb 12 22:18:27 2004 UTC

9use Text::Abbrev; 9use Text::Abbrev;
10 10
11my $last_ts = time; 11my $last_ts = time;
12 12
13my %complete; 13my %complete;
14my @commands = qw(quit squit refresh country restart block info print); 14my @commands = qw(quit squit refresh country restart block info print clrdiridx);
15 15
16abbrev \%complete, @commands; 16abbrev \%complete, @commands;
17 17
18sub shell { 18sub shell {
19 my $fh = shift; 19 my $fh = shift;
32 my @res = eval $_; 32 my @res = eval $_;
33 print $fh "eval: $@\n" if $@; 33 print $fh "eval: $@\n" if $@;
34 print $fh "RES = ", (join " : ", @res), "\n"; 34 print $fh "RES = ", (join " : ", @res), "\n";
35 } elsif ($cmd eq "block") { 35 } elsif ($cmd eq "block") {
36 print "blocked '$_'\n";#d# 36 print "blocked '$_'\n";#d#
37 $conn::blocked{$_} = time + $::BLOCKTIME; 37 $conn::blocked{$_} = [time + $::BLOCKTIME, "blocked by operator"];
38 } elsif ($cmd eq "info") { 38 } elsif ($cmd eq "info") {
39 $::NOW = time+1e-6; 39 $::NOW = time+1e-6;
40 my @data; 40 my @data;
41 for (values %conn::conn) { 41 for (values %conn::conn) {
42 for (values %$_) { 42 for (values %$_) {
45 push @data, "$_->{country}/$_->{remote_addr} $_->{written} $rate $_->{method} $_->{uri}\n"; 45 push @data, "$_->{country}/$_->{remote_addr} $_->{written} $rate $_->{method} $_->{uri}\n";
46 } 46 }
47 } 47 }
48 print $fh sort @data; 48 print $fh sort @data;
49 print $fh scalar@data, " ($::conns) connections\n";#d# 49 print $fh scalar@data, " ($::conns) connections\n";#d#
50 print $fh "$::written bytes written in the last ",$::NOW - $last_ts, " seconds\n"; 50 print $fh "$::written bytes written in the last ", $::NOW - $last_ts, " seconds\n";
51 printf $fh "(%.1f bytes/s)\n", $::written / ($::NOW - $last_ts); 51 printf $fh "(%.1f bytes/s)\n", $::written / ($::NOW - $last_ts);
52 ($last_ts, $::written) = ($::NOW, 0); 52 ($last_ts, $::written) = ($::NOW, 0);
53 } elsif ($cmd eq "refresh") { 53 } elsif ($cmd eq "refresh") {
54 do "config.pl"; 54 do "config.pl";
55 print $fh "config.pl: $@\n" if $@; 55 print $fh "config.pl: $@\n" if $@;
56 %statdata_cache = ();
56 read_blockuri; 57 conn::read_blockuri;
57 read_blockref; 58 conn::read_blockref;
59 } elsif ($cmd eq "clrdiridx") {
60 %statdata_cache = ();
61 delete $diridx{$_} for keys %diridx; # server error on %diridx = ();
58 } elsif ($cmd eq "restart") { 62 } elsif ($cmd eq "restart") {
59 $::RESTART = 1; 63 $::RESTART = 1;
60 unloop; 64 unloop;
61 print $fh "restarting, cu!\n"; 65 print $fh "restarting, cu!\n";
62 last; 66 last;
63 } elsif ($cmd eq "country") { 67 } elsif ($cmd eq "country") {
64 print $fh ip_request($_), "\n"; 68 print $fh netgeo::ip_request($_), "\n";
65 } 69 }
66 } else { 70 } else {
67 print $fh "try one of @commands\n"; 71 print $fh "try one of @commands\n";
68 } 72 }
69 } 73 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines