register FileSystem beans

This commit is contained in:
Doug MacEachern 2008-10-04 01:31:16 +00:00
parent e2616dbac1
commit 273a7aad96
1 changed files with 21 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import javax.management.MBeanServer;
import javax.management.ObjectInstance; import javax.management.ObjectInstance;
import javax.management.ObjectName; import javax.management.ObjectName;
import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.Sigar; import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.SigarLoader; import org.hyperic.sigar.SigarLoader;
@ -197,7 +198,7 @@ public class SigarRegistry extends AbstractMBean {
this.mbeanServer.registerMBean(mbean, name); this.mbeanServer.registerMBean(mbean, name);
this.managedBeans.add(instance.getObjectName()); this.managedBeans.add(instance.getObjectName());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} }
@ -230,6 +231,25 @@ public class SigarRegistry extends AbstractMBean {
throw unexpectedError("CpuInfoList", e); throw unexpectedError("CpuInfoList", e);
} }
//FileSystem beans
try {
FileSystem[] fslist = sigarImpl.getFileSystemList();
for (int i=0; i<fslist.length; i++) {
FileSystem fs = fslist[i];
if (fs.getType() != FileSystem.TYPE_LOCAL_DISK) {
continue;
}
String name = fs.getDirName();
ReflectedMBean mbean =
new ReflectedMBean(sigarImpl, "FileSystem", name);
mbean.setType(mbean.getType() + "Usage");
mbean.putAttributes(fs);
registerMBean(mbean);
}
} catch (SigarException e) {
throw unexpectedError("FileSystemList", e);
}
//physical memory bean //physical memory bean
registerMBean(new ReflectedMBean(sigarImpl, "Mem")); registerMBean(new ReflectedMBean(sigarImpl, "Mem"));
//swap memory bean //swap memory bean