Added Bosch Sensortec I2C BME280/BMP280 sensor
Added support for additional measurements in addition to the temperature Fixed handling of default I2C address Updated documentation for the new I2C sensors (and fixed a few errors)
This commit is contained in:
114
README.md
114
README.md
@@ -25,7 +25,8 @@ This repository contains the following scripts:
|
||||
* [check_otp](#check_otp)
|
||||
plugin to monitor PrivacyIDEA (and LinOTP) OTP validation
|
||||
* [check_temperature](#check_temperature)
|
||||
plugin to monitor the CPU temperature of a RaspberryPi or that of a DS18b20 1-wire sensor on a RaspberryPi
|
||||
plugin to monitor the RaspberryPi CPU temperature or that of an 1-wire
|
||||
(DS18b20) or I2C (MCP9080) sensor attached to a RaspberryPi
|
||||
* [nagiosstatus](#nagiosstatus)
|
||||
CGI-BIN script to report the status of nagios (to monitor nagios itself)
|
||||
|
||||
@@ -239,68 +240,121 @@ define service {
|
||||
-------------------------------------------------------
|
||||
Plugin (check) to monitor monitor the Raspberry Pi CPU temperature or that of a
|
||||
temperature sensor connected to a RaspberryPi. This implementation currently
|
||||
supports the DS18B20 1-wire temperature sensor. Other methods and interfaces can
|
||||
be plugged in easily (just raise a request or provide a patch). For information
|
||||
on how to connect sensor to the RaspberryPi and to get it working please see
|
||||
[this Adafruit tutorial](
|
||||
https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing).
|
||||
supports the following sensors:
|
||||
* 1-wire:
|
||||
* Maxim Integrated [DS18B20](https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing)
|
||||
* I2C
|
||||
* Bosch Sensortec [BME280](https://learn.adafruit.com/adafruit-bme280-humidity-barometric-pressure-temperature-sensor-breakout)
|
||||
* Bosch Sensortec [BMP280](https://learn.adafruit.com/adafruit-bmp280-barometric-pressure-plus-temperature-sensor-breakout)
|
||||
* Microchip [MCP9080](https://learn.adafruit.com/adafruit-mcp9808-precision-i2c-temperature-sensor-guide)
|
||||
|
||||
No setup is required to read the CPU temperature. To enable the 1-wire interface
|
||||
support on the RaspberryPi one can use the command:
|
||||
~~~
|
||||
sudo raspi-config nonint do_onewire 0
|
||||
~~~
|
||||
or use `raspi-config` in interactive mode (9. Advanced Options --> A9. 1-Wire).
|
||||
Please note that changing this requires a reboot.
|
||||
|
||||
Installation for is straightforward, after installing the script on the server
|
||||
add the following to your Nagios `commands.cmd` configuration file:
|
||||
Other methods and interfaces can be plugged in easily (just raise a request or
|
||||
provide a patch). For information on how to connect sensor to the RaspberryPi
|
||||
and to get it working please click on the links in the list above. As per these,
|
||||
most sensors require some configuration to make them available:
|
||||
* No setup is required to read the CPU temperature.
|
||||
* To enable 1-wire interface support on the RaspberryPi use the command:
|
||||
~~~
|
||||
sudo raspi-config nonint do_onewire 0
|
||||
~~~
|
||||
or use `raspi-config` interactively (1. Interfacing Options --> P7. 1-Wire).
|
||||
Please note that changing this requires a reboot.
|
||||
* To enable I2C interface support on the RaspberryPi use the command:
|
||||
~~~
|
||||
sudo raspi-config nonint do_i2c 0
|
||||
~~~
|
||||
or use `raspi-config` interactively (1. Interfacing Options --> P5. I2C).
|
||||
Please note that changing this requires a reboot.
|
||||
The I2C interface also requires the `SMBus` or `SMBus2` library, to install
|
||||
the `SMBus` library on Raspbian Linux run:
|
||||
~~~
|
||||
sudo apt install python-smbus
|
||||
~~~
|
||||
`SMBus2` is a pure Python implementation that requires system-wide or a
|
||||
`virtualenv`-based installation, less trivial than installing the package.
|
||||
|
||||
Configuration of Nagios to use the script is straightforward, after installing
|
||||
the script on the server add the following to your Nagios `commands.cmd`
|
||||
configuration file to enable checking the CPU temperature:
|
||||
~~~
|
||||
# 'check_cpu_temperature' command definition to monitor CPU temperature in C
|
||||
# parameters: warning (ARG1) and critical (ARG2) temperature in Celcius
|
||||
define command {
|
||||
command_name check_temperature
|
||||
command_name check_cpu_temperature
|
||||
command_line [install_path]/plugins/check_temperature -w $ARG1$ -c $ARG2$ rpi_cpu
|
||||
}
|
||||
|
||||
# 'check_cpu_ftemperature' command definition to monitor CPU temperature in F
|
||||
# parameters: warning (ARG1) and critical (ARG2) temperature in Celcius
|
||||
define command {
|
||||
command_name check_temperature
|
||||
command_name check_cpu_ftemperature
|
||||
command_line [install_path]/plugins/check_temperature -F -w $ARG1$ -c $ARG2$ rpi_cpu
|
||||
}
|
||||
~~~
|
||||
|
||||
To monitor a supported temperature sensor on its default address, add:
|
||||
~~~
|
||||
# 'check_temperature' command definition to monitor a single temperature in C
|
||||
# parameters: warning (ARG1) and critical (ARG2) temperature in Celcius
|
||||
define command {
|
||||
command_name check_temperature
|
||||
command_line [install_path]/plugins/check_temperature -w $ARG1$ -c $ARG2$ w1_ds18b20
|
||||
command_name check_cpu_temperature
|
||||
command_line [install_path]/plugins/check_temperature -w $ARG1$ -c $ARG2$ <<sensor>>
|
||||
}
|
||||
|
||||
# 'check_ftemperature' command definition to monitor a single temperature in F
|
||||
# parameters: warning (ARG1) and critical (ARG2) temperature in Farenheit
|
||||
define command {
|
||||
command_name check_ftemperature
|
||||
command_line [install_path]/plugins/check_temperature -F -w $ARG1$ -c $ARG2$ w1_ds18b20
|
||||
command_name check_cpu_temperature_f
|
||||
command_line [install_path]/plugins/check_temperature -F -w $ARG1$ -c $ARG2$ <<sensor>>
|
||||
}
|
||||
~~~
|
||||
With `<<sensor>>` replaced by the sensor, e.g. w1_ds18b20 for a 1-wire DS18B20,
|
||||
i2c_mcp9808 for an I2C MCP9808 sensor or i2c_bme280 for an I2C BME280. Run the
|
||||
|
||||
In case you have multiple sensors, add multiple definitions with different
|
||||
values for `command_name`.
|
||||
|
||||
If you need to pass on additional parameters, e.g. the sensor serial for an
|
||||
1-wire DS18B20, you can do that like this:
|
||||
~~~
|
||||
# 'check_temperature_sensor' command definition to monitor a single temperature in C
|
||||
# parameters: sensor serial (ARG1), warning (ARG2) and critical (ARG3) temperature in Celcius
|
||||
define command {
|
||||
command_name check_temperature_sensor
|
||||
command_name check_ds18b20_sensor
|
||||
command_line [install_path]/plugins/check_temperature -w $ARG2$ -c $ARG3$ w1_ds18b20 -s $ARG1$
|
||||
}
|
||||
|
||||
# 'check_ftemperature_sensor' command definition to monitor a single temperature in F
|
||||
# parameters: sensor serial (ARG1), warning (ARG2) and critical (ARG3) temperature in Farenheit
|
||||
define command {
|
||||
command_name check_ftemperature_sensor
|
||||
command_name check_ds18b20_sensor_f
|
||||
command_line [install_path]/plugins/check_temperature -F -w $ARG2$ -c $ARG3$ w1_ds18b20 -s $ARG1$
|
||||
}
|
||||
|
||||
~~~
|
||||
|
||||
Likewise, to pass the I2C address for an I2C MCP9808 use something like:
|
||||
~~~
|
||||
# 'check_temperature_sensor' command definition to monitor a single temperature in C
|
||||
# parameters: sensor address (ARG1), warning (ARG2) and critical (ARG3) temperature in Celcius
|
||||
define command {
|
||||
command_name check_mcp9808_sensor
|
||||
command_line [install_path]/plugins/check_temperature -w $ARG2$ -c $ARG3$ i2c_mcp9808 -a $ARG1$
|
||||
}
|
||||
|
||||
# 'check_ftemperature_sensor' command definition to monitor a single temperature in F
|
||||
# parameters: sensor address (ARG1), warning (ARG2) and critical (ARG3) temperature in Farenheit
|
||||
define command {
|
||||
command_name check_mcp9808_sensor_f
|
||||
command_line [install_path]/plugins/check_temperature -F -w $ARG2$ -c $ARG3$ i2c_mcp9808 -a $ARG1$
|
||||
}
|
||||
|
||||
~~~
|
||||
|
||||
For the list of available sensors, please run `check_temperature -h` and run
|
||||
`check_temperature <<sensor>> -h` to get the list of accepted options for sensor
|
||||
``<<sensor>>``.
|
||||
|
||||
Make sure to replace `[install_path]/plugins` with the location of the script.
|
||||
To use the it define a service check like below:
|
||||
|
||||
@@ -313,7 +367,7 @@ define service {
|
||||
use generic-service
|
||||
}
|
||||
|
||||
# check temperature in Celcius using a DS18B20 sensor connected to a RaspberryPi
|
||||
# check temperature in Celcius using a sensor connected to a RaspberryPi
|
||||
define service {
|
||||
host hostname.mydomain.tld
|
||||
service_description Check Temperature
|
||||
@@ -325,7 +379,15 @@ define service {
|
||||
define service {
|
||||
host hostname.mydomain.tld
|
||||
service_description Check Temperature
|
||||
check_command check_temperature_sensor!0000a31ea3de!30!35
|
||||
check_command check_ds18b20_sensor!0000a31ea3de!30!35
|
||||
use generic-service
|
||||
}
|
||||
|
||||
# check temperature with MCP9808 sensor 0x19 connected to a RaspberryPi
|
||||
define service {
|
||||
host hostname.mydomain.tld
|
||||
service_description Check Temperature
|
||||
check_command check_mcp9808_sensor!0x19!30!35
|
||||
use generic-service
|
||||
}
|
||||
~~~
|
||||
|
||||
Reference in New Issue
Block a user