Advertisement
Guest User

Untitled

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