Zabbix监控Linux主机CPU温度
一、客户端
1、客户Linux主机安装Im_sensors
[root@localhost ~]# yum install -y lm-sensors-y
[root@localhost ~]# sensors-detect
一直yes,然后重启zabbix-agent服务或者主机。
2、Im_sensors查看显示结果(由于这里是使用虚机,所以温度显示有问题)
[root@localhost ~]# sensors coretemp-isa-0000 Adapter: ISA adapter Physical id 0: N/A (high = +100.0°C, crit = +100.0°C) Core 0: N/A (high = +100.0°C, crit = +100.0°C)
正常情况是:
[root@Zabbix ~]# sensors i5k_amb-isa-0000 Adapter: ISA adapter Ch. 0 DIMM 0: +54.5°C (low = +100.5°C, high = +124.0°C) Ch. 1 DIMM 0: +58.5°C (low = +100.5°C, high = +124.0°C) coretemp-isa-0000 Adapter: ISA adapter Core 0: +45.0°C (high = +82.0°C, crit = +100.0°C) Core 1: +42.0°C (high = +82.0°C, crit = +100.0°C) Core 2: +44.0°C (high = +82.0°C, crit = +100.0°C) Core 3: +44.0°C (high = +82.0°C, crit = +100.0°C) coretemp-isa-0001 Adapter: ISA adapter Core 0: +47.0°C (high = +82.0°C, crit = +100.0°C) Core 1: +47.0°C (high = +82.0°C, crit = +100.0°C) Core 2: +48.0°C (high = +82.0°C, crit = +100.0°C) Core 3: +46.0°C (high = +82.0°C, crit = +100.0°C) w83627hf-isa-0a00 Adapter: ISA adapter in0: +1.15 V (min = +0.00 V, max = +4.08 V) in1: +1.15 V (min = +0.00 V, max = +4.08 V) in2: +3.38 V (min = +2.82 V, max = +3.79 V) in3: +3.02 V (min = +3.57 V, max = +4.08 V) ALARM in4: +1.50 V (min = +4.00 V, max = +2.03 V) ALARM in5: +1.82 V (min = +3.82 V, max = +3.82 V) ALARM in6: +3.38 V (min = +4.06 V, max = +4.05 V) ALARM in7: +3.34 V (min = +3.81 V, max = +4.02 V) ALARM in8: +3.31 V (min = +3.82 V, max = +3.06 V) ALARM fan1: 0 RPM (min = 1328 RPM, div = 8) ALARM fan2: 7031 RPM (min = 0 RPM, div = 8) fan3: 0 RPM (min = 883 RPM, div = 8) ALARM temp1: +34.0°C (high = -1.0°C, hyst = -68.0°C) ALARM sensor = thermistor temp2: -3.0°C (high = +80.0°C, hyst = +75.0°C) sensor = CPU diode temp3: -3.0°C (high = +80.0°C, hyst = +75.0°C) sensor = CPU diode cpu0_vid: +1.419 V beep_enable: enabled
3、提取sensors显示数字:34.0(取Physical这行ID为0的第35-39的数值,多核就改变$0的值。-c后面的数字也根据主机显示结果改动)
[root@Zabbix ~]# sensors|grep "temp1" |cut -c 16-19 34.0
4、修改客户端配置文件zabbix-agent.conf
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
#UnsafeUserParameters=0 改为:UnsafeUserParameters=1
下面一行添加:
UserParameter=get_temp_cpu[*],sensors|grep "temp1" |cut -c 16-19
保存退出,重启zabbix-agent服务