Examples of Swap


Examples of org.hyperic.sigar.Swap

  public void run() {
    boolean skip = false;
    CpuInfo[] cpuinfo = null;
    CpuPerc[] cpuPerc = null;
    Mem mem = null;
    Swap swap = null;
    FileSystem[] fs = null;
    String[] netIf = null;
    Uptime uptime = null;
    double[] loadavg = null;
    JSONObject json = new JSONObject();
    try {
      // CPU utilization
      cpuinfo = sigar.getCpuInfoList();
      cpuPerc = sigar.getCpuPercList();
      JSONArray cpuList = new JSONArray();
      for (int i = 0; i < cpuinfo.length; i++) {
        JSONObject cpuMap = new JSONObject();
        cpuMap.putAll(cpuinfo[i].toMap());
        cpuMap.put("combined", cpuPerc[i].getCombined());
        cpuMap.put("user", cpuPerc[i].getUser());
        cpuMap.put("sys", cpuPerc[i].getSys());
        cpuMap.put("idle", cpuPerc[i].getIdle());
        cpuMap.put("wait", cpuPerc[i].getWait());
        cpuMap.put("nice", cpuPerc[i].getNice());
        cpuMap.put("irq", cpuPerc[i].getIrq());
        cpuList.add(cpuMap);
      }
      sigar.getCpuPerc();
      json.put("cpu", cpuList);
     
      // Uptime
      uptime = sigar.getUptime();
      json.put("uptime", uptime.getUptime());
     
      // Load Average
      loadavg = sigar.getLoadAverage();
      JSONArray load = new JSONArray();
      load.add(loadavg[0]);
      load.add(loadavg[1]);
      load.add(loadavg[2]);
      json.put("loadavg", load);

      // Memory Utilization
      mem = sigar.getMem();
      JSONObject memMap = new JSONObject();
      memMap.putAll(mem.toMap());
      json.put("memory", memMap);

      // Swap Utilization
      swap = sigar.getSwap();
      JSONObject swapMap = new JSONObject();
      swapMap.putAll(swap.toMap());
      json.put("swap", swapMap);
     
      // Network Utilization
      netIf = sigar.getNetInterfaceList();
      JSONArray netInterfaces = new JSONArray();
View Full Code Here

Examples of org.hyperic.sigar.Swap

        return new Long(value / 1024);
    }

    public void output(String[] args) throws SigarException {
        Mem mem   = this.sigar.getMem();
        Swap swap = this.sigar.getSwap();

        Object[] header = new Object[] { "total", "used", "free" };

        Object[] memRow = new Object[] {
            format(mem.getTotal()),
            format(mem.getUsed()),
            format(mem.getFree())
        };

        Object[] actualRow = new Object[] {
            format(mem.getActualUsed()),
            format(mem.getActualFree())
        };

        Object[] swapRow = new Object[] {
            format(swap.getTotal()),
            format(swap.getUsed()),
            format(swap.getFree())
        };

        printf("%18s %10s %10s", header);

        printf("Mem:    %10ld %10ld %10ld", memRow);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.