Skip to content

Commit

Permalink
mysql-logfile: Adapt to MySQLTuner v2.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
markuslf committed Sep 8, 2023
1 parent 13dd282 commit 7c48d79
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions check-plugins/mysql-logfile/mysql-logfile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def main():
"""The main function. Hier spielt die Musik.
"""

# logic taken from mysqltuner.pl:log_file_recommendations(), v1.9.8
# logic taken from mysqltuner.pl:log_file_recommendations(), v2.2.8
# including variable names

# parse the command line, exit with UNKNOWN if it fails
Expand Down Expand Up @@ -243,19 +243,23 @@ def main():
perfdata = ''

if log_error == 'stderr':
lib.base.cu('log_error is set to STDERR, so this check can\'t read it.')
lib.base.cu('log_error is set to STDERR, so this check can\'t read stderr.')

match = re.search(r'^(docker|podman|kubectl):(.*)', log_error)
if match:
cmd = "{} logs --tail={} '{}'".format(match.group(1).strip(), MAXLINES, match.group(2).strip())
cmd = "{} logs --tail={} '{}'".format(
match.group(1).strip(),
MAXLINES,
match.group(2).strip(),
)
logfile, stderr, retc = lib.base.coe(lib.shell.shell_exec(cmd))
if retc != 0:
lib.base.cu('{} exited with error ({}, {}).'.format(cmd, retc, stderr.strip()))
msg += 'Src: {}, '.format(log_error)

match = re.search(r'^systemd:(.*)', log_error)
if match:
cmd = "journalctl -n {} -b -u '{}'".format(MAXLINES, match.group(1).strip())
cmd = "journalctl --lines {} --boot --unit '{}'".format(MAXLINES, match.group(1).strip())
logfile, stderr, retc = lib.base.coe(lib.shell.shell_exec(cmd))
if retc != 0:
lib.base.cu('`{}` exited with error ({}, {}).'.format(cmd, retc, stderr.strip()))
Expand All @@ -279,7 +283,7 @@ def main():
if size >= 32 * 1024 * 1024:
size_state = STATE_WARN
state = lib.base.get_worst(state, size_state)
msg += 'bigger than 32 MiB{} (you should analyze why or implement a rotation log), '.format(
msg += 'bigger than 32 MiB{} (you should analyze why or implement a rotation log strategy such as logrotate), '.format(
lib.base.state2str(size_state, prefix=' '),
)
logfile = lib.base.coe(lib.disk.read_file(log_error))
Expand Down

0 comments on commit 7c48d79

Please sign in to comment.