added a status to Job; NONE; OK, WARNING and ERROR is implemented
This commit is contained in:
parent
fbab93eb22
commit
2456ba9fac
3 changed files with 17 additions and 4 deletions
|
|
@ -61,6 +61,7 @@ class LinspectorInterface(object):
|
||||||
d["Enabled"] = str(job.enabled)
|
d["Enabled"] = str(job.enabled)
|
||||||
d["Threshold"] = str(job.service.get_threshold())
|
d["Threshold"] = str(job.service.get_threshold())
|
||||||
d["Fails"] = str(job.job_threshold)
|
d["Fails"] = str(job.job_threshold)
|
||||||
|
d["Status"] = str(job.status)
|
||||||
#d["Last Run"] = None
|
#d["Last Run"] = None
|
||||||
#d["Last Fail"] = None
|
#d["Last Fail"] = None
|
||||||
#d["Last Success"] = None
|
#d["Last Success"] = None
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,15 @@ class Job:
|
||||||
self.message = None
|
self.message = None
|
||||||
self.execution_success = False
|
self.execution_success = False
|
||||||
self.jobHex = self.hex_string()
|
self.jobHex = self.hex_string()
|
||||||
|
"""
|
||||||
|
NONE job was not executed
|
||||||
|
OK when everything is fine
|
||||||
|
WARNING when a job has errors but not the threshold overridden
|
||||||
|
RECOVER when a job recovers e.g. the threshold decrements (not implemented)
|
||||||
|
ERROR when a jobs threshold is overridden
|
||||||
|
UNKNOWN when a job throws an exception which is not handled by the job itself (not implemented)
|
||||||
|
"""
|
||||||
|
self.status = "NONE"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.__dict__)
|
return str(self.__dict__)
|
||||||
|
|
@ -83,26 +92,28 @@ class Job:
|
||||||
def handle_threshold(self, service_threshold, execution_sucessful):
|
def handle_threshold(self, service_threshold, execution_sucessful):
|
||||||
if execution_sucessful:
|
if execution_sucessful:
|
||||||
if self.job_threshold > 0:
|
if self.job_threshold > 0:
|
||||||
#TODO: maybe set threshold_handling for each service optionally; will override core setting!
|
if "threshold_reset" in self.core and self.core["threshold_reset"]:
|
||||||
#TODO: reset should be default; decrement should be optional
|
|
||||||
if self.core["threshold_handling"] == "reset":
|
|
||||||
logger.info("Job " + self.hex_string() + ", Threshold Reset")
|
logger.info("Job " + self.hex_string() + ", Threshold Reset")
|
||||||
self.job_threshold = 0
|
self.job_threshold = 0
|
||||||
else:
|
else:
|
||||||
logger.info("Job " + self.hex_string() + ", Threshold Decrement")
|
logger.info("Job " + self.hex_string() + ", Threshold Decrement")
|
||||||
self.job_threshold -= 1
|
self.job_threshold -= 1
|
||||||
|
|
||||||
|
self.status = "OK"
|
||||||
self.job_wins += 1
|
self.job_wins += 1
|
||||||
else:
|
else:
|
||||||
|
self.status = "WARNING"
|
||||||
self.job_fails += 1
|
self.job_fails += 1
|
||||||
self.job_threshold += 1
|
self.job_threshold += 1
|
||||||
|
|
||||||
if self.job_threshold >= service_threshold:
|
if self.job_threshold >= service_threshold:
|
||||||
logger.info("Job " + self.hex_string() + ", Threshold reached!")
|
logger.info("Job " + self.hex_string() + ", Threshold reached!")
|
||||||
|
self.status = "ERROR"
|
||||||
self.handle_alarm()
|
self.handle_alarm()
|
||||||
|
|
||||||
def handle_alarm(self):
|
def handle_alarm(self):
|
||||||
for member in self.members:
|
for member in self.members:
|
||||||
self.task_list.execute_task_infos(self.get_message(), member.get_tasks())
|
self.task_list.execute_task_infos(self.status + " " + self.get_message(), member.get_tasks())
|
||||||
|
|
||||||
def handle_call(self):
|
def handle_call(self):
|
||||||
logger.debug("handle call")
|
logger.debug("handle call")
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,7 @@ Usage:
|
||||||
PURPLE + " Next run" + END + ": " + job_dict["Next run"] + \
|
PURPLE + " Next run" + END + ": " + job_dict["Next run"] + \
|
||||||
PURPLE + " Runs" + END + ": " + job_dict["Runs"] + \
|
PURPLE + " Runs" + END + ": " + job_dict["Runs"] + \
|
||||||
PURPLE + " Fails" + END + ": " + job_dict["Fails"] + \
|
PURPLE + " Fails" + END + ": " + job_dict["Fails"] + \
|
||||||
|
PURPLE + " Status" + END + ": " + job_dict["Status"] + \
|
||||||
PURPLE + " Enabled" + END + ": " + job_dict["Enabled"]
|
PURPLE + " Enabled" + END + ": " + job_dict["Enabled"]
|
||||||
elif text == "count":
|
elif text == "count":
|
||||||
print GREEN + "Job Count" + END + ":\t" + str(self.interface.get_job_count())
|
print GREEN + "Job Count" + END + ":\t" + str(self.interface.get_job_count())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue