mirror of
https://github.com/nikdoof/dht11_munin.git
synced 2025-12-17 19:59:23 +00:00
Initial commit
This commit is contained in:
24
README.md
Normal file
24
README.md
Normal file
@@ -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
|
||||||
34
dht11_humidity
Executable file
34
dht11_humidity
Executable file
@@ -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()
|
||||||
|
|
||||||
33
dht11_temp
Executable file
33
dht11_temp
Executable file
@@ -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()
|
||||||
|
|
||||||
Reference in New Issue
Block a user