5 use Data::Dump qw(dump);
7 my $ip = shift @ARGV || '10.60.3.35';
8 my $debug = $ENV{DEBUG} || 0;
9 my $sep = $ENV{SEP} || "\t";
11 my $op = shift @ARGV || 'list';
13 my $url = 'jblist.htm';
14 if ( $op =~ m/^l/i ) { # list
16 } elsif ( $op =~ m/^h/i ) { # history
18 } elsif ( $op =~ m/^(d|c)/i ) { # delete/cancel
19 my $job_id = join('/', @ARGV) || die "expected job_id(s) missing";
20 open(my $curl, '-|', "curl --silent -XPOST -d OPR=CANCEL -d JOBS=$job_id/ http://$ip/JOBCTRL.cmd");
25 print join($sep, $ip, $job_id, 'CANCEL', $_),"\n";
30 die "UNKNOWN op [$op]\n";
33 warn "# $ip/$url" if $debug;
34 open(my $curl, '-|', "curl --silent http://$ip/$url");
37 if ( m/var (stats|types|info|hdrs|stsAry|jHst)=(.*);/ ) {
39 my $v = eval $json; # this is not valid JSON, but perl's eval doesn't mind
40 #warn "# JSON $json -> ",dump($v);
45 warn "# info=",dump($info) if $debug;
47 my @headers = @{ $info->{hdrs} };
48 unshift @headers, 'id' if $op eq 'list';
49 unshift @headers, 'IP';
51 print join($sep, @headers),"\n";
53 foreach my $l ( @{ $info->{info} } ) {
54 warn "## l=",dump($l) if $debug > 1;
56 $l->[3] .= ':' . $info->{stats}->[ $l->[3] ];
57 $l->[4] .= ':' . $info->{types}->[ $l->[4] ];
59 print join($sep, $ip, @$l), "\n";
62 foreach my $l ( @{ $info->{jHst} } ) {
63 warn "## l=",dump($l) if $debug > 1;
65 $l->[2] .= ':' . $info->{stsAry}->[ $l->[2] ];
66 $l->[3] .= ':' . $info->{types}->[ $l->[3] ];
68 print join($sep, $ip, @$l),"\n";