|
|
|
@ -17,14 +17,14 @@ def jsonrpc(method, **args):
|
|
|
|
|
{'method': method, 'params': args, 'id': 'munin'}), headers={'content-type': 'application/json'}).json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def exit_sessions_main():
|
|
|
|
|
def exit_sessions_main(exe):
|
|
|
|
|
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
|
|
|
|
print("graph_title lokinet exit sessions")
|
|
|
|
|
print("graph_vlabel sessions")
|
|
|
|
|
print("graph_category network")
|
|
|
|
|
print("graph_info This graph shows the number of exit sessions on a lokinet exit")
|
|
|
|
|
print("lokinet.exit.sessions.info Number of exit sessions")
|
|
|
|
|
print("lokinet.exit.sessions.label sessions")
|
|
|
|
|
print("{}.sessions.info Number of exit sessions".format(exe))
|
|
|
|
|
print("{}.sessions.label sessions".format(exe))
|
|
|
|
|
else:
|
|
|
|
|
count = 0
|
|
|
|
|
try:
|
|
|
|
@ -32,19 +32,19 @@ def exit_sessions_main():
|
|
|
|
|
count = len(j['result'])
|
|
|
|
|
except RequestException:
|
|
|
|
|
pass
|
|
|
|
|
print("lokinet.exit.sessions {}".format(count))
|
|
|
|
|
print("{}.sessions {}".format(exe, count))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def peers_main():
|
|
|
|
|
def peers_main(exe):
|
|
|
|
|
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
|
|
|
|
print("graph_title lokinet peers")
|
|
|
|
|
print("graph_vlabel peers")
|
|
|
|
|
print("graph_category network")
|
|
|
|
|
print("graph_info This graph shows the number of node to node sessions of this lokinet router")
|
|
|
|
|
print("lokinet.peers.outbound.info Number of outbound lokinet peers")
|
|
|
|
|
print("lokinet.peers.inbound.info Number of inbound lokinet peers")
|
|
|
|
|
print("lokinet.peers.outbound.label outbound peers")
|
|
|
|
|
print("lokinet.peers.inbound.label inbound peers")
|
|
|
|
|
print("{}.outbound.info Number of outbound lokinet peers".format(exe))
|
|
|
|
|
print("{}.inbound.info Number of inbound lokinet peers".format(exe))
|
|
|
|
|
print("{}.outbound.label outbound peers".format(exe))
|
|
|
|
|
print("{}.inbound.label inbound peers".format(exe))
|
|
|
|
|
else:
|
|
|
|
|
inbound = Dict(int)
|
|
|
|
|
outbound = Dict(int)
|
|
|
|
@ -58,16 +58,16 @@ def peers_main():
|
|
|
|
|
except RequestException:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
print("lokinet.peers.outbound {}".format(len(outbound)))
|
|
|
|
|
print("lokinet.peers.inbound {}".format(len(inbound)))
|
|
|
|
|
print("{}.outbound {}".format(exe, len(outbound)))
|
|
|
|
|
print("{}.inbound {}".format(exe, len(inbound)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
exe = os.path.basename(sys.argv[0]).lower()
|
|
|
|
|
if exe == 'lokinet-peers':
|
|
|
|
|
peers_main()
|
|
|
|
|
peers_main(exe)
|
|
|
|
|
elif exe == 'lokinet-exit':
|
|
|
|
|
exit_sessions_main()
|
|
|
|
|
exit_sessions_main(exe)
|
|
|
|
|
else:
|
|
|
|
|
print(
|
|
|
|
|
'please symlink this as `lokinet-peers` or `lokinet-exit` in munin plugins dir')
|
|
|
|
|