📜 ⬆️ ⬇️

Temperature monitoring of the containment using 1-wire sensors and Zabbix 2

image

We have in stock a containment on 4 rows with 16 open racks in each row.
Air conditioning scheme: hot-cold corridors, internal air conditioners with external evaporators, 3 air conditioners per row, that is, 6 air conditioners per cold corridor.

Objective: to build a temperature monitoring system for the containment zone with the possibility of preventing the air conditioners from failing.
')
To solve this problem, it was decided to use a network of 1-wire temperature sensors and the Zabbix 2 monitoring system.

We collect network 1-wire.

What is a 1-wire network can be found here .

We need:

1. DS9490R 1-Wire Network Controller

image

2. DS18B20 temperature sensors , in quantity, are calculated: 4 rows * 16 racks in a row * 2 sensors per rack (cold and hot corridors), that is 128 sensors.

image

3. For convenient installation of the sensor used such an adapter RJ45 to RJ45, cat. 5e GCT11-8p8c , also in the amount of 128 pieces

image

4. And for each sensor, there are 2 patch cords, that is, 128 * 2 = 256, the patch cord length is half the width of the server rack

We assemble the sensor, select three any wires in the adapter, make 3 holes in the adapter, solder the sensor and so 128 times :)
It is recommended to fill the place of solder with glue from the thermogun, it turns out something similar to this:
image

Sensors are immediately recommended to be checked for operation by directly connecting to the 1-wire network controller and reading information from it. It is also recommended to number the sensors: consistently stick the numbers from 1 to 128. Initialization of the 1-wire network will be described below.

And so it looks if you fix on the rack.

image

Since on the controller there is an RJ11 connector, and not RJ45, I recommend making a zero adapter sensor, its sequence number will be zero, and the rack numbers will start from 1, which is more usual.

IMPORTANT!
The length of our network was about 140 meters, since the server was in the 2nd row.
During testing, it turned out that the USB port power is not enough for such a network length, the controller simply cannot interrogate the sensors, then half the network, so I recommend to buy a USB hub, always with external power, and connect the controller to it. After connecting the hub, the speed of polling the sensors increased, and errors ceased to appear on the network, all sensors were read.
I did not succeed in breaking the network into two segments, since the program that reads the data from the sensors could not understand with which controller I could not at least get it.


Initialization of 1-wire network and obtaining sensor values.

So proceed to setting up the software.

The server to which the USB controller of the 1-wire network is connected is running FreeBSD 9.1, Zabbix 2.0.8 is installed from the ports.

DigiTemp software is used to obtain sensor values .

Download the DigiTemp source and compile, the compiled programs I have are: /usr/local/etc/digitemp/new/digitemp-3.6.0/

To work with our controller, we use the program digitemp_DS2490

# cd /usr/local/etc/digitemp/new/digitemp-3.6.0/
# ./digitemp_DS2490 -i


DigiTemp needs to be run as root, so that it can read data from the device.
It is necessary to run the program only from its directory, as the network configuration file is stored there.

./digitemp_DS2490 -i - the result of the execution will be a 1-wire network configuration file with the name .digitemprc, in the program’s home directory.
At the same time, digitemp will display 64-bit sensor IDs, which will be written to a file.

Example .digitemprc
TTY USB
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
SENSORS 133
ROM 0 0x28 0x62 0xB5 0x19 0x03 0x00 0x00 0x61
ROM 1 0x28 0x29 0xD5 0x19 0x03 0x00 0x00 0xFD
ROM 2 0x28 0x59 0xDE 0x19 0x03 0x00 0x00 0x15
ROM 3 0x28 0xDA 0xD6 0x19 0x03 0x00 0x00 0x98
ROM 4 0x28 0xFD 0xBE 0x19 0x03 0x00 0x00 0x84
ROM 5 0x28 0xCB 0xE2 0x19 0x03 0x00 0x00 0x6F

IMPORTANT
The counter number ROM 0 0x28 0x62 0xB5 0x19 0x03 0x00 0x00 0x61, IS NOT its physically sequential number in the network, this number was obtained during network initialization, that is, the first one who answered was recorded in the file.
Therefore, at the stage of soldering sensors and checking them, I recommend forming a serial network right away. That is, we take the sensor, solder it, connect it directly to the controller, run ./digitemp_DS2490 -i got its ID, copied it into an Excel spreadsheet, and also added a ROM number ... to the table.
They disconnected the sensor, pasted a serial number on it, and hung it on a garland, connecting patch cards. I do not recommend to connect the garland to the controller and run the check, firstly it will be much longer, and secondly in light of the above, due to the fact that the responses from the sensors do not come consistently, it will be more difficult to look for the ID of the new sensor.

After you have tested all the sensors, connect the garland to the controller and run ./digitemp_DS2490 -i

Your network configuration file .digitemprc will be generated.

You need to replace
ROM 0 0x28 0x62 0xB5 0x19 0x03 0x00 0x00 0x61
ROM 1 0x28 0x29 0xD5 0x19 0x03 0x00 0x00 0xFD
ROM 2 0x28 0x59 0xDE 0x19 0x03 0x00 0x00 0x15
ROM 3 0x28 0xDA 0xD6 0x19 0x03 0x00 0x00 0x98
ROM 4 0x28 0xFD 0xBE 0x19 0x03 0x00 0x00 0x84

on the one that you got in Excel in the same format.

Save the resulting .digitemprc file in a different folder, because if you suddenly run ./digitemp_DS2490 -i again, your file will be overwritten, and then the physical addressing will be incorrect with a high probability.

After the 1-wire network is configured, you can read the values ​​of the sensors, run ./digitemp_DS2490 -q -a -r1 -n1 , the program will display the values ​​of the sensors.

Check the correctness of the serial connection in the network, for example, heat the 5 sensor, and run the program, the temperature should increase by 4 (since the numbering comes from 0)

Go to the configuration of Zabbix .

The server on which Zabbix is ​​installed in zabbix is ​​called ZabbixServer.
We create in it 129 data elements, that is, for each temperature sensor on the data element.

image

For us it is important to understand:
gmz.temp.t17 is the item key, they are used to send the sensor value
and the element type must be “Zabbix trapper”, since the values ​​will be sent through the zabbix_sender program.

We also create 12 additional data elements for each of the 12 air conditioners. The sensors are located so that the 3 sensors are located under the cold air outlet of the air conditioner, therefore we consider the average of these three sensors, then the data element will be calculated.

image

Pay attention to the formula, that is, the last obtained sensor values ​​are added up and divided by three.

After we have added the data elements we can send the data of the values ​​to Zabbix.

Add the task to the root crontab:
*/1 * * * * /usr/local/etc/digitemp/digitemp_cron.sh > /dev/null 2>&1


That is, run once a minute the script digitemp_cron.sh
cat /usr/local/etc/digitemp/digitemp_cron.sh

#!/usr/local/bin/bash
cd /usr/local/etc/digitemp/new/digitemp-3.6.0/
./digitemp_DS2490 -q -a -r1 -n1 -o"ZabbixServer gmz.temp.t%s %N %.2C" | /usr/local/bin/zabbix_sender -vv -z 127.0.0.1 -I 127.0.0.1 -T -i -

-o"ZabbixServer gmz.temp.t%s %N %.2C" - this line defines the output format.

IMPORTANT!
ZabbixServer is the host name with the Zabbix server installed in Zabbix.

Run ./digitemp_DS2490 -q -a -r1 -n1 -o"ZabbixServer gmz.temp.t%s %N %.2C" | /usr/local/bin/zabbix_sender -vv -z 127.0.0.1 -I 127.0.0.1 -T -i - ./digitemp_DS2490 -q -a -r1 -n1 -o"ZabbixServer gmz.temp.t%s %N %.2C" | /usr/local/bin/zabbix_sender -vv -z 127.0.0.1 -I 127.0.0.1 -T -i -

as a result of the zabbix_sender operation, it should be that all strings are sent and received:

Info from server: "Processed 133 Failed 0 Total133 Seconds spent 0.000540"
sent: 133; skipped: 0; total: 133

If so, then you can add graphs and triggers, and set up alerts.

image

image

Source: https://habr.com/ru/post/204478/


All Articles