Run command when temperature exceeds threshold, without daemon

daemonhookkerneltemperature

I need to run a specific command if my laptop gets too hot (for example, send a STOP signal to Firefox or Virtualbox in order to prevent my laptop from shutting down violently and damaging my hard disks).

I can easily write a program that loops indefinitely while periodically checking the temperature. This question's answer uses this approach.

However, I would like to avoid running my own daemon and instead attach my program to an existing one. For example, I can see in my syslog:

May 5 02:52:27 myhostname kernel: [ 9141.022262] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9276, limit 9000

So there is already code in my machine checking for temperature, which fires some action depending on a condition (eg log warning message when temperature exceeds 9000). Another example is that the fan speeds up based on the same temperature.

How can I attach my program to this existing code in my machine?
Are the fan driver speed change and kernel temperature warning message fired from the same code? How can I find this out?

Best Answer

You're going to have to run some sort of daemon that monitors for that sort of thing. Hardware sensors are just inert data sources and usually can't actually perform actions on their own.

If you're just looking to get out out writing custom code, you can look into installing the collectd-sensors package (your distro may call it something else) which will keep a history of temperatures. After you configure collectd to track temperature data you should be able to set up a collectd notification for that kind of event.

Related Question