Giter Site home page Giter Site logo

zabbix-lm-sensors-lld's Introduction

Zabbix-lm-sensors-lld

Simple bash script which returns {#CHIP}, {#SENSOR} and {#UNITS} macros. That macros should be used with native sensor type zabbix-agent items. Script depends on lm-sensors to work.

Should work with older zabbix (but I haven't opportunity to test it). Basic template attached as an example.

Installation:

  • Check that paths to egrep, cut, tr and sensors are valid.
  • Run script as zabbix user, check that it returns valid output
  • Drop userparameter_sensors.conf in zabbix_agentd.conf.d directory.

Example output:

{
	"data":[
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"temp5", "{#UNITS}":"°C"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"temp2", "{#UNITS}":"°C"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"temp1", "{#UNITS}":"°C"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"fan1", "{#UNITS}":"RPM"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"in13", "{#UNITS}":"V"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"in12", "{#UNITS}":"V"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"in3", "{#UNITS}":"V"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"in2", "{#UNITS}":"V"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"in1", "{#UNITS}":"V"},
		{"{#CHIP}":"w83795adg-i2c-1-2f", "{#SENSOR}":"in0", "{#UNITS}":"V"},
		{"{#CHIP}":"jc42-i2c-0-19", "{#SENSOR}":"temp1", "{#UNITS}":"°C"},
		{"{#CHIP}":"k10temp-pci-00c3", "{#SENSOR}":"temp1", "{#UNITS}":"°C"}
	]
}

zabbix-lm-sensors-lld's People

Contributors

ivanbayan avatar mckay1717 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zabbix-lm-sensors-lld's Issues

[enhancement] Thresholds discovery and triggers creation.

Ivan, thank you very much for sharing this template and the script - it is working charmingly! I only had to update path to egrep in the script. This small piece of software is very useful for monitoring of the low-end servers which don't have IPMI support.

It would be great if the template/script could also discover threshold values and automatically created triggers.

Alternative with jq

Thank you for sharing the idea of a LLD script. I am not a huge fan of JSON hacks though so I modified the script that it uses jq to do all the parsing. This way it is guaranteed that the output is always a valid and nicely formatted json. Feel free to reuse or perhaps provide as an alternative where jq is installed.

sensors -j | \
  jq '{"data": [to_entries[]|.key as $chip | .value |
                to_entries[]|.key as $group | .value | 
                select(type == "object") |  # discard scalars
                to_entries[]|.key as $sensor|
                select($sensor|test(".*input"))|
                if ($sensor|test("temp.*")) then .units="°C"
                  elif ($sensor|test("power.*")) then .units="W"
                  elif ($sensor|test("fan.*")) then .units="RPM"
                  elif ($sensor|test("in.*")) then .units="V"
                  else .units=""
                end | 
                {"{#CHIP}":$chip, "{#SENSOR}":($sensor|sub("_input";"")), "{#UNITS}":.units}]}'

Can't get this to work

Is it possible to give more detailed install instructions? I presume the discover.sensors need to placed on the zabbix-agent of the monitored host and added with a userparameter line? :)

Issue when detecting sensors

Testing on CentOS 7 with latest updates, I found that sensors detection works incorrectly:

	"data":[
		{"{#CHIP}":"coretemp-isa-0000", "{#SENSOR}":"temp1 temp2 temp3 temp4 temp5", "{#UNITS}":"°C"},
		{"{#CHIP}":"acpitz-virtual-0", "{#SENSOR}":"temp1 temp2", "{#UNITS}":"°C"}
	]
}

All sensor names puts in single sensor line.
One possible solution that make it work is to quote sensor query in discovery.sensor script like this:
done <<< "$($SENSORS -u $chip 2>/dev/null|$EGREP "_input:"|$TR -d " "|$CUT -d_ -f1)"
It works for me fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.