Package org.hyperic.sigar

Examples of org.hyperic.sigar.Sigar


    int processCount = NumberUtils.toInt(processCountStr, 1);
    long desirableXmx; // make 500M as default.
    long permGen = 32 * 1024 * 1024;
    try {
      // Make a free memory room size of reservedMemory.
      long free = new Sigar().getMem().getActualFree() - reservedMemory;
      long perProcessTotalMemory = Math.max(free / processCount, MIN_PER_PROCESS_MEM_SIZE);
      desirableXmx = (long) (perProcessTotalMemory * 0.5);
      permGen = Math.min(Math.max((long) (perProcessTotalMemory * 0.2), 50L * 1024 * 1024), 128 * 1024 * 1024);
      if (this.useXmxLimit) {
        desirableXmx = Math.min(DEFAULT_MAX_XMX_SIZE, desirableXmx);
View Full Code Here


  public void testArchLoader() throws ArchNotSupportedException, ArchLoaderException, UnsupportedEncodingException {
    AgentConfig agentConfig = new AgentConfig.NullAgentConfig(1).init();
    System.out.println(System.getProperty("java.library.path"));
    ArchLoaderInit archLoaderInit = new ArchLoaderInit();
    archLoaderInit.init(agentConfig.getHome().getNativeDirectory());
    Sigar sigar = new Sigar();
    sigar.getNativeLibrary();
    final String name = Charset.defaultCharset().name();
    System.out.println(name);
    System.out.println(URLDecoder.decode("D:\\nGrinder%20%ec%9a%b4%ec%98%81\\nGrinder%203" +
        ".3%20Release%20Package\\ngrinder-monitor\\lib\\sigar-native-1" +
        ".0.jar", name));
View Full Code Here

  }

  public static Sigar newSigar() throws Exception {
    final String libraryPath = NativeUtils.addResourcesToLibraryPath(getSigarBindings(), "sigar");
    try {
      return new Sigar();
    } catch (UnsatisfiedLinkError e) {
      logger.warn("Please add -Djava.library.path={} system property to resolve the UnsatisfiedLinkError", libraryPath);
      throw new RuntimeException(e);
    }
  }
View Full Code Here

        sigar.getLinkInfo(file);
    }

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

        String file;
        File dir = new File(System.getProperty("user.dir"));
        String[] entries = dir.list();
       
        for (int i=0; i<entries.length; i++) {
            file = entries[i];
            File testFile = new File(dir, file);
            if (!(testFile.exists() && testFile.canRead())) {
                continue;
            }
            if (testFile.isHidden()) {
                continue;
            }
            traceln(file + ":");
            getFileInfo(sigar,
                        testFile.getAbsolutePath());
        }

        file = "NO SUCH FILE";

        try {
            getFileInfo(sigar, file);
            assertTrue(false);
        } catch (SigarNotImplementedException e) {
            //XXX win32
        } catch (SigarException e) {
            traceln(file + ": " + e.getMessage());
            assertTrue(true);
        }

        File tmp = File.createTempFile("sigar-", "");
        file = tmp.getAbsolutePath();
        tmp.deleteOnExit();
        traceln("TMP=" + file);

        try {
            //stat() mtime is in seconds, this happens to quick to detect change.
            Thread.sleep(1000 * 1);
        } catch (InterruptedException e) {
        }

        try {
            FileInfo info = sigar.getFileInfo(file);

            FileOutputStream os = null;
            try {
                os = new FileOutputStream(file);
                os.write(1);
View Full Code Here

            }
        }
    }

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

        FileWatcherThread watcherThread =
            FileWatcherThread.getInstance();

        watcherThread.doStart();
View Full Code Here

        return found;
    }

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

        try {
            sigar.getProcArgs(getInvalidPid());
        } catch (SigarException e) {
        }

        try {
            String[] args = sigar.getProcArgs(sigar.getPid());

            if (getVerbose()) {
                findArg(args, TestProcArgs.class.getName());
            }

            if (args.length > 0) {
                assertTrue(args[0].indexOf("java") != -1);
            }

            //hpux has a limit less than what these args will be
            if (!System.getProperty("os.name").equals("HP-UX")) {
                //and this test only works when run under ant
                //assertTrue(findArg(args, TestProcArgs.class.getName()));
            }
        } catch (SigarNotImplementedException e) {
            //ok; might not happen on win32
        }

  long[] pids = sigar.getProcList();

  for (int i=0; i<pids.length; i++) {
            String pidTrace = "pid=" + pids[i];
            try {
                String[] args = sigar.getProcArgs(pids[i]);
                traceln(pidTrace);
                for (int j=0; j<args.length; j++) {
                    traceln("   " + j + "=>" + args[j] + "<==");
                }
            } catch (SigarException e) {
View Full Code Here

    public TestProcTime(String name) {
        super(name);
    }

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

        try {
            sigar.getProcTime(getInvalidPid());
        } catch (SigarException e) {
        }

        ProcCpu procTime = sigar.getProcCpu(sigar.getPid());

        assertGtEqZeroTrace("StartTime", procTime.getStartTime());
        traceln("StartDate=" + new Date(procTime.getStartTime()));
        //XXX
        //assertTrue(procTime.getStartTime() < System.currentTimeMillis());

        assertGtEqZeroTrace("User", procTime.getUser());

        assertGtEqZeroTrace("Sys", procTime.getSys());

        assertGtEqZeroTrace("Total", procTime.getTotal());

        double value = procTime.getPercent() * 100.0;
        traceln("Percent=" + value);
        assertTrue(value >= 0.0);
        int ncpu = sigar.getCpuList().length;
        assertTrue(value <= (100.0 * ncpu)); //SIGAR-145 Irix mode
    }
View Full Code Here

            //ok
        }
    }

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

        try {
      printModules(sigar, getInvalidPid());
        } catch (SigarException e) {
        }

        try {
      printModules(sigar, sigar.getPid());
        } catch (SigarNotImplementedException e) {
            return;
        }

  long[] pids = sigar.getProcList();

  for (int i=0; i<pids.length; i++) {
            try {
                printModules(sigar, pids[i]);
            } catch (SigarException e) {
View Full Code Here

    public TestNfsServerV2(String name) {
        super(name);
    }

    public void testCreate() throws Exception {
        Sigar sigar = getSigar();
        NfsServerV2 nfs;
       
        try {
            nfs = sigar.getNfsServerV2();
        } catch (SigarException e) {
            return;
        }

        traceMethods(nfs);
View Full Code Here

        SigarException ex;
        //true should make things blow up
        boolean useGlobal = false;

        public void run() {
            Sigar sigar;
            SigarProxy proxy;

            try {
                synchronized (lock) {
                    if (useGlobal) {
                        if (gSigar == null) {

                            gSigar = new Sigar();

                            gProxy = SigarProxyCache.newInstance(gSigar, 30 * 1000);
                        }

                        sigar = gSigar;
                        proxy = gProxy;
                    }
                    else {
                        sigar = new Sigar();
                   
                        proxy = SigarProxyCache.newInstance(sigar, 30 * 1000);
                    }
                }

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.