-
Notifications
You must be signed in to change notification settings - Fork 8
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
change message and state when logfile is not found #37
base: master
Are you sure you want to change the base?
Conversation
oh... travisCI errors. [python 2.6]
[python 2.7 ~ ]
|
I fixed the issue #38 which Travis CI failed. |
thanks. travis-ci check was ok. |
@kurneko Thanks for PR. "If log file does not exist, return OK" is expected behavior. |
Thank you for checking
OK. Add |
check_log_ng.py
Outdated
@@ -613,6 +613,10 @@ def _check_log(self, logfile, seekfile): | |||
_debug("logfile='{0}', seekfile='{1}'".format(logfile, seekfile)) | |||
logfile = LogChecker.to_unicode(logfile) | |||
if not os.path.exists(logfile): | |||
# if set error_no_exist, return UNKNOWN. | |||
if self.config['error_no_exist']: | |||
self.message = "UNKNOWN: Logfile is not found." |
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 it's better to contain logfile path in output.
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. I modified to display logfile path.
check_log_ng.py
Outdated
|
||
# if set error_no_exist, return UNKNOWN. | ||
if self.config['error_no_exist'] and log_exist == False: | ||
self.message = "UNKNOWN: Logfile is not found." |
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 it's better to contain logfile path in output.
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. I modified to display logfile path.
check_log_ng.py
Outdated
@@ -696,6 +702,11 @@ def _check_log_multi(self, logfile_pattern, remove_seekfile=False, tag=''): | |||
self._remove_old_seekfile_with_inode(logfile_pattern, tag) | |||
else: | |||
self._remove_old_seekfile(logfile_pattern, tag) | |||
|
|||
# if set error_no_exist, return UNKNOWN. | |||
if self.config['error_no_exist'] and log_exist == False: |
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 == False
( and == True
) is not good expression.
and not log_exist
is better.
In this context, I think the log_exist
variable is unnecessary, "and not logfile_list
" is enough.
( Evaluation of "list" returns false
if len(list) == 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.
log_exist is removed. and use len(logfile_list) == 0
check_log_ng.py
Outdated
action="store_true", | ||
dest="error_no_exist", | ||
default=False, | ||
help=("If file not exist, return UNKNOWN error.") |
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 we should use one of "not found" or "not exist" in all messages.
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. Use only "not exist".
The variable name |
I think the option name |
The variable "log_exist" has been removed. |
You’re right. Change "--error-no-exist" to "--error-logfile-not-exist". |
This looks good. |
If logfile is not found. This plugin return "OK - No matches found.".
I worry about if I wrong name in --logfile option. i will not notice it.
In check_log3.pl, if can not read logfile, return error.
https://github.com/pmcaulay/nagios-plugins/blob/master/check_log3.pl#L921-L934
** Proposal
If logfile is not found. Return code UNKNOWN, And message 「UNKNOWN: Logfile is not found.」