Remove w1sensor in favor of Go implementation (#18471)
remove w1sensor in favor of Go implementation
Fotis Voutsas committed
Sep 4, 2024 at 12:04 UTC
162e1780db675af3e110e15169672169a5b0ddb9
7 files changed
+1
-493
CMakeLists.txt
-2
@@ -2876,7 +2876,6 @@ install(FILES
2876
src/collectors/python.d.plugin/spigotmc/spigotmc.conf
2877
src/collectors/python.d.plugin/traefik/traefik.conf
2878
src/collectors/python.d.plugin/varnish/varnish.conf
2879
- src/collectors/python.d.plugin/w1sensor/w1sensor.conf
2879
src/collectors/python.d.plugin/zscores/zscores.conf
2880
COMPONENT plugin-pythond
2881
DESTINATION usr/lib/netdata/conf.d/python.d)
@@ -2892,7 +2891,6 @@ install(FILES
2891
src/collectors/python.d.plugin/spigotmc/spigotmc.chart.py
2892
src/collectors/python.d.plugin/traefik/traefik.chart.py
2893
src/collectors/python.d.plugin/varnish/varnish.chart.py
2895
- src/collectors/python.d.plugin/w1sensor/w1sensor.chart.py
2894
src/collectors/python.d.plugin/zscores/zscores.chart.py
2895
COMPONENT plugin-pythond
2896
DESTINATION usr/libexec/netdata/python.d)
src/collectors/python.d.plugin/python.d.conf
+1
-1
@@ -38,7 +38,6 @@ go_expvar: no
38
# spigotmc: yes
39
# traefik: yes
40
# varnish: yes
41
-# w1sensor: yes
41
# zscores: no
42
43
@@ -79,3 +78,4 @@ tomcat: no # Removed (replaced with go.d/tomcat)
78
tor: no # Removed (replaced with go.d/tor).
79
puppet: no # Removed (replaced with go.d/puppet).
80
uwsgi: no # Removed (replaced with go.d/uwsgi).
81
+w1sensor: no # Removed (replaced with go.d/w1sensor)
src/collectors/python.d.plugin/w1sensor/README.md
deleted
-1
@@ -1 +0,0 @@
1
-integrations/1-wire_sensors.md
\ No newline at end of file
src/collectors/python.d.plugin/w1sensor/integrations/1-wire_sensors.md
deleted
-201
@@ -1,201 +0,0 @@
1
-<!--startmeta
2
-custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/w1sensor/README.md"
3
-meta_yaml: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/w1sensor/metadata.yaml"
4
-sidebar_label: "1-Wire Sensors"
5
-learn_status: "Published"
6
-learn_rel_path: "Collecting Metrics/Hardware Devices and Sensors"
7
-most_popular: False
8
-message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
9
-endmeta-->
10
-
11
-# 1-Wire Sensors
12
-
13
-
14
-<img src="https://netdata.cloud/img/1-wire.png" width="150"/>
15
-
16
-
17
-Plugin: python.d.plugin
18
-Module: w1sensor
19
-
20
-<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
21
-
22
-## Overview
23
-
24
-Monitor 1-Wire Sensors metrics with Netdata for optimal environmental conditions monitoring. Enhance your environmental monitoring with real-time insights and alerts.
25
-
26
-The collector uses the wire, w1_gpio, and w1_therm kernel modules. Currently temperature sensors are supported and automatically detected.
27
-
28
-This collector is only supported on the following platforms:
29
-
30
-- Linux
31
-
32
-This collector supports collecting metrics from multiple instances of this integration, including remote instances.
33
-
34
-
35
-### Default Behavior
36
-
37
-#### Auto-Detection
38
-
39
-The collector will try to auto detect available 1-Wire devices.
40
-
41
-#### Limits
42
-
43
-The default configuration for this integration does not impose any limits on data collection.
44
-
45
-#### Performance Impact
46
-
47
-The default configuration for this integration is not expected to impose a significant performance impact on the system.
48
-
49
-
50
-## Metrics
51
-
52
-Metrics grouped by *scope*.
53
-
54
-The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
55
-
56
-
57
-
58
-### Per 1-Wire Sensors instance
59
-
60
-These metrics refer to the entire monitored application.
61
-
62
-This scope has no labels.
63
-
64
-Metrics:
65
-
66
-| Metric | Dimensions | Unit |
67
-|:------|:----------|:----|
68
-| w1sensor.temp | a dimension per sensor | Celsius |
69
-
70
-
71
-
72
-## Alerts
73
-
74
-There are no alerts configured by default for this integration.
75
-
76
-
77
-## Setup
78
-
79
-### Prerequisites
80
-
81
-#### Required Linux kernel modules
82
-
83
-Make sure `wire`, `w1_gpio`, and `w1_therm` kernel modules are loaded.
84
-
85
-
86
-### Configuration
87
-
88
-#### File
89
-
90
-The configuration file name for this integration is `python.d/w1sensor.conf`.
91
-
92
-
93
-You can edit the configuration file using the `edit-config` script from the
94
-Netdata [config directory](/docs/netdata-agent/configuration/README.md#the-netdata-config-directory).
95
-
96
-```bash
97
-cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
98
-sudo ./edit-config python.d/w1sensor.conf
99
-```
100
-#### Options
101
-
102
-There are 2 sections:
103
-
104
-* Global variables
105
-* One or more JOBS that can define multiple different instances to monitor.
106
-
107
-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.
108
-
109
-Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
110
-
111
-Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified.
112
-
113
-
114
-<details open><summary>Config options</summary>
115
-
116
-| Name | Description | Default | Required |
117
-|:----|:-----------|:-------|:--------:|
118
-| update_every | Sets the default data collection frequency. | 5 | no |
119
-| priority | Controls the order of charts at the netdata dashboard. | 60000 | no |
120
-| autodetection_retry | Sets the job re-check interval in seconds. | 0 | no |
121
-| penalty | Indicates whether to apply penalty to update_every in case of failures. | yes | no |
122
-| name | Job name. This value will overwrite the `job_name` value. JOBS with the same name are mutually exclusive. Only one of them will be allowed running at any time. This allows autodetection to try several alternatives and pick the one that works. | | no |
123
-| name_<1-Wire id> | This allows associating a human readable name with a sensor's 1-Wire identifier. | | no |
124
-
125
-</details>
126
-
127
-#### Examples
128
-
129
-##### Provide human readable names
130
-
131
-Associate two 1-Wire identifiers with human readable names.
132
-
133
-```yaml
134
-sensors:
135
- name_00000022276e: 'Machine room'
136
- name_00000022298f: 'Rack 12'
137
-
138
-```
139
-
140
-
141
-## Troubleshooting
142
-
143
-### Debug Mode
144
-
145
-
146
-To troubleshoot issues with the `w1sensor` collector, run the `python.d.plugin` with the debug option enabled. The output
147
-should give you clues as to why the collector isn't working.
148
-
149
-- Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on
150
- your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`.
151
-
152
- ```bash
153
- cd /usr/libexec/netdata/plugins.d/
154
- ```
155
-
156
-- Switch to the `netdata` user.
157
-
158
- ```bash
159
- sudo -u netdata -s
160
- ```
161
-
162
-- Run the `python.d.plugin` to debug the collector:
163
-
164
- ```bash
165
- ./python.d.plugin w1sensor debug trace
166
- ```
167
-
168
-### Getting Logs
169
-
170
-If you're encountering problems with the `w1sensor` collector, follow these steps to retrieve logs and identify potential issues:
171
-
172
-- **Run the command** specific to your system (systemd, non-systemd, or Docker container).
173
-- **Examine the output** for any warnings or error messages that might indicate issues. These messages should provide clues about the root cause of the problem.
174
-
175
-#### System with systemd
176
-
177
-Use the following command to view logs generated since the last Netdata service restart:
178
-
179
-```bash
180
-journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID netdata)" --namespace=netdata --grep w1sensor
181
-```
182
-
183
-#### System without systemd
184
-
185
-Locate the collector log file, typically at `/var/log/netdata/collector.log`, and use `grep` to filter for collector's name:
186
-
187
-```bash
188
-grep w1sensor /var/log/netdata/collector.log
189
-```
190
-
191
-**Note**: This method shows logs from all restarts. Focus on the **latest entries** for troubleshooting current issues.
192
-
193
-#### Docker Container
194
-
195
-If your Netdata runs in a Docker container named "netdata" (replace if different), use this command:
196
-
197
-```bash
198
-docker logs netdata 2>&1 | grep w1sensor
199
-```
200
-
201
-
src/collectors/python.d.plugin/w1sensor/metadata.yaml
deleted
-119
@@ -1,119 +0,0 @@
1
-plugin_name: python.d.plugin
2
-modules:
3
- - meta:
4
- plugin_name: python.d.plugin
5
- module_name: w1sensor
6
- monitored_instance:
7
- name: 1-Wire Sensors
8
- link: "https://www.analog.com/en/product-category/1wire-temperature-sensors.html"
9
- categories:
10
- - data-collection.hardware-devices-and-sensors
11
- icon_filename: "1-wire.png"
12
- related_resources:
13
- integrations:
14
- list: []
15
- info_provided_to_referring_integrations:
16
- description: ""
17
- keywords:
18
- - temperature
19
- - sensor
20
- - 1-wire
21
- most_popular: false
22
- overview:
23
- data_collection:
24
- metrics_description: "Monitor 1-Wire Sensors metrics with Netdata for optimal environmental conditions monitoring. Enhance your environmental monitoring with real-time insights and alerts."
25
- method_description: "The collector uses the wire, w1_gpio, and w1_therm kernel modules. Currently temperature sensors are supported and automatically detected."
26
- supported_platforms:
27
- include:
28
- - Linux
29
- exclude: []
30
- multi_instance: true
31
- additional_permissions:
32
- description: ""
33
- default_behavior:
34
- auto_detection:
35
- description: "The collector will try to auto detect available 1-Wire devices."
36
- limits:
37
- description: ""
38
- performance_impact:
39
- description: ""
40
- setup:
41
- prerequisites:
42
- list:
43
- - title: "Required Linux kernel modules"
44
- description: "Make sure `wire`, `w1_gpio`, and `w1_therm` kernel modules are loaded."
45
- configuration:
46
- file:
47
- name: python.d/w1sensor.conf
48
- options:
49
- description: |
50
- There are 2 sections:
51
-
52
- * Global variables
53
- * One or more JOBS that can define multiple different instances to monitor.
54
-
55
- 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.
56
-
57
- Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
58
-
59
- Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified.
60
- folding:
61
- title: "Config options"
62
- enabled: true
63
- list:
64
- - name: update_every
65
- description: Sets the default data collection frequency.
66
- default_value: 5
67
- required: false
68
- - name: priority
69
- description: Controls the order of charts at the netdata dashboard.
70
- default_value: 60000
71
- required: false
72
- - name: autodetection_retry
73
- description: Sets the job re-check interval in seconds.
74
- default_value: 0
75
- required: false
76
- - name: penalty
77
- description: Indicates whether to apply penalty to update_every in case of failures.
78
- default_value: yes
79
- required: false
80
- - name: name
81
- description: Job name. This value will overwrite the `job_name` value. JOBS with the same name are mutually exclusive. Only one of them will be allowed running at any time. This allows autodetection to try several alternatives and pick the one that works.
82
- default_value: ""
83
- required: false
84
- - name: name_<1-Wire id>
85
- description: This allows associating a human readable name with a sensor's 1-Wire identifier.
86
- default_value: ""
87
- required: false
88
- examples:
89
- folding:
90
- enabled: false
91
- title: "Config"
92
- list:
93
- - name: Provide human readable names
94
- description: Associate two 1-Wire identifiers with human readable names.
95
- config: |
96
- sensors:
97
- name_00000022276e: 'Machine room'
98
- name_00000022298f: 'Rack 12'
99
- troubleshooting:
100
- problems:
101
- list: []
102
- alerts: []
103
- metrics:
104
- folding:
105
- title: Metrics
106
- enabled: false
107
- description: ""
108
- availability: []
109
- scopes:
110
- - name: global
111
- description: "These metrics refer to the entire monitored application."
112
- labels: []
113
- metrics:
114
- - name: w1sensor.temp
115
- description: 1-Wire Temperature Sensor
116
- unit: "Celsius"
117
- chart_type: line
118
- dimensions:
119
- - name: a dimension per sensor
src/collectors/python.d.plugin/w1sensor/w1sensor.chart.py
deleted
-97
@@ -1,97 +0,0 @@
1
-# -*- coding: utf-8 -*-
2
-# Description: 1-wire temperature monitor netdata python.d module
3
-# Author: Diomidis Spinellis <http://www.spinellis.gr>
4
-# SPDX-License-Identifier: GPL-3.0-or-later
5
-
6
-import os
7
-import re
8
-
9
-from bases.FrameworkServices.SimpleService import SimpleService
10
-
11
-# default module values (can be overridden per job in `config`)
12
-update_every = 5
13
-
14
-# Location where 1-Wire devices can be found
15
-W1_DIR = '/sys/bus/w1/devices/'
16
-
17
-# Lines matching the following regular expression contain a temperature value
18
-RE_TEMP = re.compile(r' t=(-?\d+)')
19
-
20
-ORDER = [
21
- 'temp',
22
-]
23
-
24
-CHARTS = {
25
- 'temp': {
26
- 'options': [None, '1-Wire Temperature Sensor', 'Celsius', 'Temperature', 'w1sensor.temp', 'line'],
27
- 'lines': []
28
- }
29
-}
30
-
31
-# Known and supported family members
32
-# Based on linux/drivers/w1/w1_family.h and w1/slaves/w1_therm.c
33
-THERM_FAMILY = {
34
- '10': 'W1_THERM_DS18S20',
35
- '22': 'W1_THERM_DS1822',
36
- '28': 'W1_THERM_DS18B20',
37
- '3b': 'W1_THERM_DS1825',
38
- '42': 'W1_THERM_DS28EA00',
39
-}
40
-
41
-
42
-class Service(SimpleService):
43
- """Provide netdata service for 1-Wire sensors"""
44
-
45
- def __init__(self, configuration=None, name=None):
46
- SimpleService.__init__(self, configuration=configuration, name=name)
47
- self.order = ORDER
48
- self.definitions = CHARTS
49
- self.probes = []
50
-
51
- def check(self):
52
- """Auto-detect available 1-Wire sensors, setting line definitions
53
- and probes to be monitored."""
54
- try:
55
- file_names = os.listdir(W1_DIR)
56
- except OSError as err:
57
- self.error(err)
58
- return False
59
-
60
- lines = []
61
- for file_name in file_names:
62
- if file_name[2] != '-':
63
- continue
64
- if not file_name[0:2] in THERM_FAMILY:
65
- continue
66
-
67
- self.probes.append(file_name)
68
- identifier = file_name[3:]
69
- name = identifier
70
- config_name = self.configuration.get('name_' + identifier)
71
- if config_name:
72
- name = config_name
73
- lines.append(['w1sensor_temp_' + identifier, name, 'absolute',
74
- 1, 10])
75
- self.definitions['temp']['lines'] = lines
76
- return len(self.probes) > 0
77
-
78
- def get_data(self):
79
- """Return data read from sensors."""
80
- data = dict()
81
-
82
- for file_name in self.probes:
83
- file_path = W1_DIR + file_name + '/w1_slave'
84
- identifier = file_name[3:]
85
- try:
86
- with open(file_path, 'r') as device_file:
87
- for line in device_file:
88
- matched = RE_TEMP.search(line)
89
- if matched:
90
- # Round to one decimal digit to filter-out noise
91
- value = round(int(matched.group(1)) / 1000., 1)
92
- value = int(value * 10)
93
- data['w1sensor_temp_' + identifier] = value
94
- except (OSError, IOError) as err:
95
- self.error(err)
96
- continue
97
- return data or None
src/collectors/python.d.plugin/w1sensor/w1sensor.conf
deleted
-72
@@ -1,72 +0,0 @@
1
-# netdata python.d.plugin configuration for w1sensor
2
-#
3
-# This file is in YaML format. Generally the format is:
4
-#
5
-# name: value
6
-#
7
-# There are 2 sections:
8
-# - global variables
9
-# - one or more JOBS
10
-#
11
-# JOBS allow you to collect values from multiple sources.
12
-# Each source will have its own set of charts.
13
-#
14
-# JOB parameters have to be indented (using spaces only, example below).
15
-
16
-# ----------------------------------------------------------------------
17
-# Global Variables
18
-# These variables set the defaults for all JOBs, however each JOB
19
-# may define its own, overriding the defaults.
20
-
21
-# update_every sets the default data collection frequency.
22
-# If unset, the python.d.plugin default is used.
23
-# update_every: 5
24
-
25
-# priority controls the order of charts at the netdata dashboard.
26
-# Lower numbers move the charts towards the top of the page.
27
-# If unset, the default for python.d.plugin is used.
28
-# priority: 60000
29
-
30
-# penalty indicates whether to apply penalty to update_every in case of failures.
31
-# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes.
32
-# penalty: yes
33
-
34
-# autodetection_retry sets the job re-check interval in seconds.
35
-# The job is not deleted if check fails.
36
-# Attempts to start the job are made once every autodetection_retry.
37
-# This feature is disabled by default.
38
-# autodetection_retry: 0
39
-
40
-# ----------------------------------------------------------------------
41
-# JOBS (data collection sources)
42
-#
43
-# The default JOBS share the same *name*. JOBS with the same name
44
-# are mutually exclusive. Only one of them will be allowed running at
45
-# any time. This allows autodetection to try several alternatives and
46
-# pick the one that works.
47
-#
48
-# Any number of jobs is supported.
49
-#
50
-# All python.d.plugin JOBS (for all its modules) support a set of
51
-# predefined parameters. These are:
52
-#
53
-# job_name:
54
-# name: myname # the JOB's name as it will appear at the
55
-# # dashboard (by default is the job_name)
56
-# # JOBs sharing a name are mutually exclusive
57
-# update_every: 5 # the JOB's data collection frequency
58
-# priority: 60000 # the JOB's order on the dashboard
59
-# penalty: yes # the JOB's penalty
60
-# autodetection_retry: 0 # the JOB's re-check interval in seconds
61
-#
62
-# Additionally to the above, w1sensor also supports the following:
63
-#
64
-# name_<1-Wire id>: '<human readable name>'
65
-# This allows associating a human readable name with a sensor's 1-Wire
66
-# identifier. Example:
67
-# name_00000022276e: 'Machine room'
68
-# name_00000022298f: 'Rack 12'
69
-#
70
-# ----------------------------------------------------------------------
71
-# AUTO-DETECTION JOBS
72
-# only one of them will run (they have the same name)