We have a Zabbix server deployed in our organization to monitor the health of servers and AWPs. Due to the peculiarities of the technical process, the equipment is “spread out” in several rooms and distributed throughout the enterprise. Naturally, together with the basic parameters of computers (it works / does not work) I want to control the microclimate in the server computers as well. At the same time, as usual, the possibilities are very limited, and “knocking out” significant funds for complex temperature monitoring systems (including the control boards with thermal sensors for rack-mount APC UPSs) is a separate quest.
In the main server everything is simple - one such board was installed (purchased a long time ago by the predecessor along with the main equipment), an APC-shny thermal sensor was plugged in, an agent was opened in Zabbiks, everything works via SNMP. It’s boring :) There is no monitoring of remote hardware, there are no funds either - see above. Therefore, it was decided to show ingenuity, save the budget and at the same time pump the new skill by constructing a simple and cheap “knee” solution that fits, nevertheless, into the existing Zabbix monitoring infrastructure.
The total cost of the components is $ 10 with delivery.
Assembling the device is not difficult. The network module is put on the main board with a “sandwich”, the thermal sensor is soldered to its pins. Sensor connection: red +5 V, black - ground, yellow - data; between + 5V and Data we solder a 4.7 kΩ pull-up resistor.
The pin for the data is selected based on the pins used by the network module (D10 - SS; D11 - MOSI; D12 - MISO; D13 - SCK; D2 - IRQ).Rake: in the prototype of the device faced with a conflict - the data on the temperature were issued randomly, "after two for the third." The reason was that I attached a thermal sensor to pin 2, which, as I later found on the Internet, is used by the network module to generate an interrupt when a packet arrives. Rearranged on the 4th - it worked like a clock.
After assembling the hardware, go to the software.
The device will work on the network and pretend to be a zabbiks agent, for this it needs a MAC and an IP address. We decide how convenient it is to hard-sew when programming, generate a MAC from the address of the temperature sensor
and get IP via DHCP, etc. I went along the simplest path and zahardkodil both parameters.
The exchange protocol with the zabbiks-server is described
in the documentation
. Our device will respond to two commands - agent.ping
(there is room for further creativity, you can attach any of the expansion modules available to Arduino - even a humidity sensor, even illumination - yes what you please). For all other commands, it will
respond with a standard answer, understandable zabbiks-server.
For those who start from scratch (like me) - the Arduino programming is done using the Arduino IDE
, the installation and configuration of which is elementary. The components require the UIPEthernet and OneWire libraries, which are installed and connected to the project via the Sketch menu - Connect Library - Manage Libraries ...If you have other components (for example, a network module not on enc28j60, but on a different chip), other libraries will be needed!
The code for working with the network module and with the temperature sensor is typical, from the Internet, with some assumptions and simplifications.
After uploading the code to the controller and connecting the ethernet cable, we check from the console:
Rake: The compiled version of zabbix_get for Windows laid out on zabbix.com is outdated and uses a different protocol (with the ZBXD \ x01 header in the server request). The Linux version is relevant and the protocol corresponds to the given code.
$ zabbix_get -s 192.168.4.5 -k agent.ping 1 $ zabbix_get -s 192.168.4.5 -k env.temp 23.12 $ zabbix_get -s 192.168.4.5 -k bla-blah ZBX_NOTSUPPORTED
Everything works as intended. In the admin panel of the zabbiks we create a new host with the selected IP, it has two keys, Numeric (unsigned) agent.ping and Numeric (float) env.temp, enjoy the work. Charts, triggers - as usual.
Power device - via native USB. Body - optional: suitable plastic box, shrink, blue electrical tape.
The sensor resolution is about 0.06 (more precisely, 1/16) ° C, accuracy - when immersed in melting snow, it showed 0.19 ° C (maybe it would have dropped even lower, but there was little snow and it quickly melted). I think for a device worth 10 dollars and the described goals is more than enough.