Advertisement
Guest User

coyote-stats.sh

a guest
Nov 28th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.15 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # This script harvest some data from Coyote Pool PTS pool
  4. # Autor: Yago
  5. # License:  WTFPL http://www.wtfpl.net/txt/copying/
  6.  
  7. MINING_PORT=4444
  8. POOL_IP=162.243.45.158
  9. HTTP_TIMEOUT=5 # seconds
  10. MINING_TIMEOUT=5 # seconds
  11. TMP=/tmp/coyote-stats
  12.  
  13. mkdir -p $TMP
  14.  
  15. harvest() {
  16.     # harvest some info
  17.     SOME_INFO=`perl -pe 's/<br\/>\n/,/g' $TMP/index.html  | perl -pe 's/,</\n/g' | grep Shares | perl -pe 's/,/, /g'`
  18.  
  19.     # harvest number of addresses listed
  20.     NUMBER_ADDRESSES=`grep '<td>' $TMP/index.html | wc -l`
  21.  
  22. }
  23.  
  24. checkminingport() {
  25.     nc -z -w$MINING_TIMEOUT $POOL_IP $MINING_PORT
  26.     if [ $? -eq 0 ]; then
  27.         MINING_PORT_STATUS="$MINING_PORT:up"
  28.     else
  29.         MINING_PORT_STATUS="$MINING_PORT:DOWN :("
  30.     fi
  31. }
  32.  
  33.  
  34. # check http
  35. wget --quiet --timeout=$HTTP_TIMEOUT http://$POOL_IP -O $TMP/index.html
  36. if [ $? -eq 0 ]; then
  37.     harvest
  38.     checkminingport
  39.     echo "Coyote Pool status: HTTP:80 up, Mining: $MINING_PORT_STATUS, $SOME_INFO, Addresses with pending payouts: $NUMBER_ADDRESSES"
  40. else
  41.     checkminingport
  42.     echo "Coyote Pool status: HTTP:80 down :/, Mining: $MINING_PORT_STATUS, Shares, Balance and addresses with pending payouts: data source down."
  43. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement