I didn't really like the solutions I found here for retrieving sensor data. Specifically, I didn't like the fact that the 'cut' command was used to remove the leading plus sign because this would break monitoring when the temperature exceeds 99 degrees. This is precisely the time you want sensor NOT to break.
That said, I'm very grateful to have found that information! It helped teach me a lot about UserParameter.
I also didn't like piping through two programs when one will do the trick. So I dug up (literally!) my old awk manual and here's what I came up with.
Replace "<item>" with the name of the record as returned by sensor, without the colon (":").
I use it to get voltage and fan speed data, too!
Too often I've cut-n-pasted code from some forum and it lost spaces and special characters. To be safe, I've included the code as an attachment.
That said, I'm very grateful to have found that information! It helped teach me a lot about UserParameter.
I also didn't like piping through two programs when one will do the trick. So I dug up (literally!) my old awk manual and here's what I came up with.
- sensor.int[<item>] - returns integer
- sensor.float[<item>] - returns floating point "%g" formatting
- sensor.text[<item>] - returns text
Replace "<item>" with the name of the record as returned by sensor, without the colon (":").
Code:
UserParameter=sensor.text[*],sensors | gawk '$$1~/^'$1':$$/ {print $$2}' IGNORECASE=1
UserParameter=sensor.float[*],sensors | gawk '$$1~/^'$1':$$/ {printf "%g",$$2}' IGNORECASE=1
UserParameter=sensor.int[*],sensors | gawk '$$1~/^'$1':$$/ {printf "%i",$$2}' IGNORECASE=1
Too often I've cut-n-pasted code from some forum and it lost spaces and special characters. To be safe, I've included the code as an attachment.
Comment