Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This script harvest some data from ypool PTS pool
- # Autor: Yago
- # License: WTFPL http://www.wtfpl.net/txt/copying/
- HTTP_TIMEOUT=5 # seconds
- MINING_TIMEOUT=5 # seconds
- TMP=/tmp/ypool-stats
- mkdir -p $TMP
- harvest() {
- # login to ypool
- wget --quiet --save-cookies /tmp/ycookies.txt --post-data="login_username=sternburg&login_password=poemacatedral" "http://ypool.net/howto?ct=3" -O $TMP/howto.html
- # harvest mining ports
- awk -F "mining: <b>" '{print $2}' $TMP/howto.html | awk -F '<' '{print $1}' | perl -pe 's/, /\n/g' > $TMP/ports
- # harvest Workers
- WORKERS=`awk -F 'stats_pool_worker">' '{print $2}' /tmp/howto.html | awk -F '<' '{print $1}'`
- # harvest hashrate (coll/m)
- HASHRATE=`awk -F 'stats_pool_hashrate">' '{print $2}' /tmp/howto.html | awk -F '<' '{print $1}'`
- # harvest Blocks found last 24h
- wget --quiet --load-cookies /tmp/ycookies.txt "http://ypool.net/pts/stats_overall" -O $TMP/poolstats.html
- BLOCKSLAST24H=`perl -pe 's/<td>1 Hour/\n<td>1 Hour/g' $TMP/poolstats.html | perl -pe 's/table>/\n/g' | grep "Hour" | awk -F '>' '{print $26}' | perl -pe 's/<\/td//g'`
- }
- checkminingports() {
- # List of the working mining ports as of 28/nov/2013
- # just in case HTTP is down and $TMP got deleted
- if [ ! -f $TMP/ports ]; then
- echo "8080
- 8081
- 8082
- 8083
- 8084
- 8085
- 8086
- 8087
- 10034" > $TMP/ports
- fi
- MINING_PORT_STATUS=""
- while read PORT
- do
- nc -z -w$MINING_TIMEOUT ypool.net $PORT
- if [ $? -eq 0 ]; then
- MINING_PORT_STATUS="$MINING_PORT_STATUS $PORT:up"
- else
- MINING_PORT_STATUS="$MINING_PORT_STATUS $PORT:DOWN :("
- fi
- done <$TMP/ports
- }
- # check http
- wget --quiet --timeout=$HTTP_TIMEOUT http://ypool.net -O /dev/null
- if [ $? -eq 0 ]; then
- harvest
- checkminingports
- echo "YPOOL status: HTTP:80 up, Mining:$MINING_PORT_STATUS, Workers: $WORKERS, coll/m: $HASHRATE, Blocks found last 24h: $BLOCKSLAST24H"
- else
- checkminingports
- echo "YPOOL status: HTTP:80 down :/, Mining:$MINING_PORT_STATUS, Workers,coll/m,Blocks found last 24h: data source down."
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement