summaryrefslogtreecommitdiffstats
path: root/conf.d
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <ahferroin7@gmail.com>2018-10-04 07:07:21 -0400
committerGitHub <noreply@github.com>2018-10-04 07:07:21 -0400
commit8516249ca6e41204c02e8dd97039fbf063096cf0 (patch)
tree432fb9d834b471585dfe221dbf7a904b404576d8 /conf.d
parent7e276ccbc7ab4dfc7c19e49bdaa4385d5cc77735 (diff)
Add a python plugin for monitoring power supplies on Linux. (#3799)
* Add a python plugin for monitoring power supplies on Linux. This adds a python-based module for tracking statistics relating to Linux kernel power_supply class devices. This allows tracking battery statistics on Linux systems, as well as (in theory) other energy storage devices that utilize the kernel's power_supply class. The primary purpose of this module is twofold: - To provide a way for battery powered IoT devices to easily alert about a low battery. - To provide a way for all battery powered devices to alert on some easy to monitor battery health conditions. It provides up to four charts, one which provides the remaining capacity as a percentage, and three others which report info about charge (in amp-hours), energy (in watt-hours), and voltage, each providing info about the current values, and possibly minimal and maximal values that can be used for computing battery life. Exact support provided by each individual device varies. Almost all provide the percentage capacity, but beyond that they may or may not support any or all of the attributes needed for the other three charts (ACPI compliant systems for example support most of the charge related ones, and two of the voltage related values, but none of the energy related ones). Data collection is done by scanning entries in /sys/class/power_supply. One job must be created for each power supply to be monitored, and there is no autodetection (though the config includes an example that should work to monitor the main battery on most laptops). * Fix the build. * Fix one bug and various style issues. * Add a check to make sure it only runs on Linux. * Fixed formatting issues reported by flake8. * Updated to only collect capacity by default. * Add an alarm to alert on low battery. * Update function names to not be sunder style. * Split chart generation to a separate function. * Remove get_sysfs_value_or_zero.
Diffstat (limited to 'conf.d')
-rw-r--r--conf.d/Makefile.am2
-rw-r--r--conf.d/health.d/linux_power_supply.conf12
-rw-r--r--conf.d/python.d.conf1
-rw-r--r--conf.d/python.d/linux_power_supply.conf81
4 files changed, 96 insertions, 0 deletions
diff --git a/conf.d/Makefile.am b/conf.d/Makefile.am
index 5021e7f97f..3ed7e1597a 100644
--- a/conf.d/Makefile.am
+++ b/conf.d/Makefile.am
@@ -71,6 +71,7 @@ dist_pythonconfig_DATA = \
python.d/icecast.conf \
python.d/ipfs.conf \
python.d/isc_dhcpd.conf \
+ python.d/linux_power_supply.conf \
python.d/litespeed.conf \
python.d/logind.conf \
python.d/mdstat.conf \
@@ -134,6 +135,7 @@ dist_healthconfig_DATA = \
health.d/ipmi.conf \
health.d/isc_dhcpd.conf \
health.d/lighttpd.conf \
+ health.d/linux_power_supply.conf \
health.d/load.conf \
health.d/mdstat.conf \
health.d/megacli.conf \
diff --git a/conf.d/health.d/linux_power_supply.conf b/conf.d/health.d/linux_power_supply.conf
new file mode 100644
index 0000000000..27a172a14b
--- /dev/null
+++ b/conf.d/health.d/linux_power_supply.conf
@@ -0,0 +1,12 @@
+# Alert on low battery capacity.
+
+template: linux_power_supply_capacity
+ on: power_supply.capacity
+ calc: $capacity
+ units: %
+ every: 10s
+ warn: $this < 10
+ crit: $this < 5
+ delay: up 0 down 5m multiplier 1.2 max 1h
+ info: the percentage remaining capacity of the power supply
+ to: sysadmin
diff --git a/conf.d/python.d.conf b/conf.d/python.d.conf
index bd90333c71..f88bcdc846 100644
--- a/conf.d/python.d.conf
+++ b/conf.d/python.d.conf
@@ -56,6 +56,7 @@ go_expvar: no
# icecast: yes
# ipfs: yes
# isc_dhcpd: yes
+# linux_power_supply: yes
# litespeed: yes
logind: no
# mdstat: yes
diff --git a/conf.d/python.d/linux_power_supply.conf b/conf.d/python.d/linux_power_supply.conf
new file mode 100644
index 0000000000..3cb610f7fe
--- /dev/null
+++ b/conf.d/python.d/linux_power_supply.conf
@@ -0,0 +1,81 @@
+# netdata python.d.plugin configuration for linux_power_supply
+#
+# This file is in YaML format. Generally the format is:
+#
+# name: value
+#
+# There are 2 sections:
+# - global variables
+# - one or more JOBS
+#
+# JOBS allow you to collect values from multiple sources.
+# Each source will have its own set of charts.
+#
+# JOB parameters have to be indented (using spaces only, example below).
+
+# ----------------------------------------------------------------------
+# 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
+
+# retries sets the number of retries to be made in case of failures.
+# If unset, the default for python.d.plugin is used.
+# Attempts to restore the service are made once every update_everye
+# and only if the module has collected values in the past.
+# retries: 60
+
+# 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
+
+# ----------------------------------------------------------------------
+# JOBS (data collection sources)
+#
+# The default JOBS share the same *name*. 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.
+#
+# Any number of jobs is supported.
+#
+# All python.d.plugin JOBS (for all its modules) support a set of
+# predefined parameters. These are:
+#
+# job_name:
+# name: myname # the JOB's name as it will appear at the
+# # dashboard (by default is the job_name)
+# # JOBs sharing a name are mutually exclusive
+# update_every: 1 # the JOB's data collection frequency
+# priority: 60000 # the JOB's order on the dashboard
+# retries: 60 # the JOB's number of restoration attempts
+# autodetection_retry: 0 # the JOB's re-check interval in seconds
+#
+# In addition to the above parameters, linux_power_supply also supports
+# the following extra parameters.
+#
+# supply: '' # the name of the power supply to monitor
+# charts: 'capacity' # a space separated list of the charts to try
+# # and generate valid charts are 'capacity',
+# # 'charge', 'current', and 'voltage'
+#
+# Note that linux_power_supply will not automatically detect power
+# supplies in the system, you have to manually specify which ones you
+# want it to monitor.
+#
+# The following config will work to monitor the first battery in most
+# ACPI compliant battery powered systems (such as most laptops).
+#
+# battery:
+# name: battery
+# supply: BAT0