Add latest RBN chnages and data stats
[spider.git] / cmd / show / data_stats.pl
1 #
2 # show the users on this cluster from the routing tables
3 #
4 # Copyright (c) 1998 Dirk Koopman G1TLH
5 #
6 #
7 #
8
9 sub handle
10 {
11         my ($self, $line) = @_;
12         my @list = map { uc } split /\s+/, $line; # list of callsigns of nodes
13         my @out;
14         if ($list[0] eq 'ALL') {
15                 shift @list;
16                 @list = keys %DXChannel::channels;
17         }
18         push @out, "Data Statitics                 IN                                OUT";
19         push @out, "Callsign             Lines             Data            Lines             Data";
20         push @out, "-----------------------------------------------------------------------------";
21         if (@list) {
22                 foreach my $call (sort @list) {
23                         next if $call eq $main::mycall;
24                         my $dxchan = DXChannel::get($call);
25                         if ($dxchan) {
26                                 my $conn = $dxchan->conn;
27                                 push @out, sprintf("%-9.9s %16s %16s %16s %16s", $call, comma($conn->{linesin}), comma($conn->{datain}), comma($conn->{linesout}), comma($conn->{dataout}));
28                         }
29                 }
30         }
31
32         push @out, "-----------------------------------------------------------------------------" if @out > 3;
33         push @out, sprintf("%-9.9s %16s %16s %16s %16s", "TOTALS", comma($Msg::total_lines_in), comma($Msg::total_in), comma($Msg::total_lines_out), comma($Msg::total_out));
34
35         return (1, @out);
36 }
37
38 sub comma
39 {
40         my $num = shift;
41         return scalar reverse(join(",",unpack("(A3)*", reverse int($num))));
42 }
43