X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=gearman-top.pl;h=9670670fbe9a704ae133601b1946e14052d346d3;hb=925ecfc00ce5ab771ff4337fcb9f1b27dc9570cb;hp=12ab1e5ea41db0edfaeecc4fe673fbac88e1a05b;hpb=70c3d1a61b6d1cbc96a8c9d8f6a5c923044ffed6;p=cloudstore.git diff --git a/gearman-top.pl b/gearman-top.pl index 12ab1e5..9670670 100755 --- a/gearman-top.pl +++ b/gearman-top.pl @@ -13,15 +13,25 @@ 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 "queued running wrk function max\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"; @@ -31,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 @@ -49,5 +61,10 @@ while(1) { } =cut + if ( $content ne $last_content ) { + $erase_screen = 1; + $last_content = $content; + } + sleep 1; }