NETWAYS / check_bareos

Icinga Plugin to check Bareos Backup Director databases
https://www.netways.de/
GNU General Public License v3.0
8 stars 7 forks source link

Warning and Critical are in incorrect way for job Completed Successfully #15

Closed spardhas closed 1 year ago

spardhas commented 7 years ago

Hi,

When check the Completed Job, the warning and critical must be in reverse way.

eg: I have 5 Job. I need a warning if i have less of 5 and a critical when i have less of 3 job is not successfully done.

jgrammen-agilitypr commented 7 years ago
@@ -283,18 +283,27 @@ def checkSingleJob(cursor, name, state, kind, time, warning, critical):
     cursor.execute(query)
     results = cursor.fetchall()  # Returns a value
     result = len(results)
-
-    if result >= int(critical):
+    if(state != 'T'):
+        if result >= int(critical):
             checkState["returnCode"] = 2
             checkState["returnMessage"] = "CRITICAL - " + str(result) + " Jobs are in the state: "+str(getState(state))-    elif result >= int(warning):
+        elif result >= int(warning):
             checkState["returnCode"] = 1
             checkState["returnMessage"] = "WARNING - " + str(result) + " Jobs are in the state: "+str(getState(state))
+        else:
+            checkState["returnCode"] = 0
+            checkState["returnMessage"] = "OK - " + str(result) + " Jobs are in the state: "+str(getState(state))
     else:
+        if result <= int(critical):
+            checkState["returnCode"] = 2
+            checkState["returnMessage"] = "CRITICAL - " + str(result) + " Jobs are in the state: "+str(getState(state))+        elif result <= int(warning):
+            checkState["returnCode"] = 1
+            checkState["returnMessage"] = "WARNING - " + str(result) + " Jobs are in the state: "+str(getState(state))
+        else:
             checkState["returnCode"] = 0
             checkState["returnMessage"] = "OK - " + str(result) + " Jobs are in the state: "+str(getState(state))
     checkState["performanceData"] = str(getState(state))+"=" + str(result) + ";" + str(warning) + ";" + str(critical) +-
     return checkState

 def checkRunTimeJobs(cursor,name,state,time,warning,critical):

a simple work around that check if the state is "T" and reverse the crit and warn thresholds

martialblog commented 1 year ago

We're currently planning a rewrite that will adress this issue.

martialblog commented 1 year ago

The refactor will allow for --warning --critical Thresholds. This will solve the issues by allowing this:

check_bareos.py -U bareos job --checkJob --warning 5: --critical 3: