I use sensors
to keep an eye on CPU temperatures on the console. This is part of the output:
coretemp-isa-0001
Adapter: ISA adapter
Physical id 1: +45.0°C (high = +80.0°C, crit = +90.0°C)
Core 0: +39.0°C (high = +80.0°C, crit = +90.0°C)
Core 1: +39.0°C (high = +80.0°C, crit = +90.0°C)
Core 2: +40.0°C (high = +80.0°C, crit = +90.0°C)
Core 3: +38.0°C (high = +80.0°C, crit = +90.0°C)
Core 4: +40.0°C (high = +80.0°C, crit = +90.0°C)
Core 8: +39.0°C (high = +80.0°C, crit = +90.0°C)
Core 9: +38.0°C (high = +80.0°C, crit = +90.0°C)
Core 10: +38.0°C (high = +80.0°C, crit = +90.0°C)
Core 11: +39.0°C (high = +80.0°C, crit = +90.0°C)
Core 12: +39.0°C (high = +80.0°C, crit = +90.0°C)
nouveau-pci-0200
Adapter: PCI adapter
GPU core: +0.92 V (min = +0.92 V, max = +1.00 V)
fan1: 2220 RPM
temp1: +48.0°C (high = +95.0°C, hyst = +3.0°C)
(crit = +105.0°C, hyst = +5.0°C)
(emerg = +135.0°C, hyst = +5.0°C)
I would like to 'colorize' this output. In particular, if temperatures are above a certain threshold, I would like them to be shown in red. So, for example, let's say the threshold is 60, then any occurence of +60.0°C
, +61.0°C
, +62.0°C
, and so on should be in red (ideally, I would like an orange level and a red level based on two different thresholds, but a one level solution would be great as well). Ideally, this should also work with watch sensors
.
Best Answer
Usage:
sensors | ./color_sensors.awk
Usage with watch:
watch -c 'sensors | ./color_sensors.awk'
Result: