getminera / minera

Minera is a web interface to monitor and manage mining devices
http://getminera.com
Other
374 stars 156 forks source link

System Temp for the dashboard from lmsensors in one line straight into redis #167

Closed ghost closed 3 years ago

ghost commented 7 years ago

Here's what I am using for the system temp it pulls it in one line from the lm-sensors and stores it directly in the redis. I just use a cron for it.

echo  $(sensors -f   | grep "temp1" | grep therm | awk '{print $2}') | xargs -I {}
 redis-cli -p 6379 set dashboard_temp "{}" 
michelem09 commented 7 years ago

Are you talking about Minera installed on a non-raspberry system?

ghost commented 7 years ago

Yes, but you you wanted it to work all all systems you could do this.

 find /sys/devices/platform/ | grep hwmon/hwmon0/temp1_input | xargs cat | rev | sed 's/.\{2\}\([1-9]\)/.\1/' | rev | xargs -I {} redis-cli -p 6379 set dashboard_temp "{}" 
that will work on any system
michelem09 commented 7 years ago

Thanks I will review it soon.

ghost commented 7 years ago

It takes the temp from the first hwmon lmsensors which is allways the cpu. The rest is wierd shit I like to do with sed. 47000 is 47.0 C so I reverse it because the temp can go over 3 digits 00074 cut the last two numbers since are allways 0 074 then sed out the first number and add a period 0.74 then reverse it and it keeps any bugs out. 47.0C :) If you are going to do in php right find the hw sensor and store it in php and just grab it from there. find /sys/devices/platform/ | grep hwmon/hwmon0/temp1_input

michelem09 commented 7 years ago

Sorry I'm busy now

ghost commented 7 years ago

Here is the final version of the temp fix for you to use This goes in the installer bash script.

find /sys/devices/platform/ | grep hwmon/hwmon0/temp1_input | xargs -I {} ln -s "{}" /var/www/input_temp1

It creates a link to the hardware temp to /var/www/temp1_input This is added to the top of top application/controller/unit.php and passes the temp from php to javascript. https://pastebin.com/EPWVTp6W

michelem09 commented 7 years ago

It's not so standard my RPI3 cannot get anything neither a couple of Ubuntu cloud server. I should work on this.

ghost commented 7 years ago

Try apt-get install lm-sensors fan control Its standardized.

ghost commented 7 years ago
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))

gpuTemp0=$(/opt/vc/bin/vcgencmd measure_temp)
gpuTemp0=${gpuTemp0//\'/º}
gpuTemp0=${gpuTemp0//temp=/}

echo CPU Temp: $cpuTemp1"."$cpuTempM"ºC"

That will give you cpu and gpu temp on the rp3 CPU Temp: 56.2ºC GPU Temp: 56.2ºC

ghost commented 7 years ago

You can read it directly through php into a javascript var as in the previous example.

ghost commented 7 years ago

The sensors wiki is the best for the info https://wiki.archlinux.org/index.php/lm_sensors

ghost commented 7 years ago

My RP3 unfortunately met a untimely death due to coffee, My new one is coming this week.

ghost commented 7 years ago

The clouds will not work because they are using Virtio I/O virtualization.