aboutsummaryrefslogtreecommitdiffstats
path: root/metrics.py
diff options
context:
space:
mode:
Diffstat (limited to 'metrics.py')
-rwxr-xr-xmetrics.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/metrics.py b/metrics.py
index 18d2eeb..ede3b1b 100755
--- a/metrics.py
+++ b/metrics.py
@@ -12,7 +12,8 @@ class EjabberdMetrics(EjabberdApiCalls):
"""
class to fetch metrics per xmlrpc
"""
- def __init__(self, url, login=None, api="rpc", muc_host: str = 'conference'):
+
+ def __init__(self, url, login=None, api="rpc", muc_host: str = "conference"):
# init ejabberd api
super().__init__(url, login, api)
@@ -32,7 +33,7 @@ class EjabberdMetrics(EjabberdApiCalls):
"profanity": [],
"Xabber": ["xabber", "xabber-android"],
"ChatSecure": ["chatsecure"],
- "Monal": []
+ "Monal": [],
}
for client, names in clientmap.items():
@@ -110,7 +111,7 @@ class EjabberdMetrics(EjabberdApiCalls):
return self.get_online_by("node", vhost=vhost)
def get_online_by_vhost(self, node=None):
- return self.get_online_by("jid", parse=lambda jid: jid[jid.find("@")+1:jid.find("/")], node=node)
+ return self.get_online_by("jid", parse=lambda jid: jid[jid.find("@") + 1 : jid.find("/")], node=node)
def get_online_by_status(self, vhost=None, node=None):
return self.get_online_by("status", vhost=vhost, node=node)
@@ -187,11 +188,11 @@ class EjabberdMetrics(EjabberdApiCalls):
return self._uptime
def get_processes(self):
- if not hasattr(self, '_processes'):
+ if not hasattr(self, "_processes"):
self._processes = self.fetch_processes()
return self._processes
- def get_vhost_metrics(self, vhost):
+ def get_vhost_metrics(self, vhost):
data = {
"registered": self.get_registered(vhost),
"muc": self.get_muc(vhost),
@@ -199,7 +200,7 @@ class EjabberdMetrics(EjabberdApiCalls):
"online_by_client": self.get_online_by_client(vhost),
"online_by_ipversion": self.get_online_by_ipversion(vhost),
"online_by_connection": self.get_online_by_connection(vhost),
- "online_by_node": self.get_online_by_node(vhost)
+ "online_by_node": self.get_online_by_node(vhost),
}
return data
@@ -209,13 +210,13 @@ class EjabberdMetrics(EjabberdApiCalls):
self._nodes = self.fetch_nodes()
return self._nodes
- def get_node_metrics(self, node):
+ def get_node_metrics(self, node):
data = {
"online_by_status": self.get_online_by_status(node=node),
"online_by_client": self.get_online_by_client(node=node),
"online_by_ipversion": self.get_online_by_ipversion(node=node),
"online_by_connection": self.get_online_by_connection(node=node),
- "online_by_vhost": self.get_online_by_vhost(node=node)
+ "online_by_vhost": self.get_online_by_vhost(node=node),
}
return data
@@ -225,7 +226,7 @@ class EjabberdMetrics(EjabberdApiCalls):
"registered": self.get_registered(),
"muc": self.get_muc(),
"s2s_in": self.get_s2s_in(),
- "s2s_out": self.get_s2s_out(),
+ "s2s_out": self.get_s2s_out(),
"uptime": self.get_uptime(),
"processes": self.get_processes(),
"online_by_status": self.get_online_by_status(),
@@ -233,14 +234,14 @@ class EjabberdMetrics(EjabberdApiCalls):
"online_by_ipversion": self.get_online_by_ipversion(),
"online_by_connection": self.get_online_by_connection(),
"online_by_node": self.get_online_by_node(),
- "online_by_vhost": self.get_online_by_vhost()
+ "online_by_vhost": self.get_online_by_vhost(),
}
vhosts = {}
for host in self.get_vhosts():
vhosts[host] = self.get_vhost_metrics(host)
data["vhosts"] = vhosts
-
+
nodes = {}
for node in self.get_nodes():
nodes[node] = self.get_node_metrics(node)
@@ -259,9 +260,9 @@ if __name__ == "__main__":
config = Config()
# credentials and parameters
- url = config.get('url', default='http://localhost:5280/api')
- login = config.get('login', default=None)
- api = config.get('api', default='rest')
+ url = config.get("url", default="http://localhost:5280/api")
+ login = config.get("login", default=None)
+ api = config.get("api", default="rest")
# init handler
metrics = EjabberdMetrics(url, login, api)