-
Notifications
You must be signed in to change notification settings - Fork 12
WIP: Cleaning up the CLI mess stack #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
WIP: Cleaning up the CLI mess stack #97
Conversation
5c9dbb0
to
076ce72
Compare
This is ready for a review, but should not yet be merged. |
"""Return the script name without .py extension if any. This assumes that the script name does not contain a | ||
dot in case of lacking an extension. | ||
""" | ||
(name, _) = os.path.splitext(full_name) |
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.
use pathlib
|
||
import os | ||
import warnings | ||
from functools import wraps |
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.
what does this do?
NAGIOS_CACHE_FILENAME_TEMPLATE % (_script_name(sys.argv[0]),) | ||
) | ||
), | ||
'nagios-check-interval-threshold': ('threshold of nagios checks timing out', 'int', 'store', 0), |
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 still don't know what this does, thresholds are configured in icinga, not in checks.
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.
What do you mean? This has been in NagiosRepoerter for 12 years.
class NagiosReporter:
"""Reporting class for Nagios/Icinga reports.
Can cache the result in a gzipped JSON file and print the result out at some later point.
"""
def __init__(self, header, filename, threshold, nagios_username="nagios", world_readable=False):
"""Initialisation.
@type header: string
@type filename: string
@type threshold: positive integer
@param header: application specific part of the message, used to denote what program/script is using the
reporter.
@param filename: the filename of the gzipped JSON cache file
@param threshold: Seconds to determines how old the gzipped JSON data may be
before reporting an unknown result. This can be used to check if the script that uses the
reporter has run the last time and succeeded in writing the cache data. If the threshold <= 0,
this feature is not used.
See @param threshold
.
Set the log level | ||
""" | ||
if self.options.quiet: | ||
logging.basicConfig(level=logging.WARNING) |
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 see a mixture of fancylogger and regular logging, most of the time that does not work (e.g. one or the other get's lost.) has this been tested?
Convenience method that exists with nagios unknown exitcode | ||
""" | ||
exit_from_errorcode(3, msg) | ||
# def ok(self, msg): |
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.
why are these in comment?
@@ -408,30 +753,32 @@ def main(self): | |||
self.fulloptions.epilogue(f"{msg} complete", self.thresholds) | |||
|
|||
|
|||
@deprecated_class("Base your scripts on the CLIBase class instead") | |||
class NrpeCLI(CLI): |
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.
why are these deprecated?
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.
Because I want to switch to the new stack, obviously. It's not that they'll stop working, but I'd prefer no new scripts use these.
@itkovian as discussed, can we get an overview of what we are trying to achieve and the problems we are trying to solve? |
Move code to a new stack such that we can ditch a lot of obsolete code that was once introduced to deal with py 2.[47] shortcomings.
post
method