From a4601ea2a8501273a149ac89889d54a9943b6e29 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 21 Feb 2005 02:19:49 +0000 Subject: [PATCH] prevent hang if nfs server is down --- bindings/java/src/net/hyperic/sigar/cmd/Df.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Df.java b/bindings/java/src/net/hyperic/sigar/cmd/Df.java index f6275d20..33264a7f 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Df.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Df.java @@ -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();