All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.rdrei.android.buildtimetracker.reporters.SysInfo.groovy Maven / Gradle / Ivy

The newest version!
package net.rdrei.android.buildtimetracker.reporters;

public class SysInfo {
    String getOSIdentifier() {
        ["os.name", "os.version", "os.arch"].collect { System.getProperty(it) }.join(" ")
    }

    long getMaxMemory() {
        MemoryUtil.physicalMemoryAvailable
    }

    String getCPUIdentifier() {
        def os = System.getProperty("os.name")
        if (os.equalsIgnoreCase("mac os x")) {
            def proc = ["sysctl", "-n", "machdep.cpu.brand_string"].execute()
            proc.waitFor()

            if (proc.exitValue() == 0) {
                return proc.in.text.trim()
            }
        } else if (os.equalsIgnoreCase("linux")) {
            def osName = ""
            new File("/proc/cpuinfo").eachLine {
                if (!osName.isEmpty()) return

                if (it.startsWith("model name")) {
                    osName = it.split(": ")[1]
                }
            }
            return osName
        }

        return ""
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy