update munin script

pull/630/head
Jeff Becker 5 years ago
parent c77e0aff8a
commit 02e8e055ed
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -6,12 +6,14 @@ import requests
import json
import sys
from collections import defaultdict as Dict
from requests.exceptions import RequestException
def jsonrpc(method, **args):
return requests.post('http://127.0.0.1:1190/', data=json.dumps(
{'method': method, 'params': args, 'id': 0}), headers={'content-type': 'application/json'}).json()
{'method': method, 'params': args, 'id': 'munin'}), headers={'content-type': 'application/json'}).json()
def exit_sessions_main():
@ -43,20 +45,20 @@ def peers_main():
print("lokinet.peers.outbound.label outbound peers")
print("lokinet.peers.inbound.label inbound peers")
else:
inbound = 0
outbound = 0
inbound = Dict(int)
outbound = Dict(int)
try:
j = jsonrpc("llarp.admin.link.neighboors")
for peer in j['result']:
if peer["outbound"]:
outbound += 1
outbound[peer['ident']] += 1
else:
inbound += 1
inbound[peer['ident']] += 1
except RequestException:
pass
print("lokinet.peers.outbound {}".format(outbound))
print("lokinet.peers.inbound {}".format(inbound))
print("lokinet.peers.outbound {}".format(len(outbound)))
print("lokinet.peers.inbound {}".format(len(inbound)))
if __name__ == '__main__':

Loading…
Cancel
Save