From 907d3bdb6171997469b18f32c091885639e3444b Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 26 Jun 2020 00:58:06 +0200 Subject: [PATCH] properly implement more values * fix the bad job with commit bf05b826 + proper guidance methods complete with a proper name --- metrics.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/metrics.py b/metrics.py index 89bf4d0..18d2eeb 100755 --- a/metrics.py +++ b/metrics.py @@ -82,6 +82,10 @@ class EjabberdMetrics(EjabberdApiCalls): self._s2s_in = self.fetch_s2s_in() self._s2s_out = self.fetch_s2s_out() + # misc + self._uptime = self.fetch_uptime() + self._processes = self.fetch_processes() + def get_online_by(self, by="node", parse=None, vhost=None, node=None): parser = parse or (lambda a: a) if not hasattr(self, "_onlineuser"): @@ -177,6 +181,16 @@ class EjabberdMetrics(EjabberdApiCalls): self._s2s_out = self.fetch_s2s_out() return self._s2s_out + def get_uptime(self): + if not hasattr(self, "_uptime"): + self._uptime = self.fetch_uptime() + return self._uptime + + def get_processes(self): + if not hasattr(self, '_processes'): + self._processes = self.fetch_processes() + return self._processes + def get_vhost_metrics(self, vhost): data = { "registered": self.get_registered(vhost), @@ -212,8 +226,8 @@ class EjabberdMetrics(EjabberdApiCalls): "muc": self.get_muc(), "s2s_in": self.get_s2s_in(), "s2s_out": self.get_s2s_out(), - "uptime": self.fetch_uptime(), - "processes": self.fetch_processes(), + "uptime": self.get_uptime(), + "processes": self.get_processes(), "online_by_status": self.get_online_by_status(), "online_by_client": self.get_online_by_client(), "online_by_ipversion": self.get_online_by_ipversion(),