summaryrefslogtreecommitdiffstats
path: root/src/collectors/python.d.plugin/sensors
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 12:08:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 12:08:18 +0000
commit5da14042f70711ea5cf66e034699730335462f66 (patch)
tree0f6354ccac934ed87a2d555f45be4c831cf92f4a /src/collectors/python.d.plugin/sensors
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-5da14042f70711ea5cf66e034699730335462f66.tar.xz
netdata-5da14042f70711ea5cf66e034699730335462f66.zip
Merging upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/collectors/python.d.plugin/sensors')
l---------src/collectors/python.d.plugin/sensors/README.md1
-rw-r--r--src/collectors/python.d.plugin/sensors/integrations/linux_sensors_lm-sensors.md187
-rw-r--r--src/collectors/python.d.plugin/sensors/metadata.yaml184
-rw-r--r--src/collectors/python.d.plugin/sensors/sensors.chart.py179
-rw-r--r--src/collectors/python.d.plugin/sensors/sensors.conf61
5 files changed, 612 insertions, 0 deletions
diff --git a/src/collectors/python.d.plugin/sensors/README.md b/src/collectors/python.d.plugin/sensors/README.md
new file mode 120000
index 000000000..4e92b0882
--- /dev/null
+++ b/src/collectors/python.d.plugin/sensors/README.md
@@ -0,0 +1 @@
+integrations/linux_sensors_lm-sensors.md \ No newline at end of file
diff --git a/src/collectors/python.d.plugin/sensors/integrations/linux_sensors_lm-sensors.md b/src/collectors/python.d.plugin/sensors/integrations/linux_sensors_lm-sensors.md
new file mode 100644
index 000000000..f743d410c
--- /dev/null
+++ b/src/collectors/python.d.plugin/sensors/integrations/linux_sensors_lm-sensors.md
@@ -0,0 +1,187 @@
+<!--startmeta
+custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/sensors/README.md"
+meta_yaml: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/sensors/metadata.yaml"
+sidebar_label: "Linux Sensors (lm-sensors)"
+learn_status: "Published"
+learn_rel_path: "Collecting Metrics/Hardware Devices and Sensors"
+most_popular: False
+message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
+endmeta-->
+
+# Linux Sensors (lm-sensors)
+
+
+<img src="https://netdata.cloud/img/microchip.svg" width="150"/>
+
+
+Plugin: python.d.plugin
+Module: sensors
+
+<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
+
+## Overview
+
+Examine Linux Sensors metrics with Netdata for insights into hardware health and performance.
+
+Enhance your system's reliability with real-time hardware health insights.
+
+
+Reads system sensors information (temperature, voltage, electric current, power, etc.) via [lm-sensors](https://hwmon.wiki.kernel.org/lm_sensors).
+
+
+This collector is supported on all platforms.
+
+This collector supports collecting metrics from multiple instances of this integration, including remote instances.
+
+
+### Default Behavior
+
+#### Auto-Detection
+
+The following type of sensors are auto-detected:
+- temperature - fan - voltage - current - power - energy - humidity
+
+
+#### Limits
+
+The default configuration for this integration does not impose any limits on data collection.
+
+#### Performance Impact
+
+The default configuration for this integration is not expected to impose a significant performance impact on the system.
+
+
+## Metrics
+
+Metrics grouped by *scope*.
+
+The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
+
+
+
+### Per chip
+
+Metrics related to chips. Each chip provides a set of the following metrics, each having the chip name in the metric name as reported by `sensors -u`.
+
+
+This scope has no labels.
+
+Metrics:
+
+| Metric | Dimensions | Unit |
+|:------|:----------|:----|
+| sensors.temperature | a dimension per sensor | Celsius |
+| sensors.voltage | a dimension per sensor | Volts |
+| sensors.current | a dimension per sensor | Ampere |
+| sensors.power | a dimension per sensor | Watt |
+| sensors.fan | a dimension per sensor | Rotations/min |
+| sensors.energy | a dimension per sensor | Joule |
+| sensors.humidity | a dimension per sensor | Percent |
+
+
+
+## Alerts
+
+There are no alerts configured by default for this integration.
+
+
+## Setup
+
+### Prerequisites
+
+No action required.
+
+### Configuration
+
+#### File
+
+The configuration file name for this integration is `python.d/sensors.conf`.
+
+
+You can edit the configuration file using the `edit-config` script from the
+Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration.md#the-netdata-config-directory).
+
+```bash
+cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
+sudo ./edit-config python.d/sensors.conf
+```
+#### Options
+
+There are 2 sections:
+
+* Global variables
+* One or more JOBS that can define multiple different instances to monitor.
+
+The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values.
+
+Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
+
+Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified.
+
+
+<details><summary>Config options</summary>
+
+| Name | Description | Default | Required |
+|:----|:-----------|:-------|:--------:|
+| types | The types of sensors to collect. | temperature, fan, voltage, current, power, energy, humidity | yes |
+| update_every | Sets the default data collection frequency. | 1 | no |
+| priority | Controls the order of charts at the netdata dashboard. | 60000 | no |
+| autodetection_retry | Sets the job re-check interval in seconds. | 0 | no |
+| penalty | Indicates whether to apply penalty to update_every in case of failures. | yes | no |
+
+</details>
+
+#### Examples
+
+##### Default
+
+Default configuration.
+
+```yaml
+types:
+ - temperature
+ - fan
+ - voltage
+ - current
+ - power
+ - energy
+ - humidity
+
+```
+
+
+## Troubleshooting
+
+### Debug Mode
+
+To troubleshoot issues with the `sensors` collector, run the `python.d.plugin` with the debug option enabled. The output
+should give you clues as to why the collector isn't working.
+
+- Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on
+ your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`.
+
+ ```bash
+ cd /usr/libexec/netdata/plugins.d/
+ ```
+
+- Switch to the `netdata` user.
+
+ ```bash
+ sudo -u netdata -s
+ ```
+
+- Run the `python.d.plugin` to debug the collector:
+
+ ```bash
+ ./python.d.plugin sensors debug trace
+ ```
+
+### lm-sensors doesn't work on your device
+
+
+
+### ACPI ring buffer errors are printed
+
+
+
+
diff --git a/src/collectors/python.d.plugin/sensors/metadata.yaml b/src/collectors/python.d.plugin/sensors/metadata.yaml
new file mode 100644
index 000000000..ceb4ba721
--- /dev/null
+++ b/src/collectors/python.d.plugin/sensors/metadata.yaml
@@ -0,0 +1,184 @@
+plugin_name: python.d.plugin
+modules:
+ - meta:
+ plugin_name: python.d.plugin
+ module_name: sensors
+ monitored_instance:
+ name: Linux Sensors (lm-sensors)
+ link: https://hwmon.wiki.kernel.org/lm_sensors
+ categories:
+ - data-collection.hardware-devices-and-sensors
+ icon_filename: "microchip.svg"
+ related_resources:
+ integrations:
+ list: []
+ info_provided_to_referring_integrations:
+ description: ""
+ keywords:
+ - sensors
+ - temperature
+ - voltage
+ - current
+ - power
+ - fan
+ - energy
+ - humidity
+ most_popular: false
+ overview:
+ data_collection:
+ metrics_description: |
+ Examine Linux Sensors metrics with Netdata for insights into hardware health and performance.
+
+ Enhance your system's reliability with real-time hardware health insights.
+ method_description: >
+ Reads system sensors information (temperature, voltage, electric current, power, etc.) via [lm-sensors](https://hwmon.wiki.kernel.org/lm_sensors).
+ supported_platforms:
+ include: []
+ exclude: []
+ multi_instance: true
+ additional_permissions:
+ description: ""
+ default_behavior:
+ auto_detection:
+ description: >
+ The following type of sensors are auto-detected:
+
+ - temperature
+ - fan
+ - voltage
+ - current
+ - power
+ - energy
+ - humidity
+ limits:
+ description: ""
+ performance_impact:
+ description: ""
+ setup:
+ prerequisites:
+ list: []
+ configuration:
+ file:
+ name: python.d/sensors.conf
+ description: ""
+ options:
+ description: |
+ There are 2 sections:
+
+ * Global variables
+ * One or more JOBS that can define multiple different instances to monitor.
+
+ The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values.
+
+ Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
+
+ Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified.
+ folding:
+ title: Config options
+ enabled: true
+ list:
+ - name: types
+ description: The types of sensors to collect.
+ default_value: "temperature, fan, voltage, current, power, energy, humidity"
+ required: true
+ - name: update_every
+ description: Sets the default data collection frequency.
+ default_value: 1
+ required: false
+ - name: priority
+ description: Controls the order of charts at the netdata dashboard.
+ default_value: 60000
+ required: false
+ - name: autodetection_retry
+ description: Sets the job re-check interval in seconds.
+ default_value: 0
+ required: false
+ - name: penalty
+ description: Indicates whether to apply penalty to update_every in case of failures.
+ default_value: yes
+ required: false
+ examples:
+ folding:
+ enabled: true
+ title: Config
+ list:
+ - name: Default
+ folding:
+ enabled: false
+ description: Default configuration.
+ config: |
+ types:
+ - temperature
+ - fan
+ - voltage
+ - current
+ - power
+ - energy
+ - humidity
+ troubleshooting:
+ problems:
+ list:
+ - name: lm-sensors doesn't work on your device
+ description: |
+ When `lm-sensors` doesn't work on your device (e.g. for RPi temperatures),
+ use [the legacy bash collector](https://github.com/netdata/netdata/blob/master/src/collectors/charts.d.plugin/sensors/README.md)
+ - name: ACPI ring buffer errors are printed
+ description: |
+ There have been reports from users that on certain servers, ACPI ring buffer errors are printed by the kernel (`dmesg`)
+ when ACPI sensors are being accessed. We are tracking such cases in issue [#827](https://github.com/netdata/netdata/issues/827).
+ Please join this discussion for help.
+ alerts: []
+ metrics:
+ folding:
+ title: Metrics
+ enabled: false
+ description: ""
+ availability: []
+ scopes:
+ - name: chip
+ description: >
+ Metrics related to chips. Each chip provides a set of the following metrics, each having the chip name in the metric name as reported by `sensors -u`.
+ labels: []
+ metrics:
+ - name: sensors.temperature
+ description: Temperature
+ unit: "Celsius"
+ chart_type: line
+ dimensions:
+ - name: a dimension per sensor
+ - name: sensors.voltage
+ description: Voltage
+ unit: "Volts"
+ chart_type: line
+ dimensions:
+ - name: a dimension per sensor
+ - name: sensors.current
+ description: Current
+ unit: "Ampere"
+ chart_type: line
+ dimensions:
+ - name: a dimension per sensor
+ - name: sensors.power
+ description: Power
+ unit: "Watt"
+ chart_type: line
+ dimensions:
+ - name: a dimension per sensor
+ - name: sensors.fan
+ description: Fans speed
+ unit: "Rotations/min"
+ chart_type: line
+ dimensions:
+ - name: a dimension per sensor
+ - name: sensors.energy
+ description: Energy
+ unit: "Joule"
+ chart_type: line
+ dimensions:
+ - name: a dimension per sensor
+ - name: sensors.humidity
+ description: Humidity
+ unit: "Percent"
+ chart_type: line
+ dimensions:
+ - name: a dimension per sensor
diff --git a/src/collectors/python.d.plugin/sensors/sensors.chart.py b/src/collectors/python.d.plugin/sensors/sensors.chart.py
new file mode 100644
index 000000000..0d9de3750
--- /dev/null
+++ b/src/collectors/python.d.plugin/sensors/sensors.chart.py
@@ -0,0 +1,179 @@
+# -*- coding: utf-8 -*-
+# Description: sensors netdata python.d plugin
+# Author: Pawel Krupa (paulfantom)
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from collections import defaultdict
+
+from bases.FrameworkServices.SimpleService import SimpleService
+from third_party import lm_sensors as sensors
+
+ORDER = [
+ 'temperature',
+ 'fan',
+ 'voltage',
+ 'current',
+ 'power',
+ 'energy',
+ 'humidity',
+]
+
+# This is a prototype of chart definition which is used to dynamically create self.definitions
+CHARTS = {
+ 'temperature': {
+ 'options': [None, 'Temperature', 'Celsius', 'temperature', 'sensors.temperature', 'line'],
+ 'lines': [
+ [None, None, 'absolute', 1, 1000]
+ ]
+ },
+ 'voltage': {
+ 'options': [None, 'Voltage', 'Volts', 'voltage', 'sensors.voltage', 'line'],
+ 'lines': [
+ [None, None, 'absolute', 1, 1000]
+ ]
+ },
+ 'current': {
+ 'options': [None, 'Current', 'Ampere', 'current', 'sensors.current', 'line'],
+ 'lines': [
+ [None, None, 'absolute', 1, 1000]
+ ]
+ },
+ 'power': {
+ 'options': [None, 'Power', 'Watt', 'power', 'sensors.power', 'line'],
+ 'lines': [
+ [None, None, 'absolute', 1, 1000]
+ ]
+ },
+ 'fan': {
+ 'options': [None, 'Fans speed', 'Rotations/min', 'fans', 'sensors.fan', 'line'],
+ 'lines': [
+ [None, None, 'absolute', 1, 1000]
+ ]
+ },
+ 'energy': {
+ 'options': [None, 'Energy', 'Joule', 'energy', 'sensors.energy', 'line'],
+ 'lines': [
+ [None, None, 'incremental', 1, 1000]
+ ]
+ },
+ 'humidity': {
+ 'options': [None, 'Humidity', 'Percent', 'humidity', 'sensors.humidity', 'line'],
+ 'lines': [
+ [None, None, 'absolute', 1, 1000]
+ ]
+ }
+}
+
+LIMITS = {
+ 'temperature': [-127, 1000],
+ 'voltage': [-400, 400],
+ 'current': [-127, 127],
+ 'fan': [0, 65535]
+}
+
+TYPE_MAP = {
+ 0: 'voltage',
+ 1: 'fan',
+ 2: 'temperature',
+ 3: 'power',
+ 4: 'energy',
+ 5: 'current',
+ 6: 'humidity',
+ # 7: 'max_main',
+ # 16: 'vid',
+ # 17: 'intrusion',
+ # 18: 'max_other',
+ # 24: 'beep_enable'
+}
+
+
+class Service(SimpleService):
+ def __init__(self, configuration=None, name=None):
+ SimpleService.__init__(self, configuration=configuration, name=name)
+ self.order = list()
+ self.definitions = dict()
+ self.chips = configuration.get('chips')
+ self.priority = 60000
+
+ def get_data(self):
+ seen, data = dict(), dict()
+ try:
+ for chip in sensors.ChipIterator():
+ chip_name = sensors.chip_snprintf_name(chip)
+ seen[chip_name] = defaultdict(list)
+
+ for feat in sensors.FeatureIterator(chip):
+ if feat.type not in TYPE_MAP:
+ continue
+
+ feat_type = TYPE_MAP[feat.type]
+ feat_name = str(feat.name.decode())
+ feat_label = sensors.get_label(chip, feat)
+ feat_limits = LIMITS.get(feat_type)
+ sub_feat = next(sensors.SubFeatureIterator(chip, feat)) # current value
+
+ if not sub_feat:
+ continue
+
+ try:
+ v = sensors.get_value(chip, sub_feat.number)
+ except sensors.SensorsError:
+ continue
+
+ if v is None:
+ continue
+
+ seen[chip_name][feat_type].append((feat_name, feat_label))
+
+ if feat_limits and (v < feat_limits[0] or v > feat_limits[1]):
+ continue
+
+ data[chip_name + '_' + feat_name] = int(v * 1000)
+
+ except sensors.SensorsError as error:
+ self.error(error)
+ return None
+
+ self.update_sensors_charts(seen)
+
+ return data or None
+
+ def update_sensors_charts(self, seen):
+ for chip_name, feat in seen.items():
+ if self.chips and not any([chip_name.startswith(ex) for ex in self.chips]):
+ continue
+
+ for feat_type, sub_feat in feat.items():
+ if feat_type not in ORDER or feat_type not in CHARTS:
+ continue
+
+ chart_id = '{}_{}'.format(chip_name, feat_type)
+ if chart_id in self.charts:
+ continue
+
+ params = [chart_id] + list(CHARTS[feat_type]['options'])
+ new_chart = self.charts.add_chart(params)
+ new_chart.params['priority'] = self.get_chart_priority(feat_type)
+
+ for name, label in sub_feat:
+ lines = list(CHARTS[feat_type]['lines'][0])
+ lines[0] = chip_name + '_' + name
+ lines[1] = label
+ new_chart.add_dimension(lines)
+
+ def check(self):
+ try:
+ sensors.init()
+ except sensors.SensorsError as error:
+ self.error(error)
+ return False
+
+ self.priority = self.charts.priority
+
+ return bool(self.get_data() and self.charts)
+
+ def get_chart_priority(self, feat_type):
+ for i, v in enumerate(ORDER):
+ if v == feat_type:
+ return self.priority + i
+ return self.priority
diff --git a/src/collectors/python.d.plugin/sensors/sensors.conf b/src/collectors/python.d.plugin/sensors/sensors.conf
new file mode 100644
index 000000000..d3369ba66
--- /dev/null
+++ b/src/collectors/python.d.plugin/sensors/sensors.conf
@@ -0,0 +1,61 @@
+# netdata python.d.plugin configuration for sensors
+#
+# This file is in YaML format. Generally the format is:
+#
+# name: value
+#
+
+# ----------------------------------------------------------------------
+# Global Variables
+# These variables set the defaults for all JOBs, however each JOB
+# may define its own, overriding the defaults.
+
+# update_every sets the default data collection frequency.
+# If unset, the python.d.plugin default is used.
+# update_every: 1
+
+# priority controls the order of charts at the netdata dashboard.
+# Lower numbers move the charts towards the top of the page.
+# If unset, the default for python.d.plugin is used.
+# priority: 60000
+
+# penalty indicates whether to apply penalty to update_every in case of failures.
+# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes.
+# penalty: yes
+
+# autodetection_retry sets the job re-check interval in seconds.
+# The job is not deleted if check fails.
+# Attempts to start the job are made once every autodetection_retry.
+# This feature is disabled by default.
+# autodetection_retry: 0
+
+# ----------------------------------------------------------------------
+# Limit the number of sensors types.
+# Comment the ones you want to disable.
+# Also, re-arranging this list controls the order of the charts at the
+# netdata dashboard.
+
+types:
+ - temperature
+ - fan
+ - voltage
+ - current
+ - power
+ - energy
+ - humidity
+
+# ----------------------------------------------------------------------
+# Limit the number of sensors chips.
+# Uncomment the first line (chips:) and add chip names below it.
+# The chip names that start with like that will be matched.
+# You can find the chip names using the sensors command.
+
+#chips:
+# - i8k
+# - coretemp
+#
+# chip names can be found using the sensors shell command
+# the prefix is matched (anything that starts like that)
+#
+#----------------------------------------------------------------------
+