mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Plugin bitcoind_: unify exit behaviour
This commit is contained in:
parent
a0aa955a2d
commit
fd45fe6c8e
1 changed files with 9 additions and 9 deletions
|
@ -84,7 +84,7 @@ def main():
|
||||||
if command == 'suggest':
|
if command == 'suggest':
|
||||||
for var_name in request_labels.keys():
|
for var_name in request_labels.keys():
|
||||||
print(var_name)
|
print(var_name)
|
||||||
return
|
return True
|
||||||
|
|
||||||
if command == 'config':
|
if command == 'config':
|
||||||
print('graph_category htc')
|
print('graph_category htc')
|
||||||
|
@ -92,7 +92,7 @@ def main():
|
||||||
print('graph_vlabel %s' % labels[1])
|
print('graph_vlabel %s' % labels[1])
|
||||||
for label in line_labels:
|
for label in line_labels:
|
||||||
print('%s.label %s' % (label, label))
|
print('%s.label %s' % (label, label))
|
||||||
return
|
return True
|
||||||
|
|
||||||
# Munin should send connection options via environment vars
|
# Munin should send connection options via environment vars
|
||||||
bitcoin_options = get_env_options('rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword')
|
bitcoin_options = get_env_options('rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword')
|
||||||
|
@ -104,10 +104,10 @@ def main():
|
||||||
if not conf_file:
|
if not conf_file:
|
||||||
print("Missing environment settings (rpcuser/rcpassword or bitcoin_configfile)",
|
print("Missing environment settings (rpcuser/rcpassword or bitcoin_configfile)",
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
return False
|
||||||
elif not os.path.exists(conf_file):
|
elif not os.path.exists(conf_file):
|
||||||
print("Configuration file does not exist: {}".format(conf_file), file=sys.stderr)
|
print("Configuration file does not exist: {}".format(conf_file), file=sys.stderr)
|
||||||
sys.exit(1)
|
return False
|
||||||
else:
|
else:
|
||||||
bitcoin_options = parse_conf(conf_file)
|
bitcoin_options = parse_conf(conf_file)
|
||||||
|
|
||||||
|
@ -123,11 +123,11 @@ def main():
|
||||||
if error:
|
if error:
|
||||||
if command == 'autoconf':
|
if command == 'autoconf':
|
||||||
print('no')
|
print('no')
|
||||||
return
|
return True
|
||||||
else:
|
else:
|
||||||
# TODO: Better way to report errors to Munin-node.
|
# TODO: Better way to report errors to Munin-node.
|
||||||
print("Could not connect to Bitcoin server.", file=sys.stderr)
|
print("Could not connect to Bitcoin server.", file=sys.stderr)
|
||||||
sys.exit(1)
|
return False
|
||||||
|
|
||||||
if request_var in ('transactions', 'block_age'):
|
if request_var in ('transactions', 'block_age'):
|
||||||
(info, error) = bitcoin.getblockhash(info['blocks'])
|
(info, error) = bitcoin.getblockhash(info['blocks'])
|
||||||
|
@ -142,7 +142,7 @@ def main():
|
||||||
|
|
||||||
if command == 'autoconf':
|
if command == 'autoconf':
|
||||||
print('yes')
|
print('yes')
|
||||||
return
|
return True
|
||||||
|
|
||||||
for label in line_labels:
|
for label in line_labels:
|
||||||
print("%s.value %s" % (label, info[label]))
|
print("%s.value %s" % (label, info[label]))
|
||||||
|
@ -197,7 +197,7 @@ class Options(dict):
|
||||||
print("Missing required setting%s: %s." % ('s' if len(missing) > 1 else '',
|
print("Missing required setting%s: %s." % ('s' if len(missing) > 1 else '',
|
||||||
', '.join(missing)),
|
', '.join(missing)),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
return False
|
||||||
|
|
||||||
|
|
||||||
class ServiceProxy:
|
class ServiceProxy:
|
||||||
|
@ -268,4 +268,4 @@ def get_json_url(url):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
sys.exit(0 if main() else 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue