use of org.opensearch.monitor.os.OsProbe in project fess by codelibs.
the class SystemHelper method getSystemCpuPercent.
protected short getSystemCpuPercent() {
final long now = System.currentTimeMillis();
if (now - systemCpuCheckTime > systemCpuCheckInterval) {
synchronized (this) {
if (now - systemCpuCheckTime > systemCpuCheckInterval) {
try {
final OsProbe osProbe = OsProbe.getInstance();
systemCpuPercent = osProbe.getSystemCpuPercent();
if (logger.isDebugEnabled()) {
logger.debug("Updated System Cpu {}%", systemCpuPercent);
}
} catch (final Exception e) {
logger.warn("Failed to get SystemCpuPercent.", e);
return 0;
}
systemCpuCheckTime = now;
}
}
}
return systemCpuPercent;
}
use of org.opensearch.monitor.os.OsProbe in project fess by codelibs.
the class SystemMonitorTarget method appendOsStats.
private void appendOsStats(final StringBuilder buf) {
buf.append("\"os\":{");
final OsProbe osProbe = OsProbe.getInstance();
buf.append("\"memory\":{");
buf.append("\"physical\":{");
append(buf, "free", () -> osProbe.getFreePhysicalMemorySize()).append(',');
append(buf, "total", () -> osProbe.getTotalPhysicalMemorySize());
buf.append("},");
buf.append("\"swap_space\":{");
append(buf, "free", () -> osProbe.getFreeSwapSpaceSize()).append(',');
append(buf, "total", () -> osProbe.getTotalSwapSpaceSize());
buf.append('}');
buf.append("},");
buf.append("\"cpu\":{");
append(buf, "percent", () -> osProbe.getSystemCpuPercent());
final OsStats osStats = osProbe.osStats();
buf.append("},");
append(buf, "load_averages", () -> osStats.getCpu().getLoadAverage());
buf.append("},");
}
Aggregations