aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore111
-rwxr-xr-xejabberdrpc.py60
2 files changed, 142 insertions, 29 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..31a4ad7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,111 @@
+
+# Created by https://www.gitignore.io/api/python
+# Edit at https://www.gitignore.io/?templates=python
+
+### Python ###
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# pyenv
+.python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# celery beat schedule file
+celerybeat-schedule
+
+# SageMath parsed files
+*.sage.py
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# Pycharm
+.idea/ \ No newline at end of file
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():