Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2015 14:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2fb7bf2aa2eee0d929fd to your computer and use it in GitHub Desktop.
Save anonymous/2fb7bf2aa2eee0d929fd to your computer and use it in GitHub Desktop.
Log mining rigs temperatures and auto-adjust
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
DATE;DEVICE0;DEVICE1;TEMP0;TEMP1;FAN0;FAN1
1446127512;R9-390X-0;R9-390X-1;77;66;55;50
1446127527;R9-390X-0;R9-390X-1;67;54;45;40
1446127542;R9-390X-0;R9-390X-1;74;63;55;50
1446127557;R9-390X-0;R9-390X-1;74;63;55;50
1446127572;R9-390X-0;R9-390X-1;74;63;55;50
1446127587;R9-390X-0;R9-390X-1;72;62;55;50
1446127602;R9-390X-0;R9-390X-1;73;63;55;50
1446127617;R9-390X-0;R9-390X-1;73;63;55;50
1446127632;R9-390X-0;R9-390X-1;73;63;55;50
;;;;;;
1446386942;R9-390X-0;R9-390X-1;76;66;55;50
1446386957;R9-390X-0;R9-390X-1;76;66;55;50
1446386972;R9-390X-0;R9-390X-1;75;65;55;50
1446386987;R9-390X-0;R9-390X-1;76;65;55;50
1446387002;R9-390X-0;R9-390X-1;76;66;55;50
1446387017;R9-390X-0;R9-390X-1;75;66;55;50
1446387033;R9-390X-0;R9-390X-1;75;65;55;50
1446387048;R9-390X-0;R9-390X-1;76;66;55;50
1446387063;R9-390X-0;R9-390X-1;76;66;55;50
1446387078;R9-390X-0;R9-390X-1;75;65;55;50
1446387093;R9-390X-0;R9-390X-1;76;66;55;50
1446387108;R9-390X-0;R9-390X-1;76;66;55;50
1446387123;R9-390X-0;R9-390X-1;76;66;55;50
1446387138;R9-390X-0;R9-390X-1;76;66;55;50
1446387153;R9-390X-0;R9-390X-1;76;66;55;50
1446387168;R9-390X-0;R9-390X-1;76;67;55;50
1446387183;R9-390X-0;R9-390X-1;76;67;55;50
1446387198;R9-390X-0;R9-390X-1;77;67;55;50
1446387213;R9-390X-0;R9-390X-1;77;67;55;50
1446387228;R9-390X-0;R9-390X-1;77;67;55;50
1446387243;R9-390X-0;R9-390X-1;77;67;55;50
1446387258;R9-390X-0;R9-390X-1;77;67;55;50
1446387273;R9-390X-0;R9-390X-1;77;66;55;50
1446387288;R9-390X-0;R9-390X-1;77;67;55;50
1446387303;R9-390X-0;R9-390X-1;77;66;55;50
1446387318;R9-390X-0;R9-390X-1;77;66;55;50
1446387334;R9-390X-0;R9-390X-1;76;66;55;50
1446387349;R9-390X-0;R9-390X-1;76;66;55;50
1446387364;R9-390X-0;R9-390X-1;71;61;55;50
1446387379;R9-390X-0;R9-390X-1;75;65;55;50
1446387394;R9-390X-0;R9-390X-1;76;66;55;50
1446387409;R9-390X-0;R9-390X-1;76;66;55;50
1446387424;R9-390X-0;R9-390X-1;76;66;55;50
1446387439;R9-390X-0;R9-390X-1;76;66;55;50
1446387454;R9-390X-0;R9-390X-1;76;66;55;50
1446387469;R9-390X-0;R9-390X-1;76;66;55;50
1446387484;R9-390X-0;R9-390X-1;76;66;55;50
1446387499;R9-390X-0;R9-390X-1;77;66;55;50
1446387514;R9-390X-0;R9-390X-1;76;66;55;50
1446387529;R9-390X-0;R9-390X-1;77;66;55;50
1446387544;R9-390X-0;R9-390X-1;77;67;55;50
1446387559;R9-390X-0;R9-390X-1;77;67;55;50
1446387574;R9-390X-0;R9-390X-1;76;66;55;50
1446387589;R9-390X-0;R9-390X-1;77;66;55;50
1446387604;R9-390X-0;R9-390X-1;77;66;55;50
1446387619;R9-390X-0;R9-390X-1;77;67;55;50
1446387634;R9-390X-0;R9-390X-1;77;66;55;50
1446387650;R9-390X-0;R9-390X-1;77;66;55;50
1446387665;R9-390X-0;R9-390X-1;77;67;55;50
1446387680;R9-390X-0;R9-390X-1;76;66;55;50
1446387695;R9-390X-0;R9-390X-1;76;66;55;50
1446387710;R9-390X-0;R9-390X-1;77;66;55;50
1446387725;R9-390X-0;R9-390X-1;77;66;55;50
1446387740;R9-390X-0;R9-390X-1;77;67;55;50
1446387755;R9-390X-0;R9-390X-1;73;62;55;50
1446387770;R9-390X-0;R9-390X-1;76;66;55;50
1446387785;R9-390X-0;R9-390X-1;76;66;55;50
<html><head><title>GPU Monitor</title><style>
#rig { background: #eee; margin: 50px; padding: 50px; }
#time { font-weight: bold; }
#device, #time { background: #ddd; margin: 10px; }
#name { font-weight: bold; color: #0a0; }
#temp { font-weight: bold; color: #d00; }
#fan { font-weight: bold; color: #d90; }
</style></head><body id='rig'><div id='time'>So 1. Nov 14:22:35 UTC 2015</div>
<div id='device'>Device 0: <span id='name'>R9-390X-0</span>, Temperature <span id='temp'>73&deg;C</span> (Fan <span id='fan'>55%</span>).</div>
<div id='device'>Device 1: <span id='name'>R9-390X-1</span>, Temperature <span id='temp'>62&deg;C</span> (Fan <span id='fan'>50%</span>).</div></body></html>
#!/bin/bash
CSV="gpu.csv"
HTML="gpu.html"
DEVICE0="R9-390X-0"
DEVICE1="R9-390X-1"
TEMP0=111
TEMP1=111
FAN0=99
FAN1=99
#echo "DATE;DEVICE0;DEVICE1;TEMP0;TEMP1;FAN0;FAN1" > $CSV
echo ";;;;;;" >> $CSV
while true; do
echo ""
TEMP0=$(DISPLAY=:0.0 aticonfig --adapter=0 --odgt | sed -n '/Temperature/{s/.*- //; s/[.].*//; p}')
TEMP1=$(DISPLAY=:0.1 aticonfig --adapter=1 --odgt | sed -n '/Temperature/{s/.*- //; s/[.].*//; p}')
echo "Device temperatures are $TEMP0 °C and $TEMP1 °C ..."
if [ $TEMP0 -ge 110 ]; then
FAN0=95
FAN1=90
elif [ $TEMP0 -ge 100 ]; then
FAN0=85
FAN1=80
elif [ $TEMP0 -ge 90 ]; then
FAN0=75
FAN1=70
elif [ $TEMP0 -ge 80 ]; then
FAN0=65
FAN1=60
elif [ $TEMP0 -ge 70 ]; then
FAN0=55
FAN1=50
elif [ $TEMP0 -ge 60 ]; then
FAN0=45
FAN1=40
elif [ $TEMP0 -ge 50 ]; then
FAN0=35
FAN1=30
elif [ $TEMP0 -ge 40 ]; then
FAN0=25
FAN1=20
elif [ $TEMP0 -ge 30 ]; then
FAN0=15
FAN1=10
else
FAN0='atuo'
FAN1='auto'
fi
echo "Setting fans to $FAN0 % and $FAN1 % ..."
DISPLAY=:0.0 aticonfig --pplib-cmd "set fanspeed 0 $FAN0"
DISPLAY=:0.1 aticonfig --pplib-cmd "set fanspeed 0 $FAN1"
echo "$(date +%s);$DEVICE0;$DEVICE1;$TEMP0;$TEMP1;$FAN0;$FAN1" >> $CSV
echo "<html><head><title>GPU Monitor</title><style>" > $HTML
echo "#rig { background: #eee; margin: 50px; padding: 50px; }" >> $HTML
echo "#time { font-weight: bold; }" >> $HTML
echo "#device, #time { background: #ddd; margin: 10px; }" >> $HTML
echo "#name { font-weight: bold; color: #0a0; }" >> $HTML
echo "#temp { font-weight: bold; color: #d00; }" >> $HTML
echo "#fan { font-weight: bold; color: #d90; }" >> $HTML
echo "</style></head><body id='rig'><div id='time'>$(date --utc)</div>" >> $HTML
echo "<div id='device'>Device 0: <span id='name'>$DEVICE0</span>, Temperature <span id='temp'>$TEMP0&deg;C</span> (Fan <span id='fan'>$FAN0%</span>).</div>" >> $HTML
echo "<div id='device'>Device 1: <span id='name'>$DEVICE1</span>, Temperature <span id='temp'>$TEMP1&deg;C</span> (Fan <span id='fan'>$FAN1%</span>).</div></body></html>" >> $HTML
sleep 15
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment