mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
update munin script
This commit is contained in:
parent
c77e0aff8a
commit
02e8e055ed
|
@ -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…
Reference in a new issue