Small change to SystemStats


#1

On linux getDeviceDescription() returns an empty string, on ARM systems this might be useful (it must be moved after the
LinuxStatsHelpers declaration)

String SystemStats::getDeviceDescription()
{
    return LinuxStatsHelpers::getCpuInfo ("Hardware");
}

on x86 it will be empty anyway

 

Also the CPU vendor is not vendor_id, it's "CPU implementer    : 0x41" (this means Samsung i guess)

 


#2

Sure, that seems like a good request.

I don't understand your point about the CPU vendor though, vendor_id seems to be the correct field AFAICT (?)


#3

No such field exists for ARM cpus so it's valid only for x86, i was looking for some cross platform way to find this info but so far no luck. Below i'm pasting output from 2 different ARM platforms i have handy at home:

Rapberry PI:

[root@sensitive:~]# cat /proc/cpuinfo
processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
Features        : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000e
Serial          : 0000000059edd177


And output from a ODROID X2 (exynos based)

[root@odroid:~]# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 3984.58
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

processor       : 1
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 3984.58
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

processor       : 2
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 3984.58
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

processor       : 3
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 3984.58
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

Hardware        : ODROIDX2
Revision        : 0000
Serial          : 0000000000000000

 

I thought the the CPU implementer was the equivalent of vendor_id, but it looks like it might not be (raspberry is broadcom and exynos is samsung and both have the same ID)

But there might be a better way to get some info using the uname() call:

#include <sys/utsname.h>
#include <stdio.h>

int main(void)
{
  struct utsname unameData;
  uname(&unameData);
  printf("System name: %s\n", unameData.sysname);
  printf("Node name: %s\n", unameData.nodename);
  printf("Release level: %s\n", unameData.release);
  printf("Version level: %s\n", unameData.version);
  printf("Hardware type: %s\n", unameData.machine);
}

for Raspberry this returns:

[root@sensitive:~]# ./a.out
System name: Linux
Node name: sensitive
Release level: 3.12.4+
Version level: #10 PREEMPT Sun Jan 5 00:25:32 CET 2014
Hardware type: armv6l


for Odroid:

[root@odroid:~]# ./a.out
System name: Linux
Node name: odroid
Release level: 3.8.13.18
Version level: #1 SMP PREEMPT Fri Feb 21 14:47:18 BRT 2014
Hardware type: armv7l

The hardware type field and release level are useful within some applications to find out what the system can do.


#4

Seems like "model name" would do the trick, e.g. 

 

String SystemStats::getCpuVendor()
{
    String v (LinuxStatsHelpers::getCpuInfo ("vendor_id"));

    if (v.isEmpty())
        v = LinuxStatsHelpers::getCpuInfo ("model name");

    return v;
}