Zabbix 2.2: Monitoring the CPU temperature of a Windows machine

A little about yourself and the work environment
I work as an engineer in a company of two people, we service a dozen municipal and commercial enterprises with a fleet of computers up to 100 pieces of which 99% are windows of machines. We are engaged in everything from laying a network to setting up information systems. There is a lot of work and sometimes I really want to make my life a little easier and now, at the next such moment, I came across a zabbix monitoring system.
When I first met zabbix, I was filled with emotions and fantasies about monitoring everything in the world. The first was the idea of ​​preventing physical malfunctions by monitoring key indicators of iron, such as temperature or voltage, since it seems logical and economical to me to change thermal grease or start picking up a replacement for tired equipment before the user reports its premature death or terrible brakes.
Zabbix monitoring system is really very powerful and flexible, but, unfortunately, not all aspects for tracking are available from standard boxed templates. Thus, my imagination crashed crashing against the wall of the lack of standard temperature monitoring tools in Windows.

The process of searching on the Internet has confronted me with the fact that it is impossible to pull out the temperature of iron without third-party tools. When searching for these very tools, I came across the popular SpeedFan utility , which can collect data on the temperature of devices, fan speeds, and voltages. But there is no way to get data ready for processing from it without installing another utility. Plus, they are not open source and require activation of the SNMP protocol component. Conclusion: you can try on a windows server without IMPI, but as an option for mass distribution on the network - it is not suitable. Further search brought to the programs hwmonitor and aida64 - monsters, large and paid.

Openhardwaremonitor

Already almost desperate, caught on a short message on the English forum zabbix. We recommended a small open source utility OpenHardwareMonitor - it has a graphical interface and can read the temperature of devices from sensors. And most importantly, its author, at the request of the workers, wrote a console version (latest version 10/28/2012) that displays information in a form ready for processing.

Version with GUI :

GUI Version


Console version :

Console version


The console version consists of two files, an exe executable and a dll library.

  • OpenHardwareMonitorReport.exe
  • OpenHardwareMonitorLib.dll

Where to get the data we understood, now we need to establish the supply of Zabbix metrics to the server.

Server Tuning

First, add a new data item to the server for the host:

New data item


Let's call it: CPU Temperature. (CPU temperature)

Type: Zabbix agent
Key: Temperature.CPU [0]. (The name is not important, the main thing is that it matches the agent config).
Host Interface: ip \ dns. (The node that we will monitor).
Information type: Numeric (positive integer)
Data type: Decimal

Update interval (in seconds): 3600. (The screenshot shows 10 seconds, for a temporary check).

Finished on the server, go to the client configuration.

Client setup

We will send non-standard data through the Zabbix agent in the config (zabbix_agentd.conf) of which the so-called user parameters are provided - UserParameters of the form:

UserParameter=ключ[*],команда


The command through which we get the value is processed on the client side. Zabbix server will receive a key with the value assigned to it. The article means that you have already installed the agent as a service and are friends with the server.

At the end of the agent config file, add:

UserParameter=Temperature.CPU[*], C:\OpenHardwareMonitor\CPUTemperature.bat


CPUTemperature.bat - a batch file written by me that pulls out the average processor temperature from OpenHardwareMonitor. In the program, this line is called the CPU Package.

There are 3 files in C: \ OpenHardwareMonitor:

  • OpenHardwareMonitorReport.exe
  • OpenHardwareMonitorLib.dll
  • CPUTemperature.bat


Contents of CPUTemperature.bat
Here is my old code
Disabled person on crutches.
@echo off
del /s C:\OpenHardwareMonitor\*.txt >nul 2>null
call start /B /wait C:\OpenHardwareMonitor\OpenHardwareMonitorReport.exe >> C:\OpenHardwareMonitor\OpenHardwareMonitorReport.txt
find "CPU Package    :" C:\OpenHardwareMonitor\OpenHardwareMonitorReport.txt | find "temperature" >>C:\OpenHardwareMonitor\Result.txt
for /f "tokens=7 delims= " %%i in (C:\OpenHardwareMonitor\Result.txt) do echo %%i >> C:\OpenHardwareMonitor\temp.txt
TYPE C:\OpenHardwareMonitor\temp.txt


I appeal to the habra community for help in converting this horror into normal program code without crutches from text files.
Nevertheless, the script copes with its task.

Updated: New code from respected cawaleb
@echo off
for /F "usebackq tokens=7-10" %%a in (`C:\OpenHardwareMonitor\OpenHardwareMonitorReport.exe`) do echo %%b %%c %%d| findstr .*lpc.*\/temperature\/0>nul && set temper=%%a
echo %temper%

For intel processors, the same is true with find instead of findstr and a regular expression:
@echo off
for /F "usebackq tokens=7-10" %%a in (`C:\OpenHardwareMonitor\OpenHardwareMonitorReport.exe`) do echo %%b %%c %%d| find "/intelcpu/0/temperature/0">nul && set temper=%%a 
echo %temper%



The script returns the value as a decimal number.

After this change, the file config and the location of all files and scripts, restart the zabbix agent service.

We begin to receive values ​​on the server:

Schedule


Conclusion

Solved the problem of extracting the temperature of the CPU. Using the same scheme, you can get the temperature of the GPU. But the questions of determining the speed of fans, voltage on BP, as well as the question of whether there is a way to check the condition of the north and south bridges, remain acute.

Update: Added code for CPUTemperature.bat proposed by respected Cawaleb . Do not forget to thank him for responding to help!

Also popular now: