Last active
May 3, 2024 19:14
-
-
Save dataslayermedia/fb20aae9dea64bca286b5e6d189027b8 to your computer and use it in GitHub Desktop.
real-time-temperature-output-coral-ai-pcie-accelerators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to convert millidegree Celsius to Fahrenheit | |
convert_to_fahrenheit() { | |
local temp_milli_c=$1 | |
# Convert millidegree Celsius to Celsius | |
local temp_c=$(echo "scale=4; $temp_milli_c / 1000" | bc) | |
# Convert Celsius to Fahrenheit | |
echo "scale=2; ($temp_c * 9 / 5) + 32" | bc | |
} | |
# Main loop to continuously monitor the temperature | |
while true; do | |
clear | |
echo "Monitoring Coral PCIe Accelerators Temperature in Fahrenheit" | |
# Dynamically find all apex devices and read their temperatures | |
for device_path in /sys/class/apex/apex_*; do | |
if [ -f "$device_path/temp" ]; then | |
device_name=$(basename "$device_path") | |
temp_milli_c=$(cat "$device_path/temp") | |
temp_f=$(convert_to_fahrenheit $temp_milli_c) | |
echo "$device_name: $temp_f°F" | |
else | |
echo "$device_name: Temperature readout not available" | |
fi | |
done | |
# Wait for a second before the next update | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The script prints out the temperature of all PCIe accelerators in fahrenheit