Advertisement
Guest User

Untitled

a guest
Dec 9th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 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.  
  20. #ip=$(grep "ip" /run/ethos/stats.file | sed 's/.*://' | head -n 1)
  21. #echo $ip
  22. #curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "ip,host=$hostname value=""$ip"""
  23.  
  24. #version=$(grep "version" /run/ethos/stats.file | sed 's/.*://' | tail -n 1)
  25. #curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "version,host=$hostname value="$version""
  26.  
  27.  
  28. defunct=$(grep "defunct:" /run/ethos/stats.file | sed 's/.*://')
  29. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "defunct,host=$hostname value="$defunct""
  30.  
  31. overheat=$(grep "overheat" /run/ethos/stats.file | sed 's/.*://')
  32. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "overheat,host=$hostname value="$overheat""
  33.  
  34.  
  35. rx_kbps=$(grep "rx_kbps" /run/ethos/stats.file | sed 's/.*://')
  36. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "rx_kbps,host=$hostname value="$rx_kbps""
  37.  
  38. tx_kbps=$(grep "tx_kbps" /run/ethos/stats.file | sed 's/.*://')
  39. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "tx_kbps,host=$hostname value="$tx_kbps""
  40.  
  41. uptime=$(grep "uptime" /run/ethos/stats.file | sed 's/.*://')
  42.  
  43.  
  44. #miner=$(show stats | grep "miner:" | head -n 1 | awk '{print $2}')
  45. #curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "miner,host=$hostname value="$miner""
  46.  
  47. #miner_ver=$(grep "version" /run/ethos/stats.file | sed 's/.*://' | head -n 1)
  48.  
  49.  
  50. miner_secs=$(grep "miner_secs" /run/ethos/stats.file | sed 's/.*://')
  51.  
  52.  
  53. load=$(grep "load" /run/ethos/stats.file | sed 's/.*://')
  54. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "load,host=$hostname value="$load""
  55.  
  56. cpu_temp=$(grep "cpu_temp" /run/ethos/stats.file | sed 's/.*://')
  57. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "cpu_temp,host=$hostname value="$cpu_temp""
  58.  
  59. gpus=$(grep "gpus" /run/ethos/stats.file | sed 's/.*://')
  60. #curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gpus,host=$hostname value="$gpus""
  61.  
  62. totalHash=$(grep "hash:" /run/ethos/stats.file | sed 's/.*://' | tail -n 1)
  63. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "total_hash,host=$hostname value="$totalHash""
  64.  
  65. #Populate GPU temps
  66. i=1
  67. while [ $i -le $gpus ]
  68. do
  69. GPUtemp[$i]=$(grep 'temp:' /run/ethos/stats.file | sed 's/.*://' | tail -n 1 | tr -s ' ' | cut -f$i -d' ')
  70. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gputemp,host=$hostname,gpu=$i value="${GPUtemp[$i]}""
  71. ((i++))
  72. done
  73.  
  74. #Populate GPU Hash
  75. i=1
  76. while [ $i -le $gpus ]
  77. do
  78. GPUhash[$i]=$(grep 'miner_hashes:' /run/ethos/stats.file | sed 's/.*://' | head -n 1 | tr -s ' ' | cut -f$i -d' ')
  79. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gpuhash,host=$hostname,gpu=$i value="${GPUhash[$i]}""
  80. ((i++))
  81. done
  82.  
  83. #Populate GPU fan RPM
  84. i=1
  85. while [ $i -le $gpus ]
  86. do
  87. GPUfan[$i]=$(grep 'fanrpm:' /run/ethos/stats.file | sed 's/.*://' | tr -s ' ' | cut -f$i -d' ')
  88. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "fanrpm,host=$hostname,gpu=$i value="${GPUfan[$i]}""
  89. ((i++))
  90. done
  91.  
  92.  
  93.  
  94. #Populate GPU volts
  95. i=1
  96. while [ $i -le $gpus ]
  97. do
  98. GPUvolt[$i]=$(grep 'voltage:' /run/ethos/stats.file | sed 's/.*://' | tr -s ' ' | cut -f$i -d' ')
  99. curl -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "gpuvolt,host=$hostname,gpu=$i value="${GPUvolt[$i]}""
  100. ((i++))
  101. done
  102.  
  103.  
  104. url -i -XPOST "http://$user:$password@$host:$port/write?db=$dbname" --data-binary "total_hash,host=$hostname value="$totalHash""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement