projects
/
safeq
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
850a05a
)
added jbhist output with host argument
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Tue, 26 Feb 2019 07:56:13 +0000
(08:56 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Tue, 26 Feb 2019 07:56:13 +0000
(08:56 +0100)
xq.pl
patch
|
blob
|
history
diff --git
a/xq.pl
b/xq.pl
index
f90a308
..
854f21f
100755
(executable)
--- a/
xq.pl
+++ b/
xq.pl
@@
-7,10
+7,23
@@
use Data::Dump qw(dump);
my $ip = shift @ARGV || '10.60.3.35';
my $debug = $ENV{DEBUG} || 0;
my $ip = shift @ARGV || '10.60.3.35';
my $debug = $ENV{DEBUG} || 0;
-open(my $curl, '-|', "curl --silent http://$ip/jblist.htm");
+
+my $op = shift @ARGV || 'list';
+
+my $url = 'jblist.htm';
+if ( $op eq 'list' ) {
+ $url = 'jblist.htm';
+} elsif ( $op eq 'hist' ) {
+ $url = 'jbhist.htm';
+} else {
+ die "UNKNOWN op [$op]\n";
+}
+
+warn "# $ip/$url" if $debug;
+open(my $curl, '-|', "curl --silent http://$ip/$url");
my $info;
while(<$curl>) {
my $info;
while(<$curl>) {
- if ( m/var (stats|types|info|hdrs)=(.*);/ ) {
+ if ( m/var (stats|types|info|hdrs
|stsAry|jHst
)=(.*);/ ) {
my $json = $2;
my $v = eval $json; # this is not valid JSON, but perl's eval doesn't mind
#warn "# JSON $json -> ",dump($v);
my $json = $2;
my $v = eval $json; # this is not valid JSON, but perl's eval doesn't mind
#warn "# JSON $json -> ",dump($v);
@@
-20,12
+33,25
@@
while(<$curl>) {
warn "# info=",dump($info) if $debug;
warn "# info=",dump($info) if $debug;
-my $fmt = "%-8s|%-16s|%-16s|%-16s|%-16s|%s\n"; # last should be %d, but this doesn't work for header
-printf $fmt, 'id', @{ $info->{hdrs} };
+my @headers = @{ $info->{hdrs} };
+unshift @headers, 'id' if $op eq 'list';
+
+print join("\t", @headers),"\n";
foreach my $l ( @{ $info->{info} } ) {
warn "## l=",dump($l) if $debug > 1;
foreach my $l ( @{ $info->{info} } ) {
warn "## l=",dump($l) if $debug > 1;
- printf $fmt,
- $l->[0], $l->[1], $l->[2], $info->{stats}->[ $l->[3] ], $info->{types}->[ $l->[4] ], $l->[5];
+ $l->[3] = $info->{stats}->[ $l->[3] ];
+ $l->[4] = $info->{types}->[ $l->[4] ];
+
+ print join("\t", @$l), "\n";
+}
+
+foreach my $l ( @{ $info->{jHst} } ) {
+ warn "## l=",dump($l) if $debug > 1;
+
+ $l->[2] = $info->{stsAry}->[ $l->[2] ];
+ $l->[3] = $info->{types}->[ $l->[3] ];
+
+ print join("\t", @$l),"\n";
}
}