Java Code Examples for org.hyperic.sigar.CpuPerc#getUser()

The following examples show how to use org.hyperic.sigar.CpuPerc#getUser() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Monitor.java    From JobX with Apache License 2.0 6 votes vote down vote up
public CPU(int index, CpuInfo info, CpuPerc perc) {
    this.index = index;
    this.cacheSize = info.getCacheSize();
    this.coresPerSocket = info.getCoresPerSocket();
    this.totalCores = info.getTotalCores();
    this.totalSockets = info.getTotalSockets();
    this.mhz = info.getMhz();
    this.model = info.getModel();
    this.vendor = info.getVendor();

    this.user = perc.getUser();
    this.sys = perc.getSys();
    this.nice = perc.getNice();
    this.idle = perc.getIdle();
    this.wait = perc.getWait();
    this.irq = perc.getIrq();
    this.softIrq = perc.getSoftIrq();
    this.stolen = perc.getStolen();
    this.combined = perc.getCombined();
}
 
Example 2
Source File: CPUsDetailedPercSampler.java    From kieker with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void sample(final IMonitoringController monitoringController) throws SigarException {
	if (!monitoringController.isMonitoringEnabled()) {
		return;
	}
	if (!monitoringController.isProbeActivated(SignatureFactory.createCPUSignature())) {
		return;
	}

	final CpuPerc[] cpus = this.sigar.getCpuPercList();
	final ITimeSource timesource = monitoringController.getTimeSource();
	for (int i = 0; i < cpus.length; i++) {
		if (monitoringController.isProbeActivated(SignatureFactory.createCPUSignature(i))) {
			final CpuPerc curCPU = cpus[i];
			// final double combinedUtilization = curCPU.getCombined();
			final CPUUtilizationRecord r = new CPUUtilizationRecord(timesource.getTime(),
					monitoringController.getHostname(), Integer.toString(i), curCPU.getUser(), curCPU.getSys(),
					curCPU.getWait(), curCPU.getNice(), curCPU.getIrq(), curCPU.getCombined(), curCPU.getIdle());
			monitoringController.newMonitoringRecord(r);
			// CPUsDetailedPercSampler.log.info("Sigar utilization: " + combinedUtilization
			// + "; " + " Record: " + r);
		}
	}
}
 
Example 3
Source File: CPUTotalMetric.java    From perfmon-agent with Apache License 2.0 4 votes vote down vote up
public void getValue(StringBuffer res) throws SigarException {
    CpuPerc cpu;
    if (coreID < 0) {
        cpu = sigarProxy.getCpuPerc();
    } else {
        cpu = sigarProxy.getCpuPercList()[coreID];
    }

    double val;
    switch (type) {

        case COMBINED:
            val = cpu.getCombined();
            break;
        case IDLE:
            val = cpu.getIdle();
            break;
        case IRQ:
            val = cpu.getIrq();
            break;
        case NICE:
            val = cpu.getNice();
            break;
        case SOFTIRQ:
            val = cpu.getSoftIrq();
            break;
        case STOLEN:
            val = cpu.getStolen();
            break;
        case SYSTEM:
            val = cpu.getSys();
            break;
        case USER:
            val = cpu.getUser();
            break;
        case IOWAIT:
            val = cpu.getWait();
            break;
        default:
            throw new SigarException("Unknown proc total type " + type);
    }

    if (!Double.isNaN(val)) {
        res.append(Double.toString(100 * val));
    } else {
        log.warn("Failed to get total cpu metric: " + types[type]);
    }
}