projects
/
gnt-info
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use gnt-node to get list of nodes
[gnt-info]
/
gnt-i
diff --git
a/gnt-i
b/gnt-i
index
f1aa4fa
..
918ee48
100755
(executable)
--- a/
gnt-i
+++ b/
gnt-i
@@
-9,23
+9,38
@@
my $hostname = `hostname -s`;
chomp $hostname;
use Data::Dumper;
chomp $hostname;
use Data::Dumper;
-sub XXX {
warn "XXX ",Dumper( @_ )
};
+sub XXX {
$DEBUG ? warn "XXX ",Dumper( @_ ) : {}
};
+my $stat;
+my $mac_to_name;
+my $lines;
+
+my @nodes = @ARGV;
+
+@nodes = map { chomp ; $_ } `gnt-node list -o name --no-header` unless @nodes;
+
+next_node:
my $ssh = '';
my $ssh = '';
-if ( @
ARGV
) {
- $hostname =
$ARGV[0]
;
+if ( @
nodes
) {
+ $hostname =
shift @nodes
;
$ssh = "ssh $hostname ";
}
# if prefixed with _ it will be hiddden from output, _args must be last!
$ssh = "ssh $hostname ";
}
# if prefixed with _ it will be hiddden from output, _args must be last!
-my @ps_cols = qw( user pid pcpu pmem vsz cputime etimes _args);
+my @ps_cols = qw( user pid
+ pcpu pmem
+ vsz
+ rss
+ nlwp
+ cputime etimes
+ maj_flt min_flt
+ psr
+
+ _args);
sub ps_cols_all { map { my $t = $_; $t =~ s/^_//; $t } @ps_cols };
sub ps_cols_visible { grep { ! /^_/ } @ps_cols };
sub ps_cols_all { map { my $t = $_; $t =~ s/^_//; $t } @ps_cols };
sub ps_cols_visible { grep { ! /^_/ } @ps_cols };
-my $stat;
-my $mac_to_name;
-
sub DD_hh_mm_ss {
my $t = shift;
# [[DD-]hh:]mm:ss.
sub DD_hh_mm_ss {
my $t = shift;
# [[DD-]hh:]mm:ss.
@@
-40,19
+55,20
@@
sub DD_hh_mm_ss {
$t_sec *= $f[$i];
}
$t_sec *= $f[$i];
}
- warn "# DD-hh:mm:ss $t -> $t_sec\n";
+ warn "# DD-hh:mm:ss $t -> $t_sec\n"
if $DEBUG
;
return $t_sec;
}
return $t_sec;
}
-my $cmd = 'ps --no-headers axwwo ' . join(',', ps_cols_all);
+my $cmd =
$ssh .
'ps --no-headers axwwo ' . join(',', ps_cols_all);
warn "## $cmd\n";
warn "## $cmd\n";
-open(my $ps, '-|', $
ssh . $
cmd);
+open(my $ps, '-|', $cmd);
while(<$ps>) {
chomp;
s/^\s*//;
my %h;
@h{@ps_cols} = split(/\s+/, $_, $#ps_cols + 1);
while(<$ps>) {
chomp;
s/^\s*//;
my %h;
@h{@ps_cols} = split(/\s+/, $_, $#ps_cols + 1);
+ $h{cputime} = DD_hh_mm_ss( $h{cputime} );
#XXX 'h = ', \%h;
if ( $h{user} =~ m/gnt/ && $h{_args} =~ m/qemu.*-name\s+(\S+)/ ) {
#XXX 'h = ', \%h;
if ( $h{user} =~ m/gnt/ && $h{_args} =~ m/qemu.*-name\s+(\S+)/ ) {
@@
-60,22
+76,18
@@
while(<$ps>) {
my $name = $1;
$stat->{$name}->{$_} = $h{$_} foreach ps_cols_all;
my $name = $1;
$stat->{$name}->{$_} = $h{$_} foreach ps_cols_all;
- $stat->{$name}->{cputime_} = $stat->{$name}->{cputime} = DD_hh_mm_ss( $stat->{$name}->{cputime} );
-
while ( $h{_args} =~ m/mac=([0-9a-fA-F:]+)/g ) {
$mac_to_name->{$1} = $name;
}
} else {
# warn "## SKIP [$_]\n";
while ( $h{_args} =~ m/mac=([0-9a-fA-F:]+)/g ) {
$mac_to_name->{$1} = $name;
}
} else {
# warn "## SKIP [$_]\n";
- $stat->{ '__' . $hostname }->{$_} += $h{$_} foreach qw( pcpu pmem vsz );
+ $stat->{ '__' . $hostname }->{$_} += $h{$_} foreach qw( pcpu pmem vsz
rss cputime etimes maj_flt min_flt
);
}
}
}
}
-warn "# mac_to_name ", XXX( $mac_to_name );
-
open(my $ip, '-|', $ssh . 'ip -s -o link');
while(<$ip>) {
chomp;
open(my $ip, '-|', $ssh . 'ip -s -o link');
while(<$ip>) {
chomp;
@@
-91,10
+103,11
@@
while(<$ip>) {
}
}
}
}
-warn "# stat = ", XXX( $stat );
+goto next_node if @nodes;
+
+warn "# stat ", Dumper( $stat ) if $DEBUG;
XXX( @ps_cols );
XXX( @ps_cols );
-my $lines;
sub push_line {
my @l = @_;
foreach my $i ( 0 .. $#l ) {
sub push_line {
my @l = @_;
foreach my $i ( 0 .. $#l ) {
@@
-102,7
+115,7
@@
sub push_line {
$lines->{len}->[$i] ||= $len;
$lines->{len}->[$i] = $len if $len > $lines->{len}->[$i];
}
$lines->{len}->[$i] ||= $len;
$lines->{len}->[$i] = $len if $len > $lines->{len}->[$i];
}
- push @{ $lines->{line} }, [ @l ];
+ push @{ $lines->{line} }, [
map { ! defined $_ ? '-' : $_ }
@l ];
}
push_line '#name', ps_cols_visible;
}
push_line '#name', ps_cols_visible;
@@
-113,10
+126,13
@@
foreach my $name ( sort keys %$stat ) {
push_line( $name, map { $stat->{$name}->{$_} } ps_cols_visible );
}
push_line( $name, map { $stat->{$name}->{$_} } ps_cols_visible );
}
+warn '# mac_to_name ', Dumper( $mac_to_name );
+
XXX $lines;
my $fmt = join(' ', map { '%' . $_ . 's' } @{ $lines->{len} } ) . "\n";
XXX $lines;
my $fmt = join(' ', map { '%' . $_ . 's' } @{ $lines->{len} } ) . "\n";
-warn "# fmt = [$fmt]";
+warn "# fmt = [$fmt]"
if $DEBUG
;
foreach my $line ( @{ $lines->{line} } ) {
printf $fmt, @$line;
}
foreach my $line ( @{ $lines->{line} } ) {
printf $fmt, @$line;
}
+