本文整理汇总了Java中org.hyperic.sigar.ProcState类的典型用法代码示例。如果您正苦于以下问题:Java ProcState类的具体用法?Java ProcState怎么用?Java ProcState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcState类属于org.hyperic.sigar包,在下文中一共展示了ProcState类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: Processes
import org.hyperic.sigar.ProcState; //导入依赖的package包/类
Processes(
final UnitConversionService units,
final CachingService caching,
final Sigar sigar,
final AnnotationMBeanExporter server) throws SigarException, JMException {
super();
for(final long pid : sigar.getProcList()) {
try {
final ProcState state = sigar.getProcState(pid);
final String name = state.getName();
final SigarProcessMetrics process = SigarProcessMetrics
.builder()
.units(units)
.name(name)
.pid(pid)
.cpu(caching.cache(() -> sigar.getProcCpu(pid)))
.memory(caching.cache(() -> sigar.getProcMem(pid)))
.build();
server.registerManagedResource(process, new ObjectName(format(OBJECT_NAME, name, pid)));
} catch(final SigarException e) {
// Process disappeared between listing and proc state
}
}
}
开发者ID:OctoPerf,项目名称:jmx-agent,代码行数:28,代码来源:Processes.java
示例2: getNetStats
import org.hyperic.sigar.ProcState; //导入依赖的package包/类
public static List<JSON> getNetStats() throws SigarException {
_init();
int flags = NetFlags.CONN_CLIENT | NetFlags.CONN_SERVER | NetFlags.CONN_TCP | NetFlags.CONN_UDP
| NetFlags.CONN_PROTOCOLS;
NetConnection[] nn = sigar.getNetConnectionList(flags);
List<JSON> l1 = new ArrayList<JSON>();
for (NetConnection n : nn) {
if (n.getRemotePort() == 0 && n.getLocalPort() == 0)
continue;
JSON jo = JSON.create().append("remoteaddress", n.getRemoteAddress())
.append("remoteport", n.getRemotePort()).append("localaddress", n.getLocalAddress())
.append("localport", n.getLocalPort()).append("recvqueue", n.getReceiveQueue())
.append("sendqueue", n.getSendQueue()).append("state", n.getState()).append("type", n.getType())
.append("typename", n.getTypeString());
if (n.getType() != NetFlags.CONN_UDP) {
jo.append("statename", n.getStateString());
}
try {
long pid = sigar.getProcPort(n.getType(), n.getLocalPort());
if (pid != 0) {
ProcState p = sigar.getProcState(pid);
if (p != null) {
jo.append("pid", pid + "/" + p.getName());
}
}
} catch (Exception e) {
// ignore
log.warn("get pid error, type=" + n.getType() + ", port=" + n.getLocalPort());
}
l1.add(jo);
}
return l1;
}
开发者ID:giiwa,项目名称:giiwa,代码行数:35,代码来源:Host.java
注:本文中的org.hyperic.sigar.ProcState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论