org.hyperic.sigar.SigarException Java Examples

The following examples show how to use org.hyperic.sigar.SigarException. 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: ReadingInstancesFactory.java    From ats-framework with 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 #2
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpFinWait1(
                                               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.getTcpFinWait1());
        }
    };
}
 
Example #3
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #4
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #5
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #6
Source File: ReadingInstancesFactory.java    From ats-framework with 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());
        }
    };
}
 
Example #7
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpTimeWait(
                                               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.getTcpTimeWait());
        }
    };
}
 
Example #8
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpBound(
                                            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.getTcpBound());
        }
    };
}
 
Example #9
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpIdle(
                                           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.getTcpIdle());
        }
    };
}
 
Example #10
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpTotalInbound(
                                                   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.getTcpInboundTotal());
        }
    };
}
 
Example #11
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpTotalOutbound(
                                                    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.getTcpOutboundTotal());
        }
    };
}
 
Example #12
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static String constructProcessStartCommand(
                                                    Sigar sigar,
                                                    long pid ) {

    StringBuilder startCommand = new StringBuilder();
    try {
        String[] processArgs = sigar.getProcArgs(pid);
        for (String arg : processArgs) {
            startCommand.append(arg);
            startCommand.append(" ");
        }
        return startCommand.toString();
    } catch (SigarException e) {
        // some system processes can not be accessed
        return null;
    }
}
 
Example #13
Source File: SigarProcessManager.java    From kkFileView with 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 #14
Source File: ReadingInstancesFactory.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
private static ReadingInstance getTcpClosing(
                                              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.getTcpClosing());
        }
    };
}
 
Example #15
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #16
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #17
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #18
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #19
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #20
Source File: ReadingInstancesFactory.java    From ats-framework with 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 File: ReadingInstancesFactory.java    From ats-framework with 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 #22
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #23
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #24
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #25
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #26
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #27
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #28
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #29
Source File: ReadingInstancesFactory.java    From ats-framework with 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 #30
Source File: ReadingInstancesFactory.java    From ats-framework with 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();
        }
    };
}