6 use Data::Dump qw(dump);
8 my $sock = IO::Socket::INET->new(
9 PeerAddr => '127.0.0.1',
14 print "
\e[2J"; # Erase Screen
19 my $last_content = '?';
22 my $uptime = time() - $t;
23 if ( $erase_screen ) {
27 print "
\e[0;0H"; # Cursor Home
28 print "Gearman " . localtime(time()) . "\t
\e[34mmax update: $uptime
\e[0m\n";
29 printf "
\e[4mqueued running wrk function
\e[0m\n";
31 print $sock "STATUS\n";
35 while ( my $line = <$sock> ) {
39 next if $line =~ m/\t0$/; # ignore functions which don't have active workers
40 my ( $name, $queued, $running, $workers ) = split(/\t/,$line,4);
41 $max->{$name}->{$_} ||= 0 foreach qw(queued running);
42 $max->{$name}->{queued} = $queued if $queued > $max->{$name}->{queued};
43 $max->{$name}->{running} = $running if $running > $max->{$name}->{running};
44 my $line = sprintf "%3d
\e[34m%-3d
\e[0m %3d
\e[34m%-3d
\e[0m %3d %s"
45 , $queued, $max->{$name}->{queued}
46 , $running, $max->{$name}->{running}
55 print $sock "WORKERS\n";
57 while ( my $line = <$sock> ) {
64 if ( $content ne $last_content ) {
66 $last_content = $content;