Skip to content
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

WIP: Cleaning up the CLI mess stack #97

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

itkovian
Copy link
Member

@itkovian itkovian commented Jan 7, 2025

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.

  • introduce mixins so derived classes can choose what features to use (timestamps, locks, nagios blah blah, ...)
  • allow moving to ConfigArgParse while keeping compatibility with existing code
  • fix the parsing of configfiles and spit into multiple arguments for ConfigArgParse
  • check if we need the post method
  • fix the nagios stats thing so I becomes usable in the new stack

@itkovian itkovian marked this pull request as draft January 7, 2025 15:31
@itkovian itkovian force-pushed the split-nrpe-convenience-methods branch from 5c9dbb0 to 076ce72 Compare January 16, 2025 14:36
@itkovian itkovian marked this pull request as ready for review January 16, 2025 14:38
@itkovian
Copy link
Member Author

This is ready for a review, but should not yet be merged.

@itkovian itkovian requested a review from wdpypere January 16, 2025 14:39
"""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)
Copy link
Contributor

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
Copy link
Contributor

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),
Copy link
Contributor

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.

'nagios-report': ('print out nagios information', None, 'store_true', False, 'n'),
'nagios-check-filename':
('filename of where the nagios check data is stored', 'str', 'store',
os.path.join(
Copy link
Contributor

Choose a reason for hiding this comment

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

use pathlib

Set the log level
"""
if self.options.quiet:
logging.basicConfig(level=logging.WARNING)
Copy link
Contributor

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):
Copy link
Contributor

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):
Copy link
Contributor

Choose a reason for hiding this comment

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

why are these deprecated?

@wdpypere
Copy link
Contributor

@itkovian as discussed, can we get an overview of what we are trying to achieve and the problems we are trying to solve?
That we we can define and agree on a scope and we can work on a coordinated effort?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants