Jun 082015
 

In the previous post, I got the Raspberry Pi outputting the values from the temperature sensors via SNMP.

In this post, I’ll be configuring Zabbix to monitor and record these values so that I can see how cold it was last night.
You’ll need to note down the OIDs that were configured on the SNMP agent in the last post so you can use them in this post.

Monitoring the Pi

Adding it in

The Raspberry Pi will need to be monitored in some way by Zabbix in order for us to record the temperatures from the SNMP agent that we’ve set up.
You’ll need to add the Raspberry Pi as a host in Zabbix, and give it an IP address under the SNMP interfaces section. I’ve added the SNMP OS Linux template to monitor the rest of the Pi stats, but that’s not required for monitoring temperatures.

Continue reading »

Share
Jun 042015
 

So I got a bit sidetracked from my tear down of the Ritmo CE-3590 NAS, and ended up building a temperature sensor with some DS18B20s and a Raspberry Pi.

Today’s post will detail how I configured the Pi to output the temperature values to the SNMP agent that I’m running on the Pi.

Plugging The Sensors In

Since I used the DS18B20s, they are polled over a single wire with a 4K7 resistor across the VCC and Data wires.
I ended up using a whole bunch of CD Audio cables like this one –
CD Audio Cable
to create the wiring for the sensors. If I had the pins to use between the cables, I could have just joined cables together, but as I didn’t, I cut and soldered multiple cables together. At the end of the wires that will plug into the Pi, I spliced in the 4K7 resistor and heatshrinked it so hopefully it won’t short anything out.
Temp Sensor Wires
It ended up very messy, but it seems to have worked.

I used the Red wire for 3.3V, the white wire as data, and the black as ground.
Red then gets plugged into the Pi header at Pin 1 which is 3.3V power
White gets plugged into Pin 7 which is GPIO 4
Black gets plugged into Pin 6, which is a ground. This could be any of the other grounds, but this is the closest one.

Configuring the Pi

I’m using Raspbian on my Pi, so any instructions are done with a Raspbian flavour. Most distros should have the same setup though.
The Pi needs to be configured to use the w1-gpio device tree overlay (dtoverlay).
This is done by adding the line dtoverlay=w1-gpio to the end of the config.txt file on the /boot partition.
Once this dtoverlay has been activated, you should be able to see your sensors under /sys/devices/w1_bus_master1/. They should appear as 28-0215**. On my Pi, the sensors appear like so –

/sys/devices/w1_bus_master1/28-0215012018ff
/sys/devices/w1_bus_master1/28-021500ce50ff
/sys/devices/w1_bus_master1/28-021500cfceff

Catting one of the w1_slave nodes under the sensor should output something like this –

57 01 55 00 7f ff 0c 10 05 : crc=05 YES
57 01 55 00 7f ff 0c 10 05 t=21437

The YES confirms the sensor is working, and the temperature is displayed after the t=
In this example, the temperature is 21.437 Degrees Celsius. The output needs to be divided by 1000 to get the temperature to the correct amount of decimal places.

Configuring the SNMP agent

With the sensors plugged in, it’s time to extend the SNMP agent to allow us to poll the temperature sensors over SNMP.
I’ve written a script that will output just the temperature to the SNMP agent, I’ve placed this script in /opt/scripts but you’re free to put it wherever you want. You’ll need to keep the location handy for when we extend the SNMP agent.
I’ve named this script gettemp.sh

#!/bin/bash
#
# Usage: gettemp.sh
# e.g. gettemp.sh 28-0215012018ff
SENSOR=$1
SLAVE="/sys/devices/w1_bus_master1/"$SENSOR"/w1_slave"
OUTPUT=$(/bin/cat $SLAVE | /usr/bin/awk -F 't=' ' { printf $2 } ')
echo $OUTPUT

With this script, you should be able to call the script from a command line, and it should output the temperature for that sensor.

# /opt/scripts/gettemp.sh 28-021500ce50ff
21437

With this script operational, we’ll need to setup the SNMP agent to run this script to provide us the output of this script over SNMP.
To do this, we need to modify /etc/snmp/snmpd.conf. At the end of the file, put in this line –
Make sure you replace the sensor id with your own sensor id. If you want to monitor more than one sensor, add more extend lines, and give them differing names, like temp2, temp3, etc.

extend .1.3.6.1.3.1.1 temp1 /bin/bash /opt/scripts/gettemp.sh 28-021500ce50ff

After you modify the snmpd.conf file, make sure you restart SNMP agent with /etc/init.d/snmpd restart or service snmpd restart.

Once the SNMP agent is back up and running, you should be able to poll the OID we specified above (.1.3.6.1.3.1.1) and get the output of the command. I’ve run the snmpwalk on the Pi itself, polling itself.

# snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.3.1.1
iso.3.6.1.3.1.1.1.0 = INTEGER: 1
iso.3.6.1.3.1.1.2.1.2.5.116.101.109.112.49 = STRING: "/bin/bash"
iso.3.6.1.3.1.1.2.1.3.5.116.101.109.112.49 = STRING: "/opt/scripts/gettemp.sh 28-021500ce50ff"
iso.3.6.1.3.1.1.2.1.4.5.116.101.109.112.49 = ""
iso.3.6.1.3.1.1.2.1.5.5.116.101.109.112.49 = INTEGER: 5
iso.3.6.1.3.1.1.2.1.6.5.116.101.109.112.49 = INTEGER: 1
iso.3.6.1.3.1.1.2.1.7.5.116.101.109.112.49 = INTEGER: 1
iso.3.6.1.3.1.1.2.1.20.5.116.101.109.112.49 = INTEGER: 4
iso.3.6.1.3.1.1.2.1.21.5.116.101.109.112.49 = INTEGER: 1
iso.3.6.1.3.1.1.3.1.1.5.116.101.109.112.49 = STRING: "21437"
iso.3.6.1.3.1.1.3.1.2.5.116.101.109.112.49 = STRING: "21437"
iso.3.6.1.3.1.1.3.1.3.5.116.101.109.112.49 = INTEGER: 1
iso.3.6.1.3.1.1.3.1.4.5.116.101.109.112.49 = INTEGER: 0
iso.3.6.1.3.1.1.4.1.2.5.116.101.109.112.49.1 = STRING: "21437"

As you can see from the example, the temperature is output in a couple of different places.
Polling the SNMP agent with one of those locations directly should yield only the temperature.

# snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.3.1.1.4
iso.3.6.1.3.1.1.4.1.2.5.116.101.109.112.49.1 = STRING: "21437"

With that, we now have SNMP set up on the Pi, ready to be polled for the temperature.

Share
Aug 032013
 

A few people have asked for the scripts that I use to generate Raspbian Server Edition.

So here they are !

The package list is just a dump from dpkg of all the packages that have been removed.
The script is a very rough script, so there’s no error checking.
The syntax is

pkgs.sh pkgs.txt

Share
Jul 192013
 

Hey Everyone.
This version of Raspbian Server Edition is just 2.4 but it’s been upgraded to Jessie rather than Wheezy.
Not much has changed apart from that, but it’ll save you an update 🙂

5431be436a23fd05e779f3a14e8fe05d5a9dc581 RSE2.5.img
4cbb92b1b7700dff3eab95581c3b043a1ccaee1f 1GB-RSE2.5.img

The images can be grabbed from here –
RSE 2.5
RSE 2.5 1GB

Share
Jun 142013
 

Not sure if this will be of use to anyone but I’ve decided to release it anyway…

I’ve split RSE2.4 into a directory and an image file.
The directory contains all the boot files that RSE needs to boot up, and the image file is meant to be dd’ed onto a USB stick or Hard drive.
As the image file is a partition, it should be dded onto a partition
e.g.

dd if=RSE2.4.HD.img of=/dev/sda1 bs=1M

The distro itself is the same as RSE 2.4 with the exception that it’s split over 2 devices.

You can download the zip file from here

SHA1SUM –
583ad4e16b0b56d686ddee84af471a67c5103b8f RSE2.4HD.zip
I updated RSE 2.4, so this is the new SHA1 sum
461d595a5eb646da97bd2d751f05d9dcfdf96204 RSE2.4.HD.img

Share