use of com.google.common.primitives.UnsignedLong in project coprhd-controller by CoprHD.
the class ProcStats method getCPUStats.
/**
* Retrieves CPU stats from /proc/stat file.
*/
public static CPUStats getCPUStats() throws IOException, SyssvcInternalException {
String[] fileData = FileReadUtil.readLines(PROC_STAT);
for (String line : fileData) {
if (line != null && line.startsWith("cpu")) {
String[] stats = line.trim().split(SPACE_VALUE);
UnsignedLong systemMode = UnsignedLong.valueOf(stats[3]);
if (stats.length > 7) {
systemMode = systemMode.plus(UnsignedLong.valueOf(stats[6]).plus(UnsignedLong.valueOf(stats[7])));
}
return new CPUStats(UnsignedLong.valueOf(stats[1]).plus(UnsignedLong.valueOf(stats[2])), systemMode, UnsignedLong.valueOf(stats[4]), UnsignedLong.valueOf(stats[5]));
}
}
throw SyssvcException.syssvcExceptions.syssvcInternalError("CPU stats not found.");
}
Aggregations