5 |
# filesystems in same order always) |
# filesystems in same order always) |
6 |
# |
# |
7 |
# Dobrica Pavlinusic <dpavlin@rot13.org> |
# Dobrica Pavlinusic <dpavlin@rot13.org> |
8 |
|
# http://www.rot13.org/~dpavlin/sysadm.html |
9 |
# |
# |
10 |
# Usage: |
# Usage: |
11 |
# |
# |
12 |
# parse_df.pl "ssh -i ~cricket/.ssh/df host.dom" /mount_point |
# parse_df.pl "ssh -i ~cricket/.ssh/df target.host" /mount_point |
13 |
# ssh into remote host and get data for /mount_point |
# ssh into remote host and get data for /mount_point |
14 |
# |
# |
15 |
# parse_df.pl "ssh -i ~cricket/.ssh/df --config" |
# parse_df.pl "ssh -i ~cricket/.ssh/df target.host" --config |
16 |
# dump configuration file to stdout |
# dump configuration file to stdout |
17 |
# |
# |
18 |
|
|
39 |
return if (defined $df); |
return if (defined $df); |
40 |
print STDERR " [cache miss] "; |
print STDERR " [cache miss] "; |
41 |
} |
} |
42 |
open(DF,"$ssh df -klP |") || die "$ssh df: $!"; |
eval { |
43 |
|
local $SIG{ALRM} = sub { die "ssh timeout\n"; }; |
44 |
|
alarm 10; # wait for ssh to connect and return first line |
45 |
|
open(DF,"$ssh df -klP |") || die "$ssh df: $!"; |
46 |
|
}; |
47 |
|
print STDERR " read DF eof=",eof(DF); |
48 |
while(<DF>) { |
while(<DF>) { |
49 |
chomp; |
chomp; |
50 |
my ($node,$total,$used,$aval,$use_pcnt,$mount) = split(/\s+/,$_,6); |
my ($node,$total,$used,$aval,$use_pcnt,$mount) = split(/\s+/,$_,6); |
56 |
} |
} |
57 |
} |
} |
58 |
close(DF); |
close(DF); |
59 |
|
alarm 0; # turn alarm off |
60 |
$cache->set( $ssh, $df, "1 min" ) if ($USE_CACHE); |
$cache->set( $ssh, $df, "1 min" ) if ($USE_CACHE); |
61 |
} |
} |
62 |
|
|