X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=gearman-top.pl;h=9670670fbe9a704ae133601b1946e14052d346d3;hb=e2364b6f29af230d5ee3db03c8bd15de1c6fd9da;hp=611e9765593aa6061c7a135a84805e7bd8fcd3fd;hpb=1249ed111286256d06fe284303aabac969ff98c7;p=cloudstore.git diff --git a/gearman-top.pl b/gearman-top.pl index 611e976..9670670 100755 --- a/gearman-top.pl +++ b/gearman-top.pl @@ -13,20 +13,42 @@ my $sock = IO::Socket::INET->new( print ""; # Erase Screen +my $t = time(); +my $max; +my $erase_screen = 1; +my $last_content = '?'; + while(1) { + my $uptime = time() - $t; + if ( $erase_screen ) { + print ""; + $erase_screen = 0; + } print ""; # Cursor Home - print "Gearman " . localtime(time()) . "\n"; - printf " q r w function\n"; + print "Gearman " . localtime(time()) . "\tmax update: $uptime\n"; + printf "queued running wrk function\n"; print $sock "STATUS\n"; + my $content; + while ( my $line = <$sock> ) { chomp $line; # warn "# [$line]\n"; 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}; + my $line = sprintf "%3d %-3d %3d %-3d %3d %s" + , $queued, $max->{$name}->{queued} + , $running, $max->{$name}->{running} + , $workers + , $name + ; + print "$line\n"; + $content .= $line; } =for workers @@ -39,5 +61,10 @@ while(1) { } =cut + if ( $content ne $last_content ) { + $erase_screen = 1; + $last_content = $content; + } + sleep 1; }