Java Code Examples for org.hyperic.sigar.SigarException

The following examples show how to use org.hyperic.sigar.SigarException. These examples are extracted from open source projects. 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 Project: WeBASE-Front   Source File: PerformanceService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * syncPerformanceInfo per 5s
 */
@Scheduled(cron = "0/5 * * * * ?")
public void syncPerformanceInfo() throws SigarException {
    log.debug("begin sync performance");
    if (!constants.isMonitorEnabled()) {
        return;
    }
    Performance performance = new Performance();
    performance.setMemoryUseRatio(getMemoryRatio());
    performance.setCpuUseRatio(getCpuRatio());
    performance.setDiskUseRatio(getDiskRatio());
    Long currentTime = System.currentTimeMillis();
    performance.setTimestamp(currentTime);

    try {
        Map<String, Long> map = getNetSpeed();
        performance.setTxbps(new BigDecimal(map.get(TXBPS)));
        performance.setRxbps(new BigDecimal(map.get(RXBPS)));
    } catch (Exception e) {
        log.error("get net speed failed.", e);
    }

    performanceRepository.save(performance);
    log.debug("insert success =  " + performance.getId());
}
 
Example 2
Source Project: kkFileViewOfficeEdit   Source File: SigarProcessManager.java    License: Apache License 2.0 6 votes vote down vote up
public long findPid(ProcessQuery query) throws IOException {
    Sigar sigar = new Sigar();
    try {
        long[] pids = ProcessFinder.find(sigar, "State.Name.eq=" + query.getCommand());
        for (int i = 0; i < pids.length; i++) {
            String[] arguments = sigar.getProcArgs(pids[i]);
            if (arguments != null && argumentMatches(arguments, query.getArgument())) {
                return pids[i];
            }
        }
        return PID_NOT_FOUND;
    } catch (SigarException sigarException) {
        throw new IOException("findPid failed", sigarException);
    } finally {
        sigar.close();
    }
}
 
Example 3
Source Project: ats-framework   Source File: SigarWrapper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * called on each poll
 *
 * @throws SigarException
 * @throws MonitorConfigurationException
 */
void refresh() throws SigarException, MonitorConfigurationException {

    try {
        this.swap = this.sigar.getSwap();
        this.memory = this.sigar.getMem();
        this.cpu = this.sigar.getCpu();
        this.cpuPerc = this.sigar.getCpuPerc();
        if (!OperatingSystemType.getCurrentOsType().equals(OperatingSystemType.AIX)) {
            this.netstat = this.sigar.getNetStat();
            this.tcp = this.sigar.getTcp();
        }
        this.loadAvrg = new SigarLoadAverage(this.sigar);
    } catch (Exception e) {
        final String errorMsg = "Error retrieving data from the Sigar monitoring system";
        log.error(errorMsg, e);
        throw new MonitorConfigurationException(errorMsg, e);
    }

}
 
Example 4
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getSwapTotal(
                                             SigarWrapper sigarWrapper,
                                             ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               0) {
        private static final long serialVersionUID = 1L;

        @Override
        public void init() throws SigarException {

            applyMemoryNormalizationFactor();
        }

        @Override
        public float poll() {

            return (fixLongValue(sigarWrapper.swap.getTotal()) * normalizationFactor);
        }
    };
}
 
Example 5
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getSwapUsed(
                                            SigarWrapper sigarWrapper,
                                            ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               0) {
        private static final long serialVersionUID = 1L;

        @Override
        public void init() throws SigarException {

            applyMemoryNormalizationFactor();
        }

        @Override
        public float poll() {

            return (fixLongValue(sigarWrapper.swap.getUsed()) * normalizationFactor);
        }
    };
}
 
Example 6
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getSwapFree(
                                            SigarWrapper sigarWrapper,
                                            ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               0) {
        private static final long serialVersionUID = 1L;

        @Override
        public void init() throws SigarException {

            applyMemoryNormalizationFactor();
        }

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.swap.getFree()) * normalizationFactor;
        }
    };
}
 
Example 7
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getSwapPagesIn(
                                               SigarWrapper sigarWrapper,
                                               ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.swap.getPageIn());
        }
    };
}
 
Example 8
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getSwapPagesOut(
                                                SigarWrapper sigarWrapper,
                                                ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.swap.getPageOut());
        }
    };
}
 
Example 9
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getLoadAverage1minute(
                                                      SigarWrapper sigarWrapper,
                                                      ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            double dValue = fixDoubleValue(sigarWrapper.loadAvrg.getLastMinute());

            // return a float with 2 digits after the decimal point
            return new BigDecimal(dValue).setScale(2, BigDecimal.ROUND_DOWN).floatValue();
        }
    };
}
 
Example 10
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getLoadAverage15minutes(
                                                        SigarWrapper sigarWrapper,
                                                        ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            double dValue = fixDoubleValue(sigarWrapper.loadAvrg.getLast15Minutes());

            // return a float with 2 digits after the decimal point
            return new BigDecimal(dValue).setScale(2, BigDecimal.ROUND_DOWN).floatValue();
        }
    };
}
 
Example 11
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getCpuUsageWaitingForIO(
                                                        SigarWrapper sigarWrapper,
                                                        ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               100.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixDoubleValueInPercents(sigarWrapper.cpuPerc.getWait());
        }
    };
}
 
Example 12
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getCpuUsageRunningKernelCode(
                                                             SigarWrapper sigarWrapper,
                                                             ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               100.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixDoubleValueInPercents(sigarWrapper.cpuPerc.getSys());
        }
    };
}
 
Example 13
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getCpuUsageRunningUserCode(
                                                           SigarWrapper sigarWrapper,
                                                           ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               100.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixDoubleValueInPercents(sigarWrapper.cpuPerc.getUser());
        }
    };
}
 
Example 14
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getCpuUsageTotal(
                                                 SigarWrapper sigarWrapper,
                                                 ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               100.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixDoubleValueInPercents(sigarWrapper.cpuPerc.getSys()
                                            + sigarWrapper.cpuPerc.getUser()
                                            + sigarWrapper.cpuPerc.getWait());
        }
    };
}
 
Example 15
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatActiveConnectionOpenings(
                                                                   SigarWrapper sigarWrapper,
                                                                   ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getActiveOpens());
        }
    };
}
 
Example 16
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatPassiveConnectionOpenings(
                                                                    SigarWrapper sigarWrapper,
                                                                    ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getPassiveOpens());
        }
    };
}
 
Example 17
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatFailedConnectionAttemtps(
                                                                   SigarWrapper sigarWrapper,
                                                                   ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getAttemptFails());
        }
    };
}
 
Example 18
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatResetConnections(
                                                           SigarWrapper sigarWrapper,
                                                           ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getEstabResets());
        }
    };
}
 
Example 19
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatCurrentConnections(
                                                             SigarWrapper sigarWrapper,
                                                             ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getCurrEstab());
        }
    };
}
 
Example 20
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatSegmentsReceived(
                                                           SigarWrapper sigarWrapper,
                                                           ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getInSegs());
        }
    };
}
 
Example 21
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatSegmentsSent(
                                                       SigarWrapper sigarWrapper,
                                                       ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getOutSegs());
        }
    };
}
 
Example 22
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatSegmentsRetransmitter(
                                                                SigarWrapper sigarWrapper,
                                                                ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getRetransSegs());
        }
    };
}
 
Example 23
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatOutResets(
                                                    SigarWrapper sigarWrapper,
                                                    ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getOutRsts());
        }
    };
}
 
Example 24
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getNetstatInErrors(
                                                   SigarWrapper sigarWrapper,
                                                   ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.tcp.getInErrs());
        }
    };
}
 
Example 25
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpClose(
                                            SigarWrapper sigarWrapper,
                                            ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.netstat.getTcpClose());
        }
    };
}
 
Example 26
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpListen(
                                             SigarWrapper sigarWrapper,
                                             ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.netstat.getTcpListen());
        }
    };
}
 
Example 27
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpSynSent(
                                              SigarWrapper sigarWrapper,
                                              ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.netstat.getTcpSynSent());
        }
    };
}
 
Example 28
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpSynReceived(
                                                  SigarWrapper sigarWrapper,
                                                  ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.netstat.getTcpSynRecv());
        }
    };
}
 
Example 29
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpEstablished(
                                                  SigarWrapper sigarWrapper,
                                                  ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.netstat.getTcpEstablished());
        }
    };
}
 
Example 30
Source Project: ats-framework   Source File: ReadingInstancesFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpCloseWait(
                                                SigarWrapper sigarWrapper,
                                                ReadingBean reading ) throws SigarException {

    return new ReadingInstance(sigarWrapper,
                               String.valueOf(reading.getDbId()),
                               reading.getMonitorName(),
                               reading.getName(),
                               reading.getUnit(),
                               1.0F) {
        private static final long serialVersionUID = 1L;

        @Override
        public float poll() {

            return fixLongValue(sigarWrapper.netstat.getTcpCloseWait());
        }
    };
}