Skip to content

Instantly share code, notes, and snippets.

@xunker
Last active November 17, 2020 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xunker/93cd566380b0daed0402eb96ad666720 to your computer and use it in GitHub Desktop.
Save xunker/93cd566380b0daed0402eb96ad666720 to your computer and use it in GitHub Desktop.
Get temperatures from Synology running DSM 6.x
#!/bin/bash
# Simple script to get all the values from the temperature sensors on your
# Synology device running DSM 6.x.
# Only tested on my DS415play (2 core Atom CE5335), YMMV.
#
# Sample output:
#
# $ ./get_synology_cpu_temperature.sh
# temp2 (Core 0): current 40°C, critical at 100°C
# temp3 (Core 1): current 41°C, critical at 100°C
#
# If there is currently an over-temperature alarm, the output will be:
# `temp2 (Core 0): current 101°C, critical at 100°C !! TEMPERATURE WARNING !!`
#
device_path=/sys/class/hwmon/hwmon0/device
for sensor_name in $(ls -1 $device_path | egrep -o 'temp[[:digit:]]{1}' | sort -u); do
crit_file="${device_path}/${sensor_name}_crit"
crit_alarm_file="${device_path}/${sensor_name}_crit_alarm"
label_file="${device_path}/${sensor_name}_label"
input_file="${device_path}/${sensor_name}_input"
input_value=$(<$input_file)
input_value=$(expr $input_value / 1000)
label_value=$(<$label_file)
crit_value=$(<$crit_file)
crit_value=$(expr $crit_value / 1000)
crit_alarm_value=$(<$crit_alarm_file)
if [ $crit_alarm_value -ne "0" ]; then
critical_alarm_triggered="!! TEMPERATURE WARNING !!"
fi
echo "${sensor_name} (${label_value}): current ${input_value}°C, critical at ${crit_value}°C ${critical_alarm_triggered}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment