This repository was archived by the owner on Jan 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
added perfdata #18
Open
dgoetz
wants to merge
1
commit into
calestyo:master
Choose a base branch
from
dgoetz:perfdata
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
added perfdata #18
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -332,17 +332,20 @@ class YumTester: | |
if number_updates == 0: | ||
status = OK | ||
message = "0 Updates Available" | ||
perfdata = "updates=0" | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just doing one |
||
|
||
return status, message | ||
return status, message, perfdata | ||
|
||
|
||
def test_security_updates(self): | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
@@ -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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
|
@@ -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__": | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.