From aefd66009f9a42e9a92db53fc433b13acf21f3a1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 7 Feb 2022 20:43:35 +0100 Subject: [PATCH] v2.1 --- serviceData.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/serviceData.py b/serviceData.py index f8f42de..b77c6ef 100644 --- a/serviceData.py +++ b/serviceData.py @@ -45,7 +45,11 @@ class ServiceData: text = self.serviceData[host][service]["text"] msg = "(néant)" - if self.serviceData[host][service]["status_type"] == "PROBLEM": + if self.serviceData[host]["status_type"] == "PROBLEM" or + self.serviceData[host]["status_type"] == "UNKNOWN": + msg = "{}, je détecte de multiples problèmes sur {}".format(maintainer, host) + + elif self.serviceData[host][service]["status_type"] == "PROBLEM": msg = "{}, je détecte un problème de {} sur {} ({})".format(maintainer, service, host, text) elif self.serviceData[host][service]["status_type"] == "UNKNOWN": @@ -93,13 +97,15 @@ class ServiceData: # Is it a service and is it known if service and service in self.serviceData[host]: # update host if needed - if status_type != self.serviceData[host][service]["status_type"]: - self.serviceData[host][service]["status_state"] = status_state - self.serviceData[host][service]["status_type"] = status_type - self.serviceData[host][service]["destmuc"] = destmuc - self.serviceData[host][service]["text"] = text + self.serviceData[host][service]["status_state"] = status_state + self.serviceData[host][service]["status_type"] = status_type + self.serviceData[host][service]["destmuc"] = destmuc + self.serviceData[host][service]["text"] = text + maintainer = self.serviceData[host]["maintainer"] + if status_type != self.serviceData[host][service]["status_type"] and + status_type != self.serviceData[host]["status_type"]: self.serviceData[host][service]["needUpdate"] = True - maintainer = self.serviceData[host]["maintainer"] + # Is it an unkown service elif service: @@ -109,19 +115,20 @@ class ServiceData: self.serviceData[host][service]["status_state"] = status_state self.serviceData[host][service]["status_type"] = status_type self.serviceData[host][service]["text"] = text - self.serviceData[host][service]["needUpdate"] = True maintainer = self.serviceData[host]["maintainer"] + if status_type != self.serviceData[host]["status_type"]: + self.serviceData[host][service]["needUpdate"] = True # This is a host (not a service) else: # update host if needed + self.serviceData[host]["destmuc"] = destmuc + self.serviceData[host]["status_state"] = status_state + self.serviceData[host]["status_type"] = status_type + self.serviceData[host]["text"] = text + maintainer = self.serviceData[host]["maintainer"] if status_type != self.serviceData[host]["status_type"]: - self.serviceData[host]["destmuc"] = destmuc - self.serviceData[host]["status_state"] = status_state - self.serviceData[host]["status_type"] = status_type - self.serviceData[host]["text"] = text self.serviceData[host]["needUpdate"] = True - maintainer = self.serviceData[host]["maintainer"] # That host is not known else: