Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # cat logger.sh
- #/!/bin/bash
- #script to feed influxDB with rigg var from /run/ethos/stats.file
- # influxDB variable
- host=10.0.1.7
- port=8086
- user=
- password=
- # The database we created
- dbname=riggs
- # Sample period (s)
- interval=300
- time=$(date --utc +%Y%m%d_%H%M%SZ)
- hostname=$(grep "hostname:" /run/ethos/stats.file | sed 's/.*://')
- rack_loc=$(grep "rack_loc:" /run/ethos/stats.file | sed 's/.*://')
- ip=$(grep "ip" /run/ethos/stats.file | sed 's/.*://' | head -n 1)
- version=$(grep "version" /run/ethos/stats.file | sed 's/.*://' | tail -n 1)
- defunct=$(grep "defunct:" /run/ethos/stats.file | sed 's/.*://')
- overheat=$(grep "overheat" /run/ethos/stats.file | sed 's/.*://')
- rx_kbps=$(grep "rx_kbps" /run/ethos/stats.file | sed 's/.*://')
- tx_kbps=$(grep "tx_kbps" /run/ethos/stats.file | sed 's/.*://')
- uptime=$(grep "uptime" /run/ethos/stats.file | sed 's/.*://')
- miner=$(grep "globalminer" /home/ethos/local.conf | head -n 1 | awk '{print $2}')
- miner_ver=$(grep "version" /run/ethos/stats.file | sed 's/.*://' | head -n 1)
- miner_secs=$(grep "miner_secs" /run/ethos/stats.file | sed 's/.*://')
- load=$(grep "load" /run/ethos/stats.file | sed 's/.*://')
- cpu_temp=$(grep "cpu_temp" /run/ethos/stats.file | sed 's/.*://')
- gpus=$(grep "gpus" /run/ethos/stats.file | sed 's/.*://')
- totalHash=$(grep "hash:" /run/ethos/stats.file | sed 's/.*://' | tail -n 1)
- curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "total_hash,host=$hostname value="$totalHash""
- #Populate GPU temps
- i=1
- while [ $i -le $gpus ]
- do
- GPUtemp[$i]=$(grep 'temp:' /run/ethos/stats.file | sed 's/.*://' | tail -n 1 | tr -s ' ' | cut -f$i -d' ')
- curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gputemp,host=$hostname,gpu=$i value="${GPUtemp[$i]}""
- ((i++))
- done
- #Populate GPU Hash
- i=1
- while [ $i -le $gpus ]
- do
- GPUhash[$i]=$(grep 'miner_hashes:' /run/ethos/stats.file | sed 's/.*://' | head -n 1 | tr -s ' ' | cut -f$i -d' ')
- curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gpuhash,host=$hostname,gpu=$i value="${GPUhash[$i]}""
- ((i++))
- done
- #Populate GPU fan RPM
- i=1
- while [ $i -le $gpus ]
- do
- GPUfan[$i]=$(grep 'fanrpm:' /run/ethos/stats.file | sed 's/.*://' | tr -s ' ' | cut -f$i -d' ')
- curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "fanrpm,host=$hostname,gpu=$i value="${GPUfan[$i]}""
- ((i++))
- done
- #Populate GPU volts
- i=1
- while [ $i -le $gpus ]
- do
- GPUvolt[$i]=$(grep 'voltage:' /run/ethos/stats.file | sed 's/.*://' | tr -s ' ' | cut -f$i -d' ')
- curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gpuvolt,host=$hostname,gpu=$i value="${GPUvolt[$i]}""
- ((i++))
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement