improve calls

This commit is contained in:
vela-jabber 2021-04-17 17:07:42 +02:00
parent 92f91dcf34
commit d2d8ef2880
1 changed files with 26 additions and 10 deletions

View File

@ -22,6 +22,7 @@ class EjabberdApiCalls(EjabberdApi):
except AttributeError: except AttributeError:
# emtpy response or None obj # emtpy response or None obj
log.warning("nodename not found on split")
raise SystemExit(17) raise SystemExit(17)
except IndexError: except IndexError:
@ -50,6 +51,7 @@ class EjabberdApiCalls(EjabberdApi):
tmp = ver_str.findall(status)[0] tmp = ver_str.findall(status)[0]
# raise SystemExit code 17 if no status message is received # raise SystemExit code 17 if no status message is received
except TypeError: except TypeError:
log.warning("ver sting not parsed")
raise SystemExit(17) raise SystemExit(17)
# return parsed version string # return parsed version string
@ -93,25 +95,39 @@ class EjabberdApiCalls(EjabberdApi):
def fetch_s2s_in(self): def fetch_s2s_in(self):
result = self.cmd("incoming_s2s_number", {}) result = self.cmd("incoming_s2s_number", {})
if "s2s_incoming" not in result: if isinstance(result, dict):
return result if "s2s_incoming" in result:
return result["s2s_incoming"] return result["s2s_incoming"]
log.warning("fetch_s2s_in: error empty result " + str(result))
return 0
return result
def fetch_s2s_out(self): def fetch_s2s_out(self):
result = self.cmd("outgoing_s2s_number", {}) result = self.cmd("outgoing_s2s_number", {})
if "s2s_outgoing" not in result: if isinstance(result, dict):
return result if "s2s_outgoing" in result:
return result["s2s_outgoing"] return result["s2s_outgoing"]
log.warning("fetch_s2s_out: error empty result " + str(result))
return 0
return result
def fetch_uptime(self): def fetch_uptime(self):
result = self.cmd("stats", {"name": "uptimeseconds"}) result = self.cmd("stats", {"name": "uptimeseconds"})
if isinstance(result, dict):
if "stat" in result: if "stat" in result:
return result["stat"] return result["stat"]
log.warning("uptime: error empty result " + str(result))
return 0
return result
def fetch_processes(self): def fetch_processes(self):
result = self.cmd("stats", {"name": "processes"}) result = self.cmd("stats", {"name": "processes"})
if isinstance(result, dict):
if "stat" in result: if "stat" in result:
return result["stat"] return result["stat"]
log.warning("processes: error empty result " + str(result))
return 0
return result
def fetch_registered_count(self, vhost=None): def fetch_registered_count(self, vhost=None):
if vhost is None: if vhost is None: