Sample Header Ad - 728x90

Why does `pmset -g thermlog` behave so strangely when piped?

1 vote
0 answers
297 views
I'm trying to create some monitoring for the thermal throttling during some build operations. For that I'd wanted to make use of pmset -g thermlog, which works great when used directly in the console, but seems to behave weirdly when piped to tee for example. What I can observe is that these 3 lines are printed immediately, but the actual values are only emitted if another update is emitted, and for that update only the timestamp is printed immediately and the data only when another event is emitted. (For illustration purposes I only included the first "partial" event).
$ pmset -g thermlog | tee foo.txt
Note: No thermal warning level has been recorded
Note: No performance warning level has been recorded
2022-06-02 14:52:03 +0200
This doesn't happen when used without the piping.
$pmset -g thermlog
Note: No thermal warning level has been recorded
Note: No performance warning level has been recorded
2022-06-02 14:51:34 +0200 CPU Power notify
	CPU_Scheduler_Limit 	= 100
	CPU_Available_CPUs 	= 16
	CPU_Speed_Limit 	= 100
And it works fine if I use therm instead of thermlog, altough that only ever prints the one event obviously.
$ pmset -g therm | tee foo.txt
Note: No thermal warning level has been recorded
Note: No performance warning level has been recorded
2022-06-02 14:51:55 +0200 CPU Power notify
	CPU_Scheduler_Limit 	= 100
	CPU_Available_CPUs 	= 16
	CPU_Speed_Limit 	= 100
I actually want to consume the process output via Java's java.lang.Process, but there I see the same issue with the event data not being written immediately to the out stream. Can somebody explain what is wrong here and ideally provide a fix for using thermlog. I know that I could just query therm repeatedly, but that has a lower resolution and is not what I'm looking for.
Asked by user16358266 (111 rep)
Jun 2, 2022, 01:05 PM
Last activity: Jun 3, 2022, 07:16 AM