Skip to content

Commit

Permalink
Improve JobRunTime subcheck output
Browse files Browse the repository at this point in the history
  • Loading branch information
martialblog committed Sep 30, 2024
1 parent bd40556 commit f46f908
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion check_bareos.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def checkRunTimeJobs(cursor, state, time, warning, critical):
checkState["returnCode"] = OK
checkState["returnMessage"] = "[OK]"

checkState["returnMessage"] += " - " + str(result) + " Jobs are running longer than " + str(time) + " days"
checkState["returnMessage"] += " - " + str(result) + " Jobs in state '" + JOBSTATES.get(state, state) + "' are running longer than " + str(time) + " days"

checkState["performanceData"] = "bareos.job.count=" + str(result) + ";" + str(warning) + ";" + str(critical) + ";;"

Expand Down
8 changes: 4 additions & 4 deletions test_check_bareos.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ def test_checkRunTimeJobs(self):
c = mock.MagicMock()

c.fetchone.return_value = [2]
actual = checkRunTimeJobs(c, "'F','I','D'", 1, Threshold(3), Threshold(5))
expected = {'returnCode': 0, 'returnMessage': '[OK] - 2.0 Jobs are running longer than 1 days', 'performanceData': 'bareos.job.count=2.0;3;5;;'}
actual = checkRunTimeJobs(c, "D", 1, Threshold(3), Threshold(5))
expected = {'returnCode': 0, 'returnMessage': "[OK] - 2.0 Jobs in state 'Verify differences' are running longer than 1 days", 'performanceData': 'bareos.job.count=2.0;3;5;;'}
self.assertEqual(actual, expected)

c.fetchone.return_value = [10]
actual = checkRunTimeJobs(c, "'F','I','D'", 1, Threshold(3), Threshold(5))
expected = {'returnCode': 2, 'returnMessage': '[CRITICAL] - 10.0 Jobs are running longer than 1 days', 'performanceData': 'bareos.job.count=10.0;3;5;;'}
actual = checkRunTimeJobs(c, "F", 1, Threshold(3), Threshold(5))
expected = {'returnCode': 2, 'returnMessage': "[CRITICAL] - 10.0 Jobs in state 'Job waiting on File daemon' are running longer than 1 days", 'performanceData': 'bareos.job.count=10.0;3;5;;'}
self.assertEqual(actual, expected)


Expand Down

0 comments on commit f46f908

Please sign in to comment.