Last active
August 29, 2015 13:59
-
-
Save wozz/10553434 to your computer and use it in GitHub Desktop.
Electrum Server Status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| import datetime | |
| from django.template import Template, Context | |
| from django.conf import settings | |
| settings.configure() | |
| template = """ | |
| <html> | |
| <head> | |
| <title>Electrum Server Info</title> | |
| </head> | |
| <body> | |
| <table border="1"> | |
| <tr> | |
| <th></th> | |
| <th>Electrum</th> | |
| <th>Bitcoind</th> | |
| </tr> | |
| <tr> | |
| <td>Version</td> | |
| <td>0.9</td> | |
| <td>0.9.1</td> | |
| </tr> | |
| <tr> | |
| <td>Block Height</td> | |
| <td>{{ elbh }}</td> | |
| <td>{{ btcbh }}</td> | |
| </tr> | |
| <tr> | |
| <td>Connections</td> | |
| <td>{{ elc }}</td> | |
| <td>{{ btcc }}</td> | |
| </tr> | |
| </table> | |
| <p>Last updated {{ time }}</p> | |
| <p>Values updated every 10 minutes</p> | |
| </body> | |
| </html> | |
| """ | |
| elbh = sys.argv[1] | |
| btcbh = sys.argv[2] | |
| elc = sys.argv[3] | |
| btcc = sys.argv[4] | |
| dt = datetime.datetime.utcfromtimestamp(float(datetime.datetime.now().strftime('%s'))).strftime('%Y %m %d %H:%M UTC') | |
| t = Template(template) | |
| c = Context({"elbh":elbh, | |
| "btcbh":btcbh, | |
| "elc":elc, | |
| "btcc":btcc, | |
| "time":dt}) | |
| print t.render(c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0,10,20,30,40,50 * * * * /home/bitcoin/stats/stats.sh > /home/bitcoin/stats/index.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| cd /home/bitcoin | |
| btc_blockh=$(/home/bitcoin/bitcoind getinfo 2> /dev/null | grep blocks | awk '{ printf("%d", $3) }') | |
| if [ ${PIPESTATUS[0]} -ne 0 ] | |
| then | |
| btc_blockh="err" | |
| fi | |
| btc_conns=$(/home/bitcoin/bitcoind getinfo 2> /dev/null | grep connections | awk '{ printf("%d", $3) }') | |
| if [ ${PIPESTATUS[0]} -ne 0 ] | |
| then | |
| btc_conns="err" | |
| fi | |
| el_blockh=$(grep blockchain /home/bitcoin/log/electrum.err | grep -v reorg | tail -n 1 | awk '{ print $3 }') | |
| el_conns=$(/home/bitcoin/electrum-server info 2> /dev/null | wc -l) | |
| if [ ${PIPESTATUS[0]} -ne 0 ] | |
| then | |
| el_conns="err" | |
| el_blockh="err" | |
| else | |
| el_conns=$(( $el_conns - 1 )) | |
| fi | |
| python /home/bitcoin/stats/buildpage.py $el_blockh $btc_blockh $el_conns $btc_conns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment