test refresh_file_list invocations in API
[cloudstore.git] / gearman-top.pl
index 611e976..59d0c67 100755 (executable)
@@ -13,10 +13,15 @@ my $sock = IO::Socket::INET->new(
 
 print "\e[2J"; # Erase Screen
 
+my $t = time();
+my $max;
+
 while(1) {
+       my $uptime = time() - $t;
+       print "\e[2J" if $uptime % 30 == 0;
        print "\e[0;0H"; # Cursor Home
-       print "Gearman " . localtime(time()) . "\n";
-       printf "   q   r   w  function\n";
+       print "Gearman " . localtime(time()) . "\t\e[34mmax update: $uptime\e[0m\n"; 
+       printf "\e[4mqueued  running  wrk function\e[0m\n";
 
        print $sock "STATUS\n";
 
@@ -26,7 +31,15 @@ while(1) {
                last if $line eq '.';
                next if $line =~ m/\t0$/; # ignore functions which don't have active workers
                my ( $name, $queued, $running, $workers ) = split(/\t/,$line,4);
-               printf "%4d%4d%4d  %s\n", $queued, $running, $workers, $name;
+               $max->{$name}->{$_} ||= 0 foreach qw(queued running);
+               $max->{$name}->{queued}  = $queued  if $queued > $max->{$name}->{queued};
+               $max->{$name}->{running} = $running if $running > $max->{$name}->{running};
+               printf "%3d \e[34m%-3d\e[0m %3d \e[34m%-3d\e[0m %3d  %s\n"
+                       , $queued,  $max->{$name}->{queued}
+                       , $running, $max->{$name}->{running}
+                       , $workers
+                       , $name
+               ;
        }
 
 =for workers