Skip to content

Commit

Permalink
Update mysql-logfile (#716)
Browse files Browse the repository at this point in the history
* Update mysql-logfile

State only UNKNOWN if the log is empty and wasn't set deliberately. If it was empty and set deliberately, state is OK, just the info that it seems to be rotated, so a user can check.

* mysql-logfile: Fix syntax error

---------

Co-authored-by: Markus Frei <[email protected]>
  • Loading branch information
dorkmaneuver and markuslf authored Sep 21, 2023
1 parent 5b1ad55 commit 6a39374
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions check-plugins/mysql-logfile/mysql-logfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
STATE_UNKNOWN, STATE_WARN)

__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
__version__ = '2023090801'
__version__ = '2023092101'

DESCRIPTION = """Checks MySQL/MariaDB log content the same way MySQLTuner does, but also
in case the DB is down."""
Expand Down Expand Up @@ -274,7 +274,10 @@ def main():
lib.base.oao(msg, STATE_WARN)
size = os.path.getsize(log_error)
if size == 0:
lib.base.oao('Empty log file `{}` found. Assuming log-rotation. Use `--server-log` for explicit file.'.format(log_error), STATE_OK)
if not args.SERVER_LOG:
lib.base.oao('Log file {} is empty. Assuming log-rotation. Use `--server-log` for explicit file.'.format(log_error), STATE_UNKNOWN)
else:
lib.base.oao('Log file {} is empty. `--server-log` is set explicitely, so assuming log-rotation.'.format(log_error), STATE_OK)
msg += 'Src: Log file {} (size: {}), '.format(
log_error,
lib.human.bytes2human(size),
Expand Down

0 comments on commit 6a39374

Please sign in to comment.