Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

added perfdata #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions check_yum
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,20 @@ class YumTester:
if number_updates == 0:
status = OK
message = "0 Updates Available"
perfdata = "updates=0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this (and following) should rather read something like "non-security-updates=" or so - otherwise it's ambiguous whether or not this number includes security updates.

else:
if self.no_warn_on_updates:
status = OK
else:
status = CRITICAL
if number_updates == 1:
message = "1 Update Available"
perfdata = "updates=1"
else:
message = "%s Updates Available" % number_updates
perfdata = "updates=%s" % number_updates
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just doing one
perfdata = "updates=%s" % number_updates
after the if-clause?


return status, message
return status, message, perfdata


def test_security_updates(self):
Expand All @@ -355,15 +358,18 @@ class YumTester:
if number_security_updates == 0:
status = OK
message = "0 Security Updates Available"
perfdata = "security_updates=0"
else:
if self.no_warn_on_updates:
status = OK
else:
status = CRITICAL
if number_security_updates == 1:
message = "1 Security Update Available"
perfdata = "security_updates=1"
elif number_security_updates > 1:
message = "%s Security Updates Available" % number_security_updates
perfdata = "security_updates=%s" % number_security_updates
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, setting it once after the if-clause should work just fine (doesn't it?) and makes the code more bloated


if number_other_updates != 0:
if self.warn_on_any_update and status != CRITICAL:
Expand All @@ -374,10 +380,14 @@ class YumTester:

if number_other_updates == 1:
message += ". 1 Non-Security Update Available"
perfdata += " updates=1"
else:
message += ". %s Non-Security Updates Available" % number_other_updates
perfdata += " updates=%s" % number_other_updates
else:
perfdata += " updates=0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as above


return status, message
return status, message, perfdata


def vprint(self, threshold, message):
Expand Down Expand Up @@ -464,8 +474,8 @@ def main():
print "%s - Version %s\n" % (__title__, __version__)
sys.exit(OK)

result, output = tester.test_yum_updates()
end(result, output)
result, output, perfdata = tester.test_yum_updates()
end(result, output, perfdata)


if __name__ == "__main__":
Expand Down