This repository contains templates and scripts to easily log DHT11/DHT22 sensor values with Zabbix. It was developed and tested on standard Raspbian and is currently running on several Raspberry Pis (the models being 1, 3 and Zero).
* A shell script, regularly invoked by cron, reads the sensor metrics. You can configure the number of retries and a delay in between if it doesn't work. There is also a very simple plausibility check of the result. After a successful read the values and the current timestamp are saved in a file.
* A second shell script is executed by the Zabbix agent; it simply parses the previously created file. If the file contains data in the correct format and the timestamp is not too old (configurable) it prints the requested value, otherwise an error
* Zabbix logs the values
### Why?
Originally I configured Zabbix to read the sensor directly, through commands in the userparameter_dht.conf. Though this worked most of the time it had some drawbacks.<br>
First, the timeout for agent checks needed to be raised to 5-6 seconds to work reliably. Supposedly this is not a problem but still... did not feel right. Second and more importantly, sometimes the results were stuck in the qeueue for a long time. When it happened, most of the time it resolved itself after some hours, sometimes a restart of the proxy was necessary. <br>
I never figured out why and what caused it; but with the setup provided in this repo it does not happen. You can also use the same data for something else without additional queries to the sensor.