Advertisement
Guest User

Untitled

a guest
Dec 8th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. # cat logger.sh
  2. #/!/bin/bash
  3. #script to feed influxDB with rigg var from /run/ethos/stats.file
  4.  
  5. # influxDB variable
  6. host=10.0.1.7
  7. port=8086
  8. user=
  9. password=
  10.  
  11. # The database we created
  12. dbname=riggs
  13. # Sample period (s)
  14. interval=300
  15.  
  16. time=$(date --utc +%Y%m%d_%H%M%SZ)
  17. hostname=$(grep "hostname:" /run/ethos/stats.file | sed 's/.*://')
  18. rack_loc=$(grep "rack_loc:" /run/ethos/stats.file | sed 's/.*://')
  19. ip=$(grep "ip" /run/ethos/stats.file | sed 's/.*://' | head -n 1)
  20. version=$(grep "version" /run/ethos/stats.file | sed 's/.*://' | tail -n 1)
  21.  
  22. defunct=$(grep "defunct:" /run/ethos/stats.file | sed 's/.*://')
  23. overheat=$(grep "overheat" /run/ethos/stats.file | sed 's/.*://')
  24. rx_kbps=$(grep "rx_kbps" /run/ethos/stats.file | sed 's/.*://')
  25. tx_kbps=$(grep "tx_kbps" /run/ethos/stats.file | sed 's/.*://')
  26. uptime=$(grep "uptime" /run/ethos/stats.file | sed 's/.*://')
  27. miner=$(grep "globalminer" /home/ethos/local.conf | head -n 1 | awk '{print $2}')
  28. miner_ver=$(grep "version" /run/ethos/stats.file | sed 's/.*://' | head -n 1)
  29. miner_secs=$(grep "miner_secs" /run/ethos/stats.file | sed 's/.*://')
  30. load=$(grep "load" /run/ethos/stats.file | sed 's/.*://')
  31. cpu_temp=$(grep "cpu_temp" /run/ethos/stats.file | sed 's/.*://')
  32. gpus=$(grep "gpus" /run/ethos/stats.file | sed 's/.*://')
  33. totalHash=$(grep "hash:" /run/ethos/stats.file | sed 's/.*://' | tail -n 1)
  34.  
  35. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "total_hash,host=$hostname value="$totalHash""
  36.  
  37. #Populate GPU temps
  38. i=1
  39. while [ $i -le $gpus ]
  40. do
  41. GPUtemp[$i]=$(grep 'temp:' /run/ethos/stats.file | sed 's/.*://' | tail -n 1 | tr -s ' ' | cut -f$i -d' ')
  42. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gputemp,host=$hostname,gpu=$i value="${GPUtemp[$i]}""
  43. ((i++))
  44. done
  45.  
  46. #Populate GPU Hash
  47. i=1
  48. while [ $i -le $gpus ]
  49. do
  50. GPUhash[$i]=$(grep 'miner_hashes:' /run/ethos/stats.file | sed 's/.*://' | head -n 1 | tr -s ' ' | cut -f$i -d' ')
  51. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gpuhash,host=$hostname,gpu=$i value="${GPUhash[$i]}""
  52. ((i++))
  53. done
  54.  
  55. #Populate GPU fan RPM
  56. i=1
  57. while [ $i -le $gpus ]
  58. do
  59. GPUfan[$i]=$(grep 'fanrpm:' /run/ethos/stats.file | sed 's/.*://' | tr -s ' ' | cut -f$i -d' ')
  60. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "fanrpm,host=$hostname,gpu=$i value="${GPUfan[$i]}""
  61. ((i++))
  62. done
  63.  
  64.  
  65.  
  66. #Populate GPU volts
  67. i=1
  68. while [ $i -le $gpus ]
  69. do
  70. GPUvolt[$i]=$(grep 'voltage:' /run/ethos/stats.file | sed 's/.*://' | tr -s ' ' | cut -f$i -d' ')
  71. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gpuvolt,host=$hostname,gpu=$i value="${GPUvolt[$i]}""
  72. ((i++))
  73. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement