X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=gearman-top.pl;h=9670670fbe9a704ae133601b1946e14052d346d3;hb=925ecfc00ce5ab771ff4337fcb9f1b27dc9570cb;hp=59d0c674ebdd18f160106a0df5dbeb02f0268412;hpb=65f3d4cf391fb88826d6ce4f1e6bda285d066460;p=cloudstore.git diff --git a/gearman-top.pl b/gearman-top.pl index 59d0c67..9670670 100755 --- a/gearman-top.pl +++ b/gearman-top.pl @@ -15,16 +15,23 @@ print ""; # Erase Screen my $t = time(); my $max; +my $erase_screen = 1; +my $last_content = '?'; while(1) { my $uptime = time() - $t; - print "" if $uptime % 30 == 0; + if ( $erase_screen ) { + print ""; + $erase_screen = 0; + } print ""; # Cursor Home 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"; @@ -34,12 +41,14 @@ while(1) { $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 %-3d %3d %-3d %3d %s\n" + 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 @@ -52,5 +61,10 @@ while(1) { } =cut + if ( $content ne $last_content ) { + $erase_screen = 1; + $last_content = $content; + } + sleep 1; }