Révision fd45fe6c
Plugin bitcoind_: unify exit behaviour
| plugins/currency/bitcoin/bitcoind_ | ||
|---|---|---|
| 84 | 84 |
if command == 'suggest': |
| 85 | 85 |
for var_name in request_labels.keys(): |
| 86 | 86 |
print(var_name) |
| 87 |
return |
|
| 87 |
return True
|
|
| 88 | 88 |
|
| 89 | 89 |
if command == 'config': |
| 90 | 90 |
print('graph_category htc')
|
| ... | ... | |
| 92 | 92 |
print('graph_vlabel %s' % labels[1])
|
| 93 | 93 |
for label in line_labels: |
| 94 | 94 |
print('%s.label %s' % (label, label))
|
| 95 |
return |
|
| 95 |
return True
|
|
| 96 | 96 |
|
| 97 | 97 |
# Munin should send connection options via environment vars |
| 98 | 98 |
bitcoin_options = get_env_options('rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword')
|
| ... | ... | |
| 104 | 104 |
if not conf_file: |
| 105 | 105 |
print("Missing environment settings (rpcuser/rcpassword or bitcoin_configfile)",
|
| 106 | 106 |
file=sys.stderr) |
| 107 |
sys.exit(1)
|
|
| 107 |
return False
|
|
| 108 | 108 |
elif not os.path.exists(conf_file): |
| 109 | 109 |
print("Configuration file does not exist: {}".format(conf_file), file=sys.stderr)
|
| 110 |
sys.exit(1)
|
|
| 110 |
return False
|
|
| 111 | 111 |
else: |
| 112 | 112 |
bitcoin_options = parse_conf(conf_file) |
| 113 | 113 |
|
| ... | ... | |
| 123 | 123 |
if error: |
| 124 | 124 |
if command == 'autoconf': |
| 125 | 125 |
print('no')
|
| 126 |
return |
|
| 126 |
return True
|
|
| 127 | 127 |
else: |
| 128 | 128 |
# TODO: Better way to report errors to Munin-node. |
| 129 | 129 |
print("Could not connect to Bitcoin server.", file=sys.stderr)
|
| 130 |
sys.exit(1)
|
|
| 130 |
return False
|
|
| 131 | 131 |
|
| 132 | 132 |
if request_var in ('transactions', 'block_age'):
|
| 133 | 133 |
(info, error) = bitcoin.getblockhash(info['blocks']) |
| ... | ... | |
| 142 | 142 |
|
| 143 | 143 |
if command == 'autoconf': |
| 144 | 144 |
print('yes')
|
| 145 |
return |
|
| 145 |
return True
|
|
| 146 | 146 |
|
| 147 | 147 |
for label in line_labels: |
| 148 | 148 |
print("%s.value %s" % (label, info[label]))
|
| ... | ... | |
| 197 | 197 |
print("Missing required setting%s: %s." % ('s' if len(missing) > 1 else '',
|
| 198 | 198 |
', '.join(missing)), |
| 199 | 199 |
file=sys.stderr) |
| 200 |
sys.exit(1)
|
|
| 200 |
return False
|
|
| 201 | 201 |
|
| 202 | 202 |
|
| 203 | 203 |
class ServiceProxy: |
| ... | ... | |
| 268 | 268 |
|
| 269 | 269 |
|
| 270 | 270 |
if __name__ == "__main__": |
| 271 |
main() |
|
| 271 |
sys.exit(0 if main() else 1) |
|
Formats disponibles : Unified diff