getminera / minera

Minera is a web interface to monitor and manage mining devices

Home Page:http://getminera.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

opened this issue · comments

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 "{}" 

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

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

Thanks I will review it soon.

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

Sorry I'm busy now

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

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

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

#!/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

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

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

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

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