add uptime cmd, add bells to sh/data
authorDirk Koopman <djk@tobit.co.uk>
Fri, 7 Aug 2020 15:20:28 +0000 (16:20 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Fri, 7 Aug 2020 15:20:28 +0000 (16:20 +0100)
cmd/show/cluster.pl
cmd/show/data_stats.pl
cmd/uptime.pl [new file with mode: 0644]

index 7ebfb946f5baa0912831a98e98da2f8be8c8db65..d61eaa84a869b90bec0e977ced74e306c5f2c7ef 100644 (file)
@@ -8,5 +8,6 @@ my ($nodes, $tot, $users, $maxlocalusers, $maxusers, $uptime, $localnodes) = Rou
 
 $localnodes = $main::routeroot->nodes;
 $users = $main::routeroot->users;
+$uptime = difft($main::starttime, ' ');
 
 return (1, $self->msg('cluster', $localnodes, $nodes, $users, $tot, $maxlocalusers, $maxusers, $uptime));
index 7b37da06cf2679af6efec02f0cbefafd47c064a8..ecd50d7745350e1260cd3b4171b4c360642bf431 100644 (file)
@@ -9,23 +9,38 @@
 sub handle
 {
        my ($self, $line) = @_;
-       my @list = map { uc } split /\s+/, $line; # list of callsigns of nodes
+       my @in = map { uc } split /\s+/, $line; # list of callsigns of nodes
        my @out;
-       if ($list[0] eq 'ALL') {
-               shift @list;
+       my @list;
+       
+       if ($in[0] eq 'ALL') {
                @list = keys %DXChannel::channels;
+       } else {
+               while (@in) {
+                       my $in = shift @in;
+                       if ($in =~ /^NOD/){
+                               push @list, DXChannel::get_all_node_calls();
+                       } elsif ($in =~ /^USE/) {
+                               push @list, DXChannel::get_all_user_calls();
+                       } elsif ($in =~ /^RBN|SKI/) {
+                               push @list, map {$_->is_rbn ? $_->call : undef} DXChannel::get_all();
+                       } else {
+                               push @list, $in;
+                       }
+               }
        }
-       push @out, "Data Statitics                 IN                                OUT";
+       
+       my $dt = difft($main::starttime, ' ');
+       push @out, sprintf "Transfered in:%-12.12s     IN                                OUT", $dt;
        push @out, "Callsign             Lines             Data            Lines             Data";
        push @out, "-----------------------------------------------------------------------------";
-       if (@list) {
-               foreach my $call (sort @list) {
-                       next if $call eq $main::mycall;
-                       my $dxchan = DXChannel::get($call);
-                       if ($dxchan) {
-                               my $conn = $dxchan->conn;
-                               push @out, sprintf("%-9.9s %16s %16s %16s %16s", $call, comma($conn->{linesin}), comma($conn->{datain}), comma($conn->{linesout}), comma($conn->{dataout}));
-                       }
+       push @list, $self->call unless @list;
+       foreach my $call (sort @list) {
+               next if $call eq $main::mycall;
+               my $dxchan = DXChannel::get($call);
+               if ($dxchan) {
+                       my $conn = $dxchan->conn;
+                       push @out, sprintf("%-9.9s %16s %16s %16s %16s", $call, comma($conn->{linesin}), comma($conn->{datain}), comma($conn->{linesout}), comma($conn->{dataout}));
                }
        }
 
diff --git a/cmd/uptime.pl b/cmd/uptime.pl
new file mode 100644 (file)
index 0000000..484cb4c
--- /dev/null
@@ -0,0 +1,6 @@
+#
+# do a tradiotional "uptime" clone
+#
+my $self = shift;
+
+return (1, sprintf("%s $main::mycall uptime: %s", ztime(), difft($main::starttime, ' ')));