prevent hang if nfs server is down

This commit is contained in:
Doug MacEachern 2005-02-21 02:19:49 +00:00
parent 6095ad4e6f
commit a4601ea2a8
1 changed files with 11 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import net.hyperic.sigar.SigarException;
import net.hyperic.sigar.FileSystem;
import net.hyperic.sigar.FileSystemMap;
import net.hyperic.sigar.FileSystemUsage;
import net.hyperic.sigar.NfsFileSystem;
import net.hyperic.sigar.shell.FileCompleter;
import net.hyperic.sigar.util.GetlineCompleter;
@ -91,8 +92,16 @@ public class Df extends SigarCommandBase {
long used, avail, total, pct;
try {
FileSystemUsage usage =
this.sigar.getFileSystemUsage(fs.getDirName());
FileSystemUsage usage;
if (fs instanceof NfsFileSystem) {
NfsFileSystem nfs = (NfsFileSystem)fs;
if (!nfs.ping()) {
println(fs.getDevName() +
" !!! nfs server is down !!!");
return;
}
}
usage = this.sigar.getFileSystemUsage(fs.getDirName());
used = usage.getTotal() - usage.getFree();
avail = usage.getAvail();