Git Product home page Git Product logo

zabbix-sensors's Introduction

zabbix-sensors

Zabbix template & scripts to discover & monitor Linux sensors

Features

  • Low-level discovery of sensors: temperature (with thresholds), fans, voltage and power
  • Triggers on temperature, fans and voltage (detect stopped fan, adjustable)
  • Data is gathered once as a single JSON and all other items are Dependent - extracted from raw JSON
  • All data is gathered directly from SysFS - no lm-sensors needed to function

Usage

  • Put sensors.conf in /etc/zabbix/zabbix_agentd.d folder
  • Put sensors.py in /etc/zabbix/scripts folder (or in any other, but then you'll need to adjust sensors.conf)
  • Import & link template

Requirements

  • Python3

Macros

  • {$SENSORS_FAN_LOW}: Low fan speed sensor threshold
  • {$SENSORS_TEMP_CRIT}: Crit value for temp sensors
  • {$SENSORS_TEMP_HIGH}: High value for temp sensors
  • {$SENSORS_TEMP_HYST}: Hysteresis for temp sensors to make sure that trigger is not firing when value oscillates over threshold and back
  • {$SENSORS_VOLTAGE_HIGH}: Voltage high threshold
  • {$SENSORS_VOLTAGE_LOW}: Voltage low threshold

Update 2023-06

  • Script was rewritten to gather data directly from sysfs instead of using sensors binary
  • Updated templates for 6.0 and 6.4

Update 2020-12

  • Script was rewritten from scratch to make use of new sensors argument -j to export in JSON format. If it's not supported then it'll fall back to parse raw text output of -u - this will stick for some time for backwards compatibility
  • Move to Python3

zabbix-sensors's People

Contributors

blind-oracle avatar nikosch86 avatar noobcode73 avatar zocker1999net avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zabbix-sensors's Issues

Problems and questions

Hello, thanks for the work you did even it doesn't work for me lol.

First, I want to know if this tool could gives data, makes graphics, or not at all and only send warnings.

Second, the Item key isn't supported, I'm on 4.2 version.

Third, tell me if i'm wrong :

  • I installed lm-sensors on my client
  • I added the files sensors.conf & discover-sensors.py on my client
  • I imported the .xml
  • I added the Template_Sensors to my client in the configuration

Thank you for reply !
Aurèle

template for zabbix 3.x

Hi,
Thank you for your work. However, I'm unable to import the XML file into Zabbix 3.0, as it is not recognized. I have tried changing the tag to 3.0 but it's not enough, there should be other specs that have changed. If, by any chance, you have a XML template compatible with Zabbix version 3.0, or if you know what needs to be adapted to make it work with Zabbix 3.0, I'd be glad to use it. I will have a look on my side as well, maybe it's not that complicated.

Regards

If the sensors file corrupted the script fail

In sensor.py you can add the fix what is worked for me.
From line nr 27:

def process_sensors(path):
    r = {}
    for fn in os.listdir(path):
        #NEW----------------------
        #If the file is corrupted, the script will jump it over
        try:
            with open(f"{path}/{fn}") as f:
                f.read()
        except:
            continue
        #ENDOFNEW-----------------

        m = re.match(r"^(fan|in|temp|power)(\d+)_(.*)$", fn)
        if not m:
            continue

        t, i, rd = m.group(1, 2, 3)

        sens = f"{t}{i}"
        if sens not in r:
            r[sens] = {"sensor_type": t}

        r[sens][rd] = read_parse(f"{path}/{fn}")

    return r

error: 'Cannot obtain sensor information.'

Hello!
First of all, many thanks for the template and scripts.
I haven't found a better fit for my case, but I've run into a problem that I can't solve on my own.
I spent a lot of time, but to no avail. The problem is that this set of scripts and the zabbix template normally work only with the CPU temperature, if there are NMVE disks or motherboard sensors in the system agent will swear with errors:

...
2023/08/05 18:42:33.001090 check 'sensor["nvme-pci-0400", "temp1"]' is not supported: Cannot obtain sensor information.
2023/08/05 18:42:34.001322 check 'sensor["nvme-pci-0200", "temp1"]' is not supported: Cannot obtain sensor information.
2023/08/05 18:42:35.001616 check 'sensor["acpitz-acpi-0", "temp1"]' is not supported: Cannot obtain sensor information.
2023/08/05 18:42:36.001255 check 'sensor["acpitz-acpi-0", "temp2"]' is not supported: Cannot obtain sensor information.
2023/08/05 18:42:42.001598 check 'sensor["nvme-pci-0300", "temp1"]' is not supported: Cannot obtain sensor information.
2023/08/05 18:42:43.000917 check 'sensor["nvme-pci-0100", "temp1"]' is not supported: Cannot obtain sensor information.
...

This is an example of a sensors -j command output from a server where there is no collection from NMVE and ACPI interface:

root@pve02:~# sensors -j
{
   "nvme-pci-0400":{
      "Adapter": "PCI adapter",
      "Composite":{
         "temp1_input": 39.850,
         "temp1_max": 82.850,
         "temp1_min": -273.150,
         "temp1_crit": 84.850,
         "temp1_alarm": 0.000
      }
   },
   "nvme-pci-0200":{
      "Adapter": "PCI adapter",
      "Composite":{
         "temp1_input": 39.850,
         "temp1_max": 82.850,
         "temp1_min": -273.150,
         "temp1_crit": 84.850,
         "temp1_alarm": 0.000
      }
   },
   "acpitz-acpi-0":{
      "Adapter": "ACPI interface",
      "temp1":{
         "temp1_input": 27.800,
         "temp1_crit": 100.000
      },
      "temp2":{
         "temp2_input": 29.800,
         "temp2_crit": 100.000
      }
   },
   "coretemp-isa-0000":{
      "Adapter": "ISA adapter",
      "Package id 0":{
         "temp1_input": 49.000,
         "temp1_max": 68.000,
         "temp1_crit": 73.000,
         "temp1_crit_alarm": 0.000
      },
      "Core 0":{
         "temp2_input": 46.000,
         "temp2_max": 68.000,
         "temp2_crit": 73.000,
         "temp2_crit_alarm": 0.000
      },
      "Core 1":{
         "temp3_input": 49.000,
         "temp3_max": 68.000,
         "temp3_crit": 73.000,
         "temp3_crit_alarm": 0.000
      },
      "Core 2":{
         "temp4_input": 49.000,
         "temp4_max": 68.000,
         "temp4_crit": 73.000,
         "temp4_crit_alarm": 0.000
      },
      "Core 3":{
         "temp5_input": 48.000,
         "temp5_max": 68.000,
         "temp5_crit": 73.000,
         "temp5_crit_alarm": 0.000
      }
   },
   "nvme-pci-0300":{
      "Adapter": "PCI adapter",
      "Composite":{
         "temp1_input": 39.850,
         "temp1_max": 82.850,
         "temp1_min": -273.150,
         "temp1_crit": 84.850,
         "temp1_alarm": 0.000
      }
   },
   "nvme-pci-0100":{
      "Adapter": "PCI adapter",
      "Composite":{
         "temp1_input": 39.850,
         "temp1_max": 82.850,
         "temp1_min": -273.150,
         "temp1_crit": 84.850,
         "temp1_alarm": 0.000
      }
   }
}

Can you tell me in which direction to search for the cause of the problem in order to collect information completely on all sensors.
I am using Zabbix Server version 6.4 and Zabbix Agent 2 on hosts

Template not fetching sensor values

Hello,

I'm having a problem with getting the values from the sensors of my linux server.The problems seems to be recurrent as I followed this thread in zabbix forum.

Could you look into this and give some feedback?

Kind regards,

Missing UserParameter

Hello,

Just tried your template, items try to use this kind of parameter :

sensor["coretemp-isa-0000", "temp1"]

But your sensors.conf only contains

UserParameter=lmsensors.discover[*],/etc/zabbix/scripts/sensors.py $1

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.