Raspberry Pi 3 with BME680 attached (left) and Nagios web interface (above and right) |
Raspberry Pi's are a series of small cheap single-board computers.
Below is Nagios Core / NRPE plugin (written in Python 3) for monitoring of environment (e.g. in a Server room or elsewhere) using a Raspberry Pi (3) and the BME 680 sensor attached:
Code on GitHub:
https://github.com/tuathano/check_temp_pres_hum_gas/blob/master/check_temp_pres_hum_gas.py
Nagios Core:
https://www.nagios.org/downloads/nagios-core/
The BME 680 sensor which can be attached to the Raspberry Pi 3:
https://www.adafruit.com/product/3660
# check_temp_pres_hum_gas.py |
# |
# python 3 script to poll BME680 enviromental sensor and return Nagios exit codes |
# T. O'Shea / R. Trouncer 2020 |
# |
# v1: 22/01/2020: Initial version |
# v1.1: 24/01/2020: Minor edit; changed - to : in output string to avoid confusion with minus sign. |
# v2: 28/01/2020: Added median filtering of raw sensor data. User can input 2 additional arguments from command |
# line to modify the total length and time interval (s) between points for the filter. |
# v3: 29/01/2020: Combine all sensor checks into one serial god-awful check as the BME680 chip cannot cope with lots of seperate polling. |
# v3.1: 30/01/2020: Minor bug fix in WARNING condition |
# |
# Nagios exit codes: |
# 0 - Service is OK |
# 1 - Service is WARNING |
# 2 - Service is in a CRITICAL status |
# 3 - Service status is UNKNOWN |
# |
# Usage example: |
# |
# check_temp_pres_hum_gas.py <selected_meas> (<crit_min> <crit_max> <warn_min> <warn_max> x4) <filt_pts> <filt_int> |
# |
# e.g. check_temp_pres_hum_gas.py 12 28 18 25 10 100 20 80 10000 10000000 500000 9000000 900 1070 920 1060 5 1 |
# |
# The first set of crit_min/max and warn_min/max values are for temperature, then humidity, then gas and finally pressure. |
# <filt_pts> is the number of points to use when median filtering the raw data and <filt_int> is the time interval (in seconds) between the points. |
# Required libraries |
import sys |
import board |
import busio |
import adafruit_bme680 |
import time |
#!/usr/bin/env python |
No comments:
Post a Comment