Package org.hyperic.sigar

Examples of org.hyperic.sigar.Sigar


        os.println("Sigar version......." + version);
        os.println("Build date.........." + build);
        os.println("SCM rev............." + scm);
        String host = getHostName();
        String fqdn;
        Sigar sigar = new Sigar();
        try {
            File lib = sigar.getNativeLibrary();
            if (lib != null) {
                archlib = lib.getName();
            }
            fqdn = sigar.getFQDN();
        } catch (SigarException e) {
            fqdn = "unknown";
        } finally {
            sigar.close();
        }

        os.println("Archlib............." + archlib);

        os.println("Current fqdn........" + fqdn);
View Full Code Here


            stat.getZombie()   + " zombie, " +
            stat.getStopped()  + " stopped... " + stat.getThreads() + " threads";
    }

    public static void main(String[] args) throws Exception {
        Sigar sigarImpl = new Sigar();

        SigarProxy sigar =
            SigarProxyCache.newInstance(sigarImpl, SLEEP_TIME);

        while (true) {
View Full Code Here

public class MemWatch {

    static final int SLEEP_TIME = 1000 * 10;

    public static void main(String[] args) throws Exception {
        Sigar sigar = new Sigar();

        if (args.length != 1) {
            throw new Exception("Usage: MemWatch pid");
        }

        long pid = Long.parseLong(args[0]);

        long lastTime = System.currentTimeMillis();

        ProcMem last = sigar.getProcMem(pid);

        while (true) {
            ProcMem cur = sigar.getProcMem(pid);
           
            StringBuffer diff = diff(last, cur);

            if (diff.length() == 0) {
                System.out.println("no change " +
View Full Code Here

    private Sigar sigarImpl;
    private SigarProxy sigar;
    private long pid = -1;

    public SigarProcess() {
        this.sigarImpl = new Sigar();
        this.sigar = SigarProxyCache.newInstance(sigarImpl);
    }
View Full Code Here

    private static String getenv(String key) {
        try {
            return System.getenv("ANT_HOME"); //check for junit.jar
        } catch (Error e) {
            /*1.4*/
            Sigar sigar = new Sigar();
            try {
                return sigar.getProcEnv("$$", "ANT_HOME");
            } catch (Exception se) {
                return null;
            }
            finally { sigar.close(); }
        }
    }
View Full Code Here

     * @deprecated
     */
    public static List getServiceConfigs(String exe)
        throws Win32Exception {

        Sigar sigar = new Sigar();
        try {
            return getServiceConfigs(sigar, exe);
        } finally {
            sigar.close();
        }
    }
View Full Code Here

        out.println("status........[" + getStatusString() + "]");

        if (getStatus() != SERVICE_RUNNING) {
            return;
        }
        Sigar sigar = new Sigar();
        try {
            long pid = sigar.getServicePid(getConfig().getName());
            out.println("pid...........[" + pid + "]");
        } catch (SigarException e) {
        } finally {
            sigar.close();
        }
    }
View Full Code Here

            }
            System.out.println(service.getStatusString());
            return;
        }
        else if ((args.length == 1) && (args[0].startsWith("Service."))) {
            Sigar sigar = new Sigar();
            try {
                services = Service.getServiceNames(sigar, args[0]);
            } finally {
                sigar.close();
            }
        }
        else if ((args.length == 1) && (args[0].endsWith(EXE_EXT))) {
            Sigar sigar = new Sigar();
            try {
                services = getServiceConfigs(args[0]);
            } finally {
                sigar.close();
            }
            for (int i=0; i<services.size(); i++) {
                ServiceConfig config = (ServiceConfig)services.get(i);
                config.list(System.out);
                System.out.println("");
View Full Code Here

            throw e;
        }
    }

    public void testValidQueries() throws Exception {
        Sigar sigar = getSigar();

        assertTrue(THIS_PROCESS,
                   runQuery(sigar, THIS_PROCESS) == 1);

        assertTrue(JAVA_PROCESS + " vs. " + OTHER_JAVA_PROCESS,
View Full Code Here

        }
        this.qf.clear();
    }

    public void testSelf() throws Exception {
        Sigar sigar = getSigar();

        //should have eaten some cpu during this test
        String q = "Cpu.Percent.ge=0.01";
        ProcessQuery status = this.qf.getQuery(q);
        long pid = sigar.getPid();
        traceln(q + "=" + status.match(sigar, pid));
    }
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.Sigar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.