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?