pep8 and import ajustments

* optimzed import statements
* pep8 alignment changes, mostly missing whitespaces, newlines or redundant brackets
This commit is contained in:
nico 2020-06-26 00:55:49 +02:00
parent 86562276d4
commit 7296375924
Signed by: mightyBroccoli
GPG Key ID: EA7C31AAB1BDC1A2
2 changed files with 19 additions and 21 deletions

View File

@ -1,19 +1,16 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import subprocess
import logging import logging
from time import time
from collections import defaultdict
from http.server import BaseHTTPRequestHandler, HTTPServer from http.server import BaseHTTPRequestHandler, HTTPServer
from socket import AF_INET6 from socket import AF_INET6
from time import time
from urllib.parse import parse_qs, urlparse from urllib.parse import parse_qs, urlparse
from prometheus_client import ( from prometheus_client import (
CollectorRegistry, Gauge, generate_latest, CONTENT_TYPE_LATEST CollectorRegistry, Gauge, generate_latest, CONTENT_TYPE_LATEST
) )
from config import Config from config import Config
from metrics import EjabberdMetrics from metrics import EjabberdMetrics
@ -42,7 +39,8 @@ class DynamicMetricsHandler(BaseHTTPRequestHandler):
{"generator": registry_generator}) {"generator": registry_generator})
return DynMetricsHandler return DynMetricsHandler
class Prometheus():
class Prometheus:
def __init__(self, metrics): def __init__(self, metrics):
self.ttl = 10 self.ttl = 10
self._last_update = 0 self._last_update = 0
@ -73,7 +71,7 @@ class Prometheus():
online_client_ipversion = Gauge('ejabberd_online_client_ipversion', 'count of client software', ["vhost", "node", "client", "ipversion"], registry=registry) online_client_ipversion = Gauge('ejabberd_online_client_ipversion', 'count of client software', ["vhost", "node", "client", "ipversion"], registry=registry)
for host in self._metrics.get_vhosts(): for host in self._metrics.get_vhosts():
labels_vhost = (host) labels_vhost = host
registered_vhosts.labels(labels_vhost).set(self._metrics.get_registered(host)) registered_vhosts.labels(labels_vhost).set(self._metrics.get_registered(host))
muc.labels(labels_vhost).set(self._metrics.get_muc(host)) muc.labels(labels_vhost).set(self._metrics.get_muc(host))