Monitoring the temperature of the server itself

When we once again learned about the failure of the air conditioner in the server based on angry messages from the built-in server monitoring, it was a volitional decision to teach Zabbix to monitor the temperature in the server room. In order to repeat this situation, take action before the server turns into a bath.

The implementation is quite simple: the thermal sensor is polled by the controller via the 1wire bus, the controller itself is connected to any available server via USB and polled with the head -n1 / dev / cuaU command, which is written in the zabbix agent config as follows:

UserParameter=usbtemp,head -n1 /dev/cuaU0

The choice of a sensor with a digital interface is due to the fact that it is a good start for the future to add another ten sensors to the bus if you need to monitor the temperature of each rack separately, for example. The controller itself is connected via USB and in order not to reinvent its drivers, it pretends to be a regular CDC serial emulator, that is, an ordinary virtual COM port, and you could of course use the HID class, since it ideologically fits better with all its structured HID-reports for polling all kinds of sensors. But I decided to get by with the CDC for clarity and ease of implementation.

So, all that is required to implement it is: a DS18B20 thermal sensor itself, a microcontroller with an onboard USB hardware module, a pair of resistors, capacitors, and a USB lanyard. As a microcontroller that implements the 1wire-USB bridge, the PIC16F1454 MK is used, in general, the reader can use any other MK for its own taste (by connecting a couple of libraries - 1wire, USB-CDC), or connect an external UART-USB bridge of the CP2102 type. I don’t really like such crutches, so I preferred the solution on a single chip - I took the cheapest controller from USB, at the time of creating the device it was PIC16F1454.

The project did not use ready-made USB stacks from Microchip or third-party ones; instead, a self-written stack developed earlier for another project was used. However, I will not go into the specifics of implementing my USB library in this article. Since working with the USB bus is beyond the scope of this article and deserves a separate, or even a series of articles. For which I may take in the near future, if, of course, the reader will be interested in this topic.
The scheme is very simple, so the board was immediately divorced in a sprint layout, nevertheless I cite a drawing of the scheme.

The controller does not support the bootloader, so it can only be stitched through the programmer using the ICSP connector. PICKIT2, for example, or its clone.

Properly assembled device starts working immediately after power is applied and does not require adjustment. The device does not require drivers since the standard CDC class is used, under Windows 10 and FreeBSD it is determined immediately, under Windows 7 you will need to specify the inf file (see the archive for the article), which clearly indicates usbser.sys driver. Under other OS device was not tested. When connecting, it should be defined as / dev / cuaUx, under FreeBSD, where x is the logical number of the device. By executing the command #head -n1 / dev / cuaU0 you can check that the sensor is correctly polled and the current temperature is displayed.

Under Windows, you can use any terminal program, such as putty, for verification.

If everything works correctly you can continue. Next, we create a new parameter (item) where as key we set our UserParameter specified in the agent config.

Well, after that it remains only to create a new graph from this parameter. And add a trigger for example at 28-30 degrees.

In the next version it is planned to add the ability to poll a variety of sensors and display the temperature from the selected sensor on the display on the device itself. Archive with materials for the article.

Also popular now: