aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvela-jabber <host@sum7.eu>2021-04-17 17:07:42 +0200
committervela-jabber <host@sum7.eu>2021-04-17 17:07:42 +0200
commitd2d8ef2880f256af752ac362fdba34d3f64c3526 (patch)
treeb2f19af2f50d6c8e68e2cdcee8923968cc41478c
parent92f91dcf34efb2b0ddc505c0fa573f2306b1620f (diff)
improve calls
-rw-r--r--calls.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/calls.py b/calls.py
index d4c8f2c..94e8dde 100644
--- a/calls.py
+++ b/calls.py
@@ -22,6 +22,7 @@ class EjabberdApiCalls(EjabberdApi):
except AttributeError:
# emtpy response or None obj
+ log.warning("nodename not found on split")
raise SystemExit(17)
except IndexError:
@@ -50,6 +51,7 @@ class EjabberdApiCalls(EjabberdApi):
tmp = ver_str.findall(status)[0]
# raise SystemExit code 17 if no status message is received
except TypeError:
+ log.warning("ver sting not parsed")
raise SystemExit(17)
# return parsed version string
@@ -93,25 +95,39 @@ class EjabberdApiCalls(EjabberdApi):
def fetch_s2s_in(self):
result = self.cmd("incoming_s2s_number", {})
- if "s2s_incoming" not in result:
- return result
- return result["s2s_incoming"]
+ if isinstance(result, dict):
+ if "s2s_incoming" in result:
+ return result["s2s_incoming"]
+ log.warning("fetch_s2s_in: error empty result " + str(result))
+ return 0
+ return result
def fetch_s2s_out(self):
result = self.cmd("outgoing_s2s_number", {})
- if "s2s_outgoing" not in result:
- return result
- return result["s2s_outgoing"]
+ if isinstance(result, dict):
+ if "s2s_outgoing" in result:
+ return result["s2s_outgoing"]
+ log.warning("fetch_s2s_out: error empty result " + str(result))
+ return 0
+ return result
def fetch_uptime(self):
result = self.cmd("stats", {"name": "uptimeseconds"})
- if "stat" in result:
- return result["stat"]
+ if isinstance(result, dict):
+ if "stat" in result:
+ return result["stat"]
+ log.warning("uptime: error empty result " + str(result))
+ return 0
+ return result
def fetch_processes(self):
result = self.cmd("stats", {"name": "processes"})
- if "stat" in result:
- return result["stat"]
+ if isinstance(result, dict):
+ if "stat" in result:
+ return result["stat"]
+ log.warning("processes: error empty result " + str(result))
+ return 0
+ return result
def fetch_registered_count(self, vhost=None):
if vhost is None: