regigster NetInterface beans

This commit is contained in:
Doug MacEachern 2008-10-04 16:38:24 +00:00
parent 273a7aad96
commit bd94719a4a
1 changed files with 23 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import javax.management.ObjectInstance;
import javax.management.ObjectName; import javax.management.ObjectName;
import org.hyperic.sigar.FileSystem; import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.NetInterfaceConfig;
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;
@ -250,6 +251,28 @@ public class SigarRegistry extends AbstractMBean {
throw unexpectedError("FileSystemList", e); throw unexpectedError("FileSystemList", e);
} }
//NetInterface beans
try {
String[] ifnames = sigarImpl.getNetInterfaceList();
for (int i=0; i<ifnames.length; i++) {
String name = ifnames[i];
NetInterfaceConfig ifconfig =
this.sigar.getNetInterfaceConfig(name);
try {
sigarImpl.getNetInterfaceStat(name);
} catch (SigarException e) {
continue;
}
ReflectedMBean mbean =
new ReflectedMBean(sigarImpl, "NetInterface", name);
mbean.setType(mbean.getType() + "Stat");
mbean.putAttributes(ifconfig);
registerMBean(mbean);
}
} catch (SigarException e) {
throw unexpectedError("NetInterfaceList", e);
}
//physical memory bean //physical memory bean
registerMBean(new ReflectedMBean(sigarImpl, "Mem")); registerMBean(new ReflectedMBean(sigarImpl, "Mem"));
//swap memory bean //swap memory bean