You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.9 KiB
57 lines
1.9 KiB
#!/bin/bash
|
|
|
|
KEY=$1
|
|
|
|
case $KEY in
|
|
cpu0)
|
|
# Here are some examples on how to retrieve temperatures
|
|
# of your system:
|
|
#
|
|
# If your motherboard support IPMI and you have the ipmitool package
|
|
# You can use this:
|
|
# Of course, you'll have to adapt command as each controler may report different sensors name
|
|
|
|
# /usr/bin/ipmitool sdr | grep 'P1 Therm Margin' | cut -d'|' -f 2 | awk '{print $1'}
|
|
|
|
# Else, if your motherboard support lm_sensor, you can use something
|
|
# like this:
|
|
# /usr/bin/sensors | grep temp1 | cut -d':' -f 2 | awk '{print $1'} | sed -e "s/+//g" -e "s/.C//g"
|
|
|
|
# You can also try to get your CPU temperature with acpi:
|
|
# cat /proc/acpi/thermal_zone/THRM/temperature | awk '{print $2}'
|
|
|
|
# It's important that your commands return only numerical values
|
|
|
|
# The default for now is to use IPMI
|
|
/usr/bin/ipmitool sdr type Temperature | grep 'P1 Therm Margin' | cut -d'|' -f 2 | awk '{print $1'}
|
|
|
|
;;
|
|
cpu1)
|
|
# This will be the same as the above, but for the second CPU
|
|
|
|
/usr/bin/ipmitool sdr type Temperature | grep 'P2 Therm Margin' | cut -d'|' -f 2 | awk '{print $1'}
|
|
|
|
;;
|
|
mb)
|
|
# AFAIK, motherboard temperature can be retrieved only with lm_sensor or IPMI
|
|
|
|
/usr/bin/ipmitool sdr type Temperature | grep 'Baseboard' | cut -d'|' -f 2 | awk '{print $1'}
|
|
|
|
;;
|
|
ambiant)
|
|
# Some IPMI controler also report the ambiant temperature
|
|
/usr/bin/ipmitool sdr type Temperature | grep Ambient | cut -d'|' -f 2 | awk '{print $1'}
|
|
|
|
;;
|
|
hd*|sd*)
|
|
# Here, we want a harddrive temperature, so we'll use smartctl
|
|
# We could also use hddtemp but it doesn't seems to work for a lot of drive, where smartctl do
|
|
/usr/sbin/smartctl -a /dev/$KEY | grep Temperature_Celsius | awk '{print $10}'
|
|
|
|
;;
|
|
*)
|
|
# Else, we tell the server the item is not supported
|
|
echo 'ZBX_NOTSUPPORTED'
|
|
;;
|
|
esac
|
|
|
|
|