test login return from create_user
[cloudstore.git] / gearman-top.pl
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4
5 use IO::Socket::INET;
6 use Data::Dump qw(dump);
7
8 my $sock = IO::Socket::INET->new(
9         PeerAddr => '127.0.0.1',
10         PeerPort => 4730,
11         Proto    => 'tcp'
12 ) || die $1;
13
14 print "\e[2J"; # Erase Screen
15
16 my $t = time();
17 my $max;
18
19 while(1) {
20         my $uptime = time() - $t;
21         print "\e[2J" if $uptime % 30 == 0;
22         print "\e[0;0H"; # Cursor Home
23         print "Gearman " . localtime(time()) . "\t\e[34mmax update: $uptime\e[0m\n"; 
24         printf "\e[4mqueued  running  wrk function\e[0m\n";
25
26         print $sock "STATUS\n";
27
28         while ( my $line = <$sock> ) {
29                 chomp $line;
30 #               warn "# [$line]\n";
31                 last if $line eq '.';
32                 next if $line =~ m/\t0$/; # ignore functions which don't have active workers
33                 my ( $name, $queued, $running, $workers ) = split(/\t/,$line,4);
34                 $max->{$name}->{$_} ||= 0 foreach qw(queued running);
35                 $max->{$name}->{queued}  = $queued  if $queued > $max->{$name}->{queued};
36                 $max->{$name}->{running} = $running if $running > $max->{$name}->{running};
37                 printf "%3d \e[34m%-3d\e[0m %3d \e[34m%-3d\e[0m %3d  %s\n"
38                         , $queued,  $max->{$name}->{queued}
39                         , $running, $max->{$name}->{running}
40                         , $workers
41                         , $name
42                 ;
43         }
44
45 =for workers
46         print $sock "WORKERS\n";
47
48         while ( my $line = <$sock> ) {
49                 chomp $line;
50                 warn "# [$line]\n";
51                 last if $line eq '.';
52         }
53 =cut
54
55         sleep 1;
56 }