📜 ⬆️ ⬇️

We fasten monitoring of smart or any temperature parameters (cpu, motherboard) to Zabbix

Actually I didn’t find the article collected in a pile how to fasten any temperature monitoring to zabbix, so I decided to write my own.

Task1.
We have installed and configured monitoring system zabbix 1.8.2. You need to tighten the temperature monitoring of hard drives (or any other smart parameter) on a linux server (debian).
Go.
1. Install the smartmontools package.
2. Team
smartctl --all /dev/sdX 

displays all the smart parameters, looking for the temperature value there.
3. I have a parameter called Temperature_Celsius.
4. Next, select the temperature value from the output of the smartctl command. This can be done in one line, but the problem is that the zabbix-agent will run this command from the user zabbix, and it requires root rights. You can of course add zabbix user to sudoers, or something else, but I just added the script launch
 #!/bin/sh #get temperature of HDD and save it into temporary file /user/sbin/smartctl --all /dev/sdX | grep Temperature > /tmp/smart 

in the crontab, with a startup interval of 15 minutes (of course, it strains to write to the syslog every 15 minutes, then I can redo it).
5. Now we add a user parameter to the zabbix agent config in which we select only the last three bytes of the file (after grep there is a line where the last two characters are the hard drive temperature, the third character is probably the end of the line)
UserParameter = smart_ct, tail -bytes 3 / tmp / smart

We restart the zabbix-agent daemon.
And do not forget that if you do not add the agent UnsafeUserParameters = 1 to the config, then the commands in the commands are invalid: \ '"` *? [] {} ~ $! &; () <> | # @.
6. We look at the agent logs for curses. We check on our zabbix server whether our parameter is working
 zabbix_get -s hostname -p 10050 -k “smart_ct” 

7. And now the case of technology is to add a new data item to the host from the web of the zabbix's muzzle, a trigger, and, actually, everything.
A side effect is that I watch the temperature in the server room this way.
Task 2.
We have installed and configured monitoring system zabbix 1.8.2. It is necessary to fasten monitoring of the temperature of the motherboard (processor, memory etc) on the linux server (debian). Initially built-in data elements with the sensor keys [temp1 | 2 | 3] write that they are not supported.
Go
1. Install the lm-sensors package.
2. Run the command
 sensors 

and most likely we see that we are sent to sensors-detect.
3. Run
 sensors-detect 

all questions except the last answer yes. If there are supported glands, then we see (in my case) something like the following
To load everything that is needed, add this to / etc / modules:
# ---- cut here ----
# Chip drivers
coretemp
f71882fg
# ---- cut here ----

Bold is kernel modules, which further suggest adding to / etc / modules. But I want to try them separately, so we answer “no” and use modeprobe.
4. We load the modules, after loading the coretemp , the sensors command did not generate anything again, so I unloaded it and loaded f71882fg . Now the sensors command shows everything that is needed and not necessary, including the speed of rotation of the coolers and the temperature of the MP. After selection for the desired temperature, we have the following output from the sensors
temp3 +45

5. Since the sensors command does not require root rights, we add a user parameter to the zabbix agent
UserParameter = temb_mb, / usr.bin / sensors | grep 'temp3' | cut -f 2 -d + | grep -Eo '^ ..'

here I had to remember a little regular expressions, in the end we got such a construction to extract the temperature from the line. I am sure that it can be made easier, but experience is not enough. We also add the line UnsafeUserParameters = 1 to the agent's config (why it is written above). We restart the zabbix-agent daemon.
6. We look at the agent logs for curses, check whether the parameter is working on the zabbix server
 zabbix_get -s hostname -p 10050 -k “temp_mb” 

7. And now the case of technology is to add a new data item to the host from the web of the zabbix's muzzle, a trigger, and, actually, everything.
The number of parameters that the sensors command outputs naturally depends on the hardware. It is possible that the data elements for temperature monitoring, built initially in zabbix, work for someone, but I was not lucky ...

')

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


All Articles