I want to get an approach of CPU usage (of all cores)
Currenlty i can't get the info of "/proc/stat" (since API 27)
so i think of getting the info with the frequency or similar:
Working with all the previous answers i get close to what i want, but not enough
Main Func
private fun ReadCpu3():String{
val sb = StringBuffer();
sb.append("abi: ").append(Build.CPU_ABI).append("\n");
if (File("/proc/cpuinfo").exists()) {
try {
//val br = BufferedReader(FileReader(File("/proc/cpuinfo")));
val file = File("/proc/cpuinfo")
file.bufferedReader().forEachLine {
sb.append(it+"\n");
}
} catch (e: IOException) {
e.printStackTrace();
}
}
return sb.toString();
}
My results
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 45
model name : Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz
stepping : 6
microcode : 1561
cpu MHz : 600.000
cache size : 20480 KB
physical id : 0
siblings : 16
core id : 0
cpu cores : 8
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid xsaveopt
bogomips : 4399.93
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
So i get all the info of the CPU but not the actual load or usage. I do not know if with the current info i can manage to get a proximity of the cpu usage and how exactly.