1

I'm new to this forum, so if I've made something wrong, please tell me. I made some research, but I can't understand the correct answer to my problem. I need to save CPU Temp, load and fan speed in one or more files in order to be able to analyze the behaviour of my system. Previous useful discussions I found interesting were: How to monitor & log server hardware temperatures & load and How to log CPU load?. I still cannot understand how to log this data every 0,5 secs for example, and if it is more convenient to use some script or some specific software. Thank you in advance.

EDIT: I found that psensor has a build-in logging feature, but it is some kind of beta feature... It is close to what I am looking for, but the log file is too much confusing and I cannot set sample time less than 1 second (it is not strictly necessary, but could help in some cases).

Fabio
  • 11
  • what CPU? do: grep "model name" /proc/cpuinfo – Doug Smythies Aug 03 '20 at 13:03
  • Why is the model of the CPU relevant? I want to stay as general as possible. – Fabio Aug 04 '20 at 14:45
  • Becuase if it works on your processor, tubostat does what you want for CPU Temp and load already. However, it does not monitor fan speed. – Doug Smythies Aug 04 '20 at 14:59
  • That software can be a solution, thank you! Does it have a log option? I read the manpage and it reports "turbostat reads hardware counters, but doesn't write them." so I need some script, I suppose... My CPU is an I7 8550U – Fabio Aug 04 '20 at 15:18
  • Yes, it has a log option. use --out file-name. I almost always have this running: sudo ~/turbostat --Summary --quiet --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 6. I rarely sample at less than 6 seconds, and often more. why? because then I would be waking deep idle CPUs just to ask them stuff for turbostat. – Doug Smythies Aug 04 '20 at 17:09
  • Thank you very much for your kind answer, I'll try as soon as possible and let you know if it works also for me! – Fabio Aug 04 '20 at 17:34
  • I tried to install turbostat, but i cannot find it anywhere... I read that it should be found in something like linux-hwe-tools, but unfortunately it doesn't work... could you help me again? – Fabio Aug 05 '20 at 15:23
  • @DougSmythies In some way I suppose to have it installed, because I can find a file called "turbostat" in /usr/bin. But even if I elevate to root with sudo -s, I still cannot execute it. – Fabio Aug 05 '20 at 16:38
  • It should be in the linux-tools-common package. Ubuntu is weird because they make it kernel version dependent, which it isn't. See also here. – Doug Smythies Aug 06 '20 at 03:43
  • I read your bug ticket, and it is strange that no one cares about it... Thank you very much for your help, I successed into run the command you suggested! Just a note, I must remove the ~/ and run just sudo turbostat. At the first launch, it asked for the installation of other packages, I've done it via apt-get install, and now it works like a charm! I don't know if I have to do something, but we can consider this question closed. – Fabio Aug 06 '20 at 10:01

3 Answers3

1

For processors on which it works, turbostat, linux-tools-common package with an additional kernel version dependency, can monitor your processor core and package temperatures, and CPU loads. It can not monitor your fan speeds.

It works on all modern Intel processors and some AMD processors. It is the only tool that upstream escalations will accept as authoritative. It has a great many options as to what to monitor.

Myself, I run this command almost always (no load, then some load, then no load):

$ sudo turbostat --Summary --quiet --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 6
Busy%   Bzy_MHz IRQ     PkgTmp  PkgWatt GFXWatt
0.03    800     214     30      1.24    0.00
0.03    800     142     30      1.24    0.00
0.02    800     96      30      1.24    0.00
0.34    800     292     30      1.24    0.00
16.78   4474    8467    46      22.15   0.00
16.76   4600    7880    45      23.03   0.00
16.76   4600    7742    46      23.11   0.00
15.95   4599    7336    31      21.96   0.00
0.03    800     150     30      1.24    0.00
0.02    800     123     30      1.24    0.00

The Busy% column would be 100% if all CPUs are 100% busy. In the above example the processor has 6 CPUs, and during the loaded phase one was busy at 100%, or 16.67% of 6 CPUs.

I rarely use a short interval. Often users do not seem to realize that idle CPUs can go into deep idle states for multiple seconds at a time, and they wake them just to sample stuff.

There is a log to file option, --out file-name.

There is also a very informative spew of information about your processor during startup, if the --quiet command line option is omitted. Example:

~$ sudo ~/turbostat --Summary --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 6
turbostat version 20.03.20 - Len Brown <lenb@kernel.org>
CPUID(0): GenuineIntel 0x16 CPUID levels; 0x80000008 xlevels; family:model:stepping 0x6:9e:d (6:158:13)
CPUID(1): SSE3 MONITOR SMX EIST TM2 TSC MSR ACPI-TM HT TM
CPUID(6): APERF, TURBO, DTS, PTM, HWP, HWPnotify, HWPwindow, HWPepp, No-HWPpkg, EPB
cpu4: MSR_IA32_MISC_ENABLE: 0x00850089 (TCC EIST MWAIT PREFETCH TURBO)
CPUID(7): SGX
cpu4: MSR_IA32_FEATURE_CONTROL: 0x00020005 (Locked )
CPUID(0x15): eax_crystal: 2 ebx_tsc: 308 ecx_crystal_hz: 0
TSC: 3696 MHz (24000000 Hz * 308 / 2 / 1000000)
CPUID(0x16): base_mhz: 3700 max_mhz: 4600 bus_mhz: 100
cpu4: MSR_MISC_PWR_MGMT: 0x00401cc0 (ENable-EIST_Coordination DISable-EPB DISable-OOB)
RAPL: 2759 sec. Joule Counter Range, at 95 Watts
cpu4: MSR_PLATFORM_INFO: 0x8080838f1012500
8 * 100.0 = 800.0 MHz max efficiency frequency
37 * 100.0 = 3700.0 MHz base frequency
cpu4: MSR_IA32_POWER_CTL: 0x003c005d (C1E auto-promotion: DISabled)
cpu4: MSR_TURBO_RATIO_LIMIT: 0x2b2b2e2e2e2e2e2e
43 * 100.0 = 4300.0 MHz max turbo 8 active cores
43 * 100.0 = 4300.0 MHz max turbo 7 active cores
46 * 100.0 = 4600.0 MHz max turbo 6 active cores
46 * 100.0 = 4600.0 MHz max turbo 5 active cores
46 * 100.0 = 4600.0 MHz max turbo 4 active cores
46 * 100.0 = 4600.0 MHz max turbo 3 active cores
46 * 100.0 = 4600.0 MHz max turbo 2 active cores
46 * 100.0 = 4600.0 MHz max turbo 1 active cores
cpu4: MSR_CONFIG_TDP_NOMINAL: 0x00000025 (base_ratio=37)
cpu4: MSR_CONFIG_TDP_LEVEL_1: 0x00000000 ()
cpu4: MSR_CONFIG_TDP_LEVEL_2: 0x00000000 ()
cpu4: MSR_CONFIG_TDP_CONTROL: 0x80000000 ( lock=1)
cpu4: MSR_TURBO_ACTIVATION_RATIO: 0x00000000 (MAX_NON_TURBO_RATIO=0 lock=0)
cpu4: MSR_PKG_CST_CONFIG_CONTROL: 0x00000000 (UNlocked, pkg-cstate-limit=0 (pc0))
cpu4: cpufreq driver: intel_pstate
cpu4: cpufreq governor: powersave
cpufreq intel_pstate no_turbo: 0
cpu4: MSR_MISC_FEATURE_CONTROL: 0x00000000 (L2-Prefetch L2-Prefetch-pair L1-Prefetch L1-IP-Prefetch)
cpu0: MSR_PM_ENABLE: 0x00000001 (HWP)
cpu0: MSR_HWP_CAPABILITIES: 0x0108252e (high 46 guar 37 eff 8 low 1)
cpu0: MSR_HWP_REQUEST: 0xff002e08 (min 8 max 46 des 0 epp 0xff window 0x0 pkg 0x0)
cpu0: MSR_HWP_INTERRUPT: 0x00000000 (Dis_Guaranteed_Perf_Change, Dis_Excursion_Min)
cpu0: MSR_HWP_STATUS: 0x00000004 (No-Guaranteed_Perf_Change, No-Excursion_Min)
cpu0: MSR_IA32_ENERGY_PERF_BIAS: 0x00000006 (balanced)
cpu0: MSR_RAPL_POWER_UNIT: 0x000a0e03 (0.125000 Watts, 0.000061 Joules, 0.000977 sec.)
cpu0: MSR_PKG_POWER_INFO: 0x000002f8 (95 W TDP, RAPL 0 - 0 W, 0.000000 sec.)
cpu0: MSR_PKG_POWER_LIMIT: 0x4283e800dd8320 (UNlocked)
cpu0: PKG Limit #1: ENabled (100.000000 Watts, 28.000000 sec, clamp ENabled)
cpu0: PKG Limit #2: ENabled (125.000000 Watts, 0.002441* sec, clamp DISabled)
cpu0: MSR_DRAM_POWER_LIMIT: 0x5400de00000000 (UNlocked)
cpu0: DRAM Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_PP0_POLICY: 0
cpu0: MSR_PP0_POWER_LIMIT: 0x00000000 (UNlocked)
cpu0: Cores Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_PP1_POLICY: 0
cpu0: MSR_PP1_POWER_LIMIT: 0x00000000 (UNlocked)
cpu0: GFX Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_IA32_TEMPERATURE_TARGET: 0x0064100d (100 C)
cpu0: MSR_IA32_PACKAGE_THERM_STATUS: 0x88460000 (30 C)
cpu0: MSR_IA32_PACKAGE_THERM_INTERRUPT: 0x00000003 (100 C, 100 C)
cpu4: MSR_PKGC3_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu4: MSR_PKGC6_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu4: MSR_PKGC7_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu4: MSR_PKGC8_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu4: MSR_PKGC9_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu4: MSR_PKGC10_IRTL: 0x00000000 (NOTvalid, 0 ns)
Busy%   Bzy_MHz IRQ     PkgTmp  PkgWatt GFXWatt
0.03    800     184     30      1.32    0.00

Turbostat does has no kernel version dependencies, but the Ubuntu version is wrapped in a rather restrictive script.

Doug Smythies
  • 15,448
  • 5
  • 44
  • 61
0

If you are ready to do some more reading/research/experimenting (this is not just a simple "install and go" solution) then you could use a tool such as Prometheus specifically it's node-exporter where a node in this context will be your PC. The node exporter can capture a lot of data from your PC on a (configurable) periodic basis. Prometheus has a basic web-based interface to query that data.

There are versions of Prometheus in the Ubuntu repositories so to get started it may be as easy as:

sudo apt-get install prometheus prometheus-node-exporter

If you want to report/analyse/graph that captured data then you may need other tools. I use Grafana which supports lots of data sources including Prometheus. It allows you to graph current/historical data very easily in many different ways.

codlord
  • 2,506
  • That's interesting, but I think it is too much powerful and consequently too much time consuming... I'll keep it in mind, but at the moment I think it is better to use something easier. For example, a web interface is something that I would avoid, it is more useful a CSV file for me at the moment. Thank you very much for your answer. – Fabio Aug 04 '20 at 14:55
0

I would recommend to utilize stable and simple RRDtool and CollectD based solution.

It may be:

You have to read more elsewhere about the setup of the both tools.
Anyway collectd is very popular and lightweight as it used in OpenWRT routers with small amounts of RAM.

N0rbert
  • 99,918
  • That's really interesting, thank you! Tell me if I understand well: I have to install RRDtool and because I want to use local files, I need Kcollectd, which is a graphical interaction with RRDtool. Am I right? – Fabio Aug 04 '20 at 15:00
  • Collectd depends on RRDtool, while Kcollectd is a front-end to Collectd. All stuff is presented in the repositories. But may need configuration. – N0rbert Aug 04 '20 at 15:34