-
Notifications
You must be signed in to change notification settings - Fork 12
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
add support for zabbix as alternative to nagios #81
base: master
Are you sure you want to change the base?
Conversation
@smoors can you add a unittest as well? also tests fail
|
@stdweird I think this is ready, can you have another look? |
lib/vsc/utils/nagios.py
Outdated
@@ -434,6 +438,11 @@ class SimpleNagios(NagiosResult): | |||
|
|||
def __init__(self, **kwargs): | |||
"""Initialise message and perfdata""" | |||
self._init(**kwargs) |
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.
don't do this please
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.
ok, removed
lib/vsc/utils/nagios.py
Outdated
@@ -434,6 +438,11 @@ class SimpleNagios(NagiosResult): | |||
|
|||
def __init__(self, **kwargs): | |||
"""Initialise message and perfdata""" | |||
self._init(**kwargs) | |||
|
|||
def _init(self, reporterclass=NagiosReporter, **kwargs): |
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 not use a class constant instead of passing the extra arg?
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.
that's indeed a simpler solution
fixed in 507804c
lib/vsc/utils/script_tools.py
Outdated
@@ -129,6 +131,7 @@ def __init__(self, options, run_prologue=True, excepthook=None, **kwargs): | |||
|
|||
self.nagios_reporter = None | |||
self.lockfile = None | |||
self.monitorclass = monitorclass |
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.
same as with the reporter, why not use a class constant?
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.
fixed in 507804c
|
||
|
||
def print_report_and_exit(self, timestamp, nagios_exit_code, nagios_exit_string, nagios_message): | ||
"""Print the nagios report (if the data is not too old) and exit""" |
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 do you not need/use the if/else logic? i would have expected that you only want to override the if block?
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.
for zabbix the if/else logic is skipped: we always report, even if the data is too old, and let zabbix handle that.
return json.dumps(processed_dict) | ||
|
||
|
||
class ExtendedSimpleOptionZabbix(ExtendedSimpleOption): |
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.
how do you use this in code? i see no easy way to pass this via commandline or config file
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.
we use this class directly like this:
opts = ExtendedSimpleOptionZabbix(options)
this similar to how it's used here: https://github.com/vub-hpc/Lmod-UGent/blob/master/run_lmod_cache.py
or did I miss something?
@stdweird to clarify, we have a script called
this is already working for us. can this be merged, or is there anything else that needs to be done? |
lib/vsc/utils/zabbix.py
Outdated
|
||
def print_report_and_exit(self, timestamp, nagios_exit_code, nagios_exit_string, nagios_message): | ||
"""Print the zabbix report and exit""" | ||
print('[%f, "%s", %s]' % (timestamp, nagios_exit_string, nagios_message)) |
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.
Let the json module do this? So we don't have to care about any special case?
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.
that's more complicated, because nagios_message
is already a json string, so then you have to first load it and then dump it again.
|
||
# -*- encoding: utf-8 -*- | ||
# | ||
# Copyright 2012-2022 Ghent University |
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.
# Copyright 2012-2022 Ghent University | |
# Copyright 2022-2022 Vrije Universiteit Brussel |
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.
And run find ./{lib,test} -type f -name '*.py' | REPO_BASE_DIR=$PWD xargs -I '{}' python -m vsc.install.headers '{}'
in the repo.
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.
this command reverts the change back to Ghent University
"""Print the zabbix report and exit""" | ||
print('[%f, "%s", %s]' % (timestamp, nagios_exit_string, nagios_message)) | ||
self.log.info("Zabbix check cache file %s contents delivered: %s", self.filename, nagios_message) | ||
sys.exit(nagios_exit_code) |
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.
for zabbix, we want a normal exit I think? Will the agent not fail if it's non-zero?
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.
from Ward:
Checking the exit code is removed from external checks, user parameters and system.run items. These checks will not to become unsupported if the exit code is different than zero. Exit code checks are now only performed in custom alert scripts, remote commands and user scripts executed on Zabbix server and proxy.
in de release notes van 3.4.3
dus this ok
No description provided.