commit e31b70799549634dffdb7f856ffd54fd7cd0de48 Author: Andrew Williams Date: Sat Jan 7 15:06:58 2017 +0000 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..c89aa2a --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +RPi DHT11 Munin Plugins +======================= + +Two simple Munin plugins that allow you to monitor the values returned from a DHT11 temperature and humidity module connected to a Raspberry Pi + +Requirements +------------ + +* [Adafruit_DHT](https://github.com/adafruit/Adafruit_Python_DHT) +* [python-munin](https://github.com/samuel/python-munin) + +Munin Configuration +------------------- + +These values will be set in your ```plugin-conf.d/munin-node``` file. + +* ```dht11_pin``` - The GPIO pin on the Raspberry Pi where the DHT11 data line is connected. + +Example Config +-------------- + + [dht11*] + user root + env.dht11_pin 2 diff --git a/dht11_humidity b/dht11_humidity new file mode 100755 index 0000000..019d7d2 --- /dev/null +++ b/dht11_humidity @@ -0,0 +1,34 @@ +#!/usr/bin/python +import sys +import Adafruit_DHT +import os +from munin import MuninPlugin + +class DHT11Plugin(MuninPlugin): + title = "DHT11 Humidity" + args = "--base 1000 -l 0" + vlabel = "percent" + scale = False + category = "sensors" + + @property + def fields(self): + warning = os.environ.get('hum_warn', 90) + critical = os.environ.get('hum_crit', 95) + return [("hum", dict( + label = "Humidity", + info = 'Humidity as reported by a DHT11 sensor', + type = "GAUGE", + min = "0", + max = "100", + warning = str(warning), + critical = str(critical)))] + + def execute(self): + pin = int(os.environ.get('dht11_pin', '2')) + humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, pin) + return dict(hum=humidity) + +if __name__ == "__main__": + DHT11Plugin().run() + diff --git a/dht11_temp b/dht11_temp new file mode 100755 index 0000000..a5e9284 --- /dev/null +++ b/dht11_temp @@ -0,0 +1,33 @@ +#!/usr/bin/python +import sys +import Adafruit_DHT +import os +from munin import MuninPlugin + +class DHT11Plugin(MuninPlugin): + title = "DHT11 Temperature" + args = "--base 1000 -l 0" + vlabel = "degrees celcius" + scale = False + category = "sensors" + + @property + def fields(self): + warning = os.environ.get('temp_warn', 30) + critical = os.environ.get('temp_crit', 60) + return [("temp", dict( + label = "Temperature", + info = 'Temperature as reported by a DHT11 sensor', + type = "GAUGE", + min = "-20", + warning = str(warning), + critical = str(critical)))] + + def execute(self): + pin = int(os.environ.get('dht11_pin', 2)) + humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, pin) + return dict(temp=temperature) + +if __name__ == "__main__": + DHT11Plugin().run() +