海阔天空任我飞

导航

 
  protected long getMemory() {
        OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        return osmxb.getTotalPhysicalMemorySize();
    }

  

protected String getOsType() {
        String osName = System.getProperty("os.name");
        if (osName.startsWith("Linux"))
            return "Linux";
        if (osName.startsWith("Windows"))
            return "Windows";
        if ((osName.contains("SunOS")) || (osName.contains("Solaris")))
            return "Solaris";
        if (osName.contains("Mac"))
            return "Mac";
        if (osName.contains("FreeBSD")) {
            return "FreeBSD";
        }
        return "Other";
    }

  

 protected int getCpuCores() {
        return Runtime.getRuntime().availableProcessors();
    }

  

getPid() {
        String name = ManagementFactory.getRuntimeMXBean().getName();
        int indexOf = name.indexOf(64);
        if (indexOf > 0) {
            name = name.substring(0, indexOf);
        }
        return Long.parseLong(name);
    }

  



posted on 2020-12-05 17:52  海阔天空任我飞  阅读(318)  评论(0编辑  收藏  举报