From cdb82255e9151f42176d36da1d7817bf83d51b81 Mon Sep 17 00:00:00 2001 From: Thomas Riccardi Date: Sun, 29 Apr 2018 00:58:41 +0200 Subject: [PATCH] sshd_log: allow multiple journalctl args Useful for multiple filtering. At the cost of not being able to pass spaces properly in args, but that's uncommon. --- plugins/ssh/sshd_log | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/ssh/sshd_log b/plugins/ssh/sshd_log index 3c38af1c..5026d607 100755 --- a/plugins/ssh/sshd_log +++ b/plugins/ssh/sshd_log @@ -25,7 +25,7 @@ The following environment variables are used by this plugin: If the "logfile" environment variable is set to "journald" the sshd logs are read from journald, filtering on program "sshd". The filtering -may be changed using "journalctlarg". +may be changed using "journalctlargs". Config examples for /etc/munin/plugin-conf.d/munin-node: @@ -46,7 +46,7 @@ Config example with journald on the sshd.service unit only: [sshd_log] group systemd-journal env.logfile journald - env.journalctlarg --unit=sshd.service + env.journalctlargs --unit=sshd.service =head1 MAGIC MARKERS @@ -70,15 +70,16 @@ Revision 1.0 2009/04/22 22:00:00 zlati LOG=${logfile:-/var/log/secure} -JOURNALCTL_ARG=${journalctlarg:-_COMM=sshd} +JOURNALCTL_ARGS=${journalctlargs:-_COMM=sshd} if [ "$1" = "autoconf" ]; then if [ "$LOG" = "journald" ]; then - if journalctl --no-pager --quiet --lines=1 "$JOURNALCTL_ARG" | read -r DUMMY; then + # shellcheck disable=SC2086,SC2034 + if journalctl --no-pager --quiet --lines=1 $JOURNALCTL_ARGS | read -r DUMMY; then echo "yes" else - echo "no (journald empty log for '$JOURNALCTL_ARG' not found)" + echo "no (journald empty log for '$JOURNALCTL_ARGS' not found)" fi else if [ -r "$LOG" ]; then @@ -151,7 +152,8 @@ else fi if [ "$LOG" = "journald" ]; then - journalctl --no-pager --quiet --show-cursor ${CURSOR:+"--after-cursor=$CURSOR"} "$JOURNALCTL_ARG" + # shellcheck disable=SC2086 + journalctl --no-pager --quiet --show-cursor ${CURSOR:+"--after-cursor=$CURSOR"} $JOURNALCTL_ARGS else cat "$LOG" fi | \