aboutsummaryrefslogtreecommitdiffstats
path: root/ejabberdrpc.py
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2019-10-17 14:23:11 +0200
committernico <nico@magicbroccoli.de>2019-10-17 14:24:06 +0200
commit1a63916b4e9911e0cd9348e95846ef9455cc97e5 (patch)
tree09977128a4bd1c154f641585296c788dc2d8d2f3 /ejabberdrpc.py
parent47683773ffa97f7371b3c32f1cf2f572c8c2531f (diff)
pep8 and gitignore
+ add .gitignore * some pep8 changes
Diffstat (limited to 'ejabberdrpc.py')
-rwxr-xr-xejabberdrpc.py60
1 files changed, 31 insertions, 29 deletions
diff --git a/ejabberdrpc.py b/ejabberdrpc.py
index 6ae8409..b2cc908 100755
--- a/ejabberdrpc.py
+++ b/ejabberdrpc.py
@@ -33,14 +33,16 @@ class EjabberdMetrics():
"dino": [],
"poezio": [],
}
- for client,names in clientmap.items():
+ for client, names in clientmap.items():
for c in names:
if c in resource:
return client
if client in resource:
return client
return "other"
- def _ipversion(self, ip):
+
+ @staticmethod
+ def _ipversion(ip):
addr = ipaddress.ip_address(ip)
if addr.version == 6:
if addr.ipv4_mapped:
@@ -50,7 +52,6 @@ class EjabberdMetrics():
return addr.version
def fetch_onlineuser(self):
- data = None
tmp = self._cmd("connected_users_info", {})
if "connected_users_info" not in tmp:
return None
@@ -136,7 +137,6 @@ class EjabberdMetrics():
self._s2s_in = self.fetch_s2s_in()
self._s2s_out = self.fetch_s2s_out()
-
def get_online_by(self, by="node", parse=None, vhost=None, node=None):
parser = parse or (lambda a: a)
if not hasattr(self, "_onlineuser"):
@@ -233,15 +233,16 @@ class EjabberdMetrics():
return self._s2s_out
def get_vhost_metrics(self, vhost):
- data = {}
- data["registered"] = self.get_registered(vhost)
- data["muc"] = self.get_muc(vhost)
- data["online_by_status"] = self.get_online_by_status(vhost)
- data["online_by_client"] = self.get_online_by_client(vhost)
- data["online_by_ipversion"] = self.get_online_by_ipversion(vhost)
- data["online_by_connection"] = self.get_online_by_connection(vhost)
-
- data["online_by_node"] = self.get_online_by_node(vhost)
+ data = {
+ "registered": self.get_registered(vhost),
+ "muc": self.get_muc(vhost),
+ "online_by_status": self.get_online_by_status(vhost),
+ "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)
+ }
+
return data
def get_nodes(self):
@@ -250,26 +251,27 @@ class EjabberdMetrics():
return self._nodes
def get_node_metrics(self, node):
- data = {}
- data["online_by_status"] = self.get_online_by_status(node=node)
- data["online_by_client"] = self.get_online_by_client(node=node)
- data["online_by_ipversion"] = self.get_online_by_ipversion(node=node)
- data["online_by_connection"] = self.get_online_by_connection(node=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)
+ }
- data["online_by_vhost"] = self.get_online_by_vhost(node=node)
return data
def get_all(self):
- data = {}
- data["registered"] = self.get_registered()
- data["muc"] = self.get_muc()
- data["online_by_status"] = self.get_online_by_status()
- data["online_by_client"] = self.get_online_by_client()
- data["online_by_ipversion"] = self.get_online_by_ipversion()
- data["online_by_connection"] = self.get_online_by_connection()
-
- data["online_by_node"] = self.get_online_by_node()
- data["online_by_vhost"] = self.get_online_by_vhost()
+ data = {
+ "registered": self.get_registered(),
+ "muc": self.get_muc(),
+ "online_by_status": self.get_online_by_status(),
+ "online_by_client": self.get_online_by_client(),
+ "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()
+ }
vhosts = {}
for host in self.get_vhosts():