parent
47683773ff
commit
1a63916b4e
|
@ -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/
|
|
@ -40,7 +40,9 @@ class EjabberdMetrics():
|
||||||
if client in resource:
|
if client in resource:
|
||||||
return client
|
return client
|
||||||
return "other"
|
return "other"
|
||||||
def _ipversion(self, ip):
|
|
||||||
|
@staticmethod
|
||||||
|
def _ipversion(ip):
|
||||||
addr = ipaddress.ip_address(ip)
|
addr = ipaddress.ip_address(ip)
|
||||||
if addr.version == 6:
|
if addr.version == 6:
|
||||||
if addr.ipv4_mapped:
|
if addr.ipv4_mapped:
|
||||||
|
@ -50,7 +52,6 @@ class EjabberdMetrics():
|
||||||
return addr.version
|
return addr.version
|
||||||
|
|
||||||
def fetch_onlineuser(self):
|
def fetch_onlineuser(self):
|
||||||
data = None
|
|
||||||
tmp = self._cmd("connected_users_info", {})
|
tmp = self._cmd("connected_users_info", {})
|
||||||
if "connected_users_info" not in tmp:
|
if "connected_users_info" not in tmp:
|
||||||
return None
|
return None
|
||||||
|
@ -136,7 +137,6 @@ class EjabberdMetrics():
|
||||||
self._s2s_in = self.fetch_s2s_in()
|
self._s2s_in = self.fetch_s2s_in()
|
||||||
self._s2s_out = self.fetch_s2s_out()
|
self._s2s_out = self.fetch_s2s_out()
|
||||||
|
|
||||||
|
|
||||||
def get_online_by(self, by="node", parse=None, vhost=None, node=None):
|
def get_online_by(self, by="node", parse=None, vhost=None, node=None):
|
||||||
parser = parse or (lambda a: a)
|
parser = parse or (lambda a: a)
|
||||||
if not hasattr(self, "_onlineuser"):
|
if not hasattr(self, "_onlineuser"):
|
||||||
|
@ -233,15 +233,16 @@ class EjabberdMetrics():
|
||||||
return self._s2s_out
|
return self._s2s_out
|
||||||
|
|
||||||
def get_vhost_metrics(self, vhost):
|
def get_vhost_metrics(self, vhost):
|
||||||
data = {}
|
data = {
|
||||||
data["registered"] = self.get_registered(vhost)
|
"registered": self.get_registered(vhost),
|
||||||
data["muc"] = self.get_muc(vhost)
|
"muc": self.get_muc(vhost),
|
||||||
data["online_by_status"] = self.get_online_by_status(vhost)
|
"online_by_status": self.get_online_by_status(vhost),
|
||||||
data["online_by_client"] = self.get_online_by_client(vhost)
|
"online_by_client": self.get_online_by_client(vhost),
|
||||||
data["online_by_ipversion"] = self.get_online_by_ipversion(vhost)
|
"online_by_ipversion": self.get_online_by_ipversion(vhost),
|
||||||
data["online_by_connection"] = self.get_online_by_connection(vhost)
|
"online_by_connection": self.get_online_by_connection(vhost),
|
||||||
|
"online_by_node": self.get_online_by_node(vhost)
|
||||||
|
}
|
||||||
|
|
||||||
data["online_by_node"] = self.get_online_by_node(vhost)
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_nodes(self):
|
def get_nodes(self):
|
||||||
|
@ -250,26 +251,27 @@ class EjabberdMetrics():
|
||||||
return self._nodes
|
return self._nodes
|
||||||
|
|
||||||
def get_node_metrics(self, node):
|
def get_node_metrics(self, node):
|
||||||
data = {}
|
data = {
|
||||||
data["online_by_status"] = self.get_online_by_status(node=node)
|
"online_by_status": self.get_online_by_status(node=node),
|
||||||
data["online_by_client"] = self.get_online_by_client(node=node)
|
"online_by_client": self.get_online_by_client(node=node),
|
||||||
data["online_by_ipversion"] = self.get_online_by_ipversion(node=node)
|
"online_by_ipversion": self.get_online_by_ipversion(node=node),
|
||||||
data["online_by_connection"] = self.get_online_by_connection(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
|
return data
|
||||||
|
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
data = {}
|
data = {
|
||||||
data["registered"] = self.get_registered()
|
"registered": self.get_registered(),
|
||||||
data["muc"] = self.get_muc()
|
"muc": self.get_muc(),
|
||||||
data["online_by_status"] = self.get_online_by_status()
|
"online_by_status": self.get_online_by_status(),
|
||||||
data["online_by_client"] = self.get_online_by_client()
|
"online_by_client": self.get_online_by_client(),
|
||||||
data["online_by_ipversion"] = self.get_online_by_ipversion()
|
"online_by_ipversion": self.get_online_by_ipversion(),
|
||||||
data["online_by_connection"] = self.get_online_by_connection()
|
"online_by_connection": self.get_online_by_connection(),
|
||||||
|
"online_by_node": self.get_online_by_node(),
|
||||||
data["online_by_node"] = self.get_online_by_node()
|
"online_by_vhost": self.get_online_by_vhost()
|
||||||
data["online_by_vhost"] = self.get_online_by_vhost()
|
}
|
||||||
|
|
||||||
vhosts = {}
|
vhosts = {}
|
||||||
for host in self.get_vhosts():
|
for host in self.get_vhosts():
|
||||||
|
|
Loading…
Reference in New Issue