- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
#!/usr/bin/env python
# litecoind_ Munin plugin for Litecoin Server Variables
#
# by Mike Koss
# Feb 14, 2012, MIT License
#
import os
import sys
import time
import re
import urllib2
import json
DEBUG = False
def main():
# getinfo variable is read from command name - probably the sym-link name.
request_var = sys.argv[0].split('_', 1)[1] or 'balance'
command = sys.argv[1] if len(sys.argv) > 1 else None
request_labels = {'balance': ('Wallet Balance', 'BTC'),
'connections': ('Peer Connections', 'Connections'),
'fees': ("Tip Offered", "BTC"),
'transactions': ("Transactions", "Transactions",
('confirmed', 'waiting')),
'block_age': ("Last Block Age", "Seconds"),
'difficulty': ("Difficulty", ""),
}
labels = request_labels[request_var]
if len(labels) < 3:
line_labels = [request_var]
else:
line_labels = labels[2]
if command == 'suggest':
for var_name in request_labels.keys():
print var_name
return
if command == 'config':
print 'graph_category litecoin'
print 'graph_title Litecoin %s' % labels[0]
print 'graph_vlabel %s' % labels[1]
for label in line_labels:
print '%s.label %s' % (label, label)
return
# Munin should send connection options via environment vars
litecoin_options = get_env_options('rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword')
litecoin_options.rpcconnect = litecoin_options.get('rpcconnect', '127.0.0.1')
litecoin_options.rpcport = litecoin_options.get('rpcport', '8332')
if litecoin_options.get('rpcuser') is None:
conf_file = os.path.join(os.path.expanduser('~/.litecoin'), 'litecoin.conf')
litecoin_options = parse_conf(conf_file)
litecoin_options.require('rpcuser', 'rpcpassword')
litecoin = ServiceProxy('http://%s:%s' % (litecoin_options.rpcconnect,
litecoin_options.rpcport),
username=litecoin_options.rpcuser,
password=litecoin_options.rpcpassword)
(info, error) = litecoin.getinfo()
if error:
if command == 'autoconf':
print 'no'
Комментарии (0) RSS
Добавить комментарий