added return codes to CPU temps
This commit is contained in:
parent
0a93505b10
commit
b24de828d6
@ -3,13 +3,26 @@
|
|||||||
# Run sensors command and store the output
|
# Run sensors command and store the output
|
||||||
sensors_output=$(sensors)
|
sensors_output=$(sensors)
|
||||||
|
|
||||||
# Extract temperatures for each CPU and find the highest core temp for each CPU
|
# Extract temperatures for each CPU and find the highest for each
|
||||||
cpu1_temps=$(echo "$sensors_output" | awk '/coretemp-isa-0000/ {p=1} /coretemp-isa-0001/ {p=0} p' | awk '/Core/ {print $3}' | sort -n | tail -n 1)
|
cpu1_temps=$(echo "$sensors_output" | awk '/coretemp-isa-0000/ {p=1} /coretemp-isa-0001/ {p=0} p' | awk '/Core/ {print $3}' | sort -n | tail -n 1)
|
||||||
cpu2_temps=$(echo "$sensors_output" | awk '/coretemp-isa-0001/ {p=1} /i350bb-pci-0103/ {p=0} p' | awk '/Core/ {print $3}' | sort -n | tail -n 1)
|
cpu2_temps=$(echo "$sensors_output" | awk '/coretemp-isa-0001/ {p=1} /i350bb-pci-0103/ {p=0} p' | awk '/Core/ {print $3}' | sort -n | tail -n 1)
|
||||||
|
|
||||||
# Strip out the + and degree symbol from temperatures
|
# Strip out the + and degree symbol from temperatures
|
||||||
cpu1_temps_clean=$(echo "$cpu1_temps" | tr -d '+°')
|
cpu1_temp_value=$(echo "$cpu1_temps" | tr -d '+°' | awk -F '.' '{print $1}')
|
||||||
cpu2_temps_clean=$(echo "$cpu2_temps" | tr -d '+°')
|
cpu2_temp_value=$(echo "$cpu2_temps" | tr -d '+°' | awk -F '.' '{print $1}')
|
||||||
|
|
||||||
# Format the final output
|
# Determine the status code based on temperature thresholds
|
||||||
echo "CPU0: ${cpu1_temps_clean} | CPU1: ${cpu2_temps_clean}"
|
if [ "$cpu1_temp_value" -ge 95 ] || [ "$cpu2_temp_value" -ge 95 ]; then
|
||||||
|
status_code=4
|
||||||
|
elif [ "$cpu1_temp_value" -ge 90 ] || [ "$cpu2_temp_value" -ge 90 ]; then
|
||||||
|
status_code=3
|
||||||
|
elif [ "$cpu1_temp_value" -ge 80 ] || [ "$cpu2_temp_value" -ge 80 ]; then
|
||||||
|
status_code=2
|
||||||
|
elif [ "$cpu1_temp_value" -ge 70 ] || [ "$cpu2_temp_value" -ge 70 ]; then
|
||||||
|
status_code=1
|
||||||
|
else
|
||||||
|
status_code=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Output the status code
|
||||||
|
echo "$status_code"
|
||||||
|
Loading…
Reference in New Issue
Block a user