Ad Widget

Collapse

Getting Temperature - revisited

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rgerharz
    Junior Member
    • Jun 2007
    • 4

    #1

    Getting Temperature - revisited

    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.
    • 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
    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.
    Attached Files
  • andrelinux
    Junior Member
    • Jul 2007
    • 1

    #2
    Hi,
    I have inserted the code in the zabbix_agent.conf of the client, but executing on server zabbix-get - s 192.168.168.100 - k 'sensors.text [CPU Temp]' the system answers ZBX_NOTSUPPORTED. The client it is a Debian Etch stable. On server Zabbix 1.4.1.


    thx,

    Comment

    • steffi
      Junior Member
      • Jun 2008
      • 2

      #3
      is there a solution found? I have the same problem and also using a stable debian etch platform (ubuntu server 8.04).

      Thx for your help.
      Regards
      Steffi

      Comment

      • TuXator
        Junior Member
        • Feb 2009
        • 15

        #4
        The space inside the sensor name is the problem.
        Use this one:

        Code:
        UserParameter=sensor.text[*],/usr/bin/sensors $2 |/usr/bin/gawk -F' *: *' '$$1 ~ /^'"$1"'$/ { print $$2 }' IGNORECASE=1
        UserParameter=sensor.float[*],/usr/bin/sensors $2 |/usr/bin/gawk -F' *: *' '$$1 ~ /^'"$1"'$/ { printf "%g",$$2 }' IGNORECASE=1
        UserParameter=sensor.int[*],/usr/bin/sensors $2 |/usr/bin/gawk -F' *: *' '$$1 ~ /^'"$1"'$/ { printf "%i",$$2 }' IGNORECASE=1
        Using this, you can optionally specify the chip-name as second argument, e.g.:
        Code:
        # zabbix_get -s localhost -k 'sensor.float[Core 1,coretemp-isa-0001]'
        40

        Cheers,
        --leo

        Comment

        Working...