Raspberry PI - Temperature monitoring with Zabbix

A raspberry pi is a good cheap way of getting temperature monitoring in your data centre or home.  You will need a raspberry pi, temperature sensor (DS18B20) and a 4.7k Ω (ohm) resistor.

After adding the sensor you need to load the necessary kernel modules.

  • modprobe w1_gpio
  • modprobe w1_therm

First make sure the kernel has the correct parameters to read the sensor on boot.
  • cd /boot
  • vi config.txt
  • add dtoverlay=w1-gpio,gpiopin=4
  • save the file
  • reboot
After rebooting you should now have a new directory under /sys/bus/w1/devices.
The directory will contain a number of files, but the one we are looking for is w1_slave.

If you cat the file the contents look something similar to this
b1 01 4b 46 7f ff 0f 10 8d : crc=8d YES
b1 01 4b 46 7f ff 0f 10 8d t=27062

The last line contains the temperature t=27062 in degrees celcius multiplied by 1000.

Below is a simple script that will read the time from the file divide it by 1000 and output the current temperature.

/bin/cat /sys/bus/w1/devices/28-00000887acbe/w1_slave | awk '/t=/ {print $10}' | cut -d= -f2  | awk '{sum=$1/1000} END {print sum}'

So in order to have zabbix read the temperature and graph it we need to add the script as a UserParameter.
  • cd /etc/zabbix/zabbix_agentd.conf.d
  • create a file called temp.conf  and add the follwoing contents
  • UnsafeUserParameters=1
  • UserParameter=raspi.temp,/bin/cat /sys/bus/w1/devices/28-00000887acbe/w1_slave | awk '/t=/ {print $10}' | cut -d= -f2  | awk '{sum=$1/1000} END {print sum}'
  • restart the zabbix agent to ensure changes are applied
Next we need to add the raspberry pi to zabbix.  Add it as a normal host.  When finished go to configuration->hosts and click on your newly created host. click on items then Create Item. I used "raspi.temp" as my variable within the UserParameter file.  This will be the name and key i use when creating a new item.


Once the item has been created you can see if any data is being returned by going to monitoring->latest data and selecting the host. If data is returned against the raspi.temp variable you are good to create a graph.


Comments

  1. Thank you for sharing this information with all of us, have you heard of digital temperature sensors? The use of wireless temperature sensors in temperature measurement and sensing have made tremendous progress in the last few decades.

    ReplyDelete
  2. How much is a steel tip worth? - TITNIA ART
    This article is about steel tip. The basic babyliss nano titanium flat iron anatomy and structure of a 3-reel & 2-3-reel slot is a type of 3-reel, three-row slot game. titanium necklace mens The titanium vs stainless steel game citizen eco drive titanium watch is titanium wood stove

    ReplyDelete

Post a Comment

Popular posts from this blog

DSTV Now on Amazon Fire TV Stick

Update Openvas Feeds

Zabbix - adding apt update checks