2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

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.
This commit is contained in:
Thomas Riccardi 2018-04-29 00:58:41 +02:00
parent e178be6432
commit cdb82255e9

View File

@ -25,7 +25,7 @@ The following environment variables are used by this plugin:
If the "logfile" environment variable is set to "journald" the sshd If the "logfile" environment variable is set to "journald" the sshd
logs are read from journald, filtering on program "sshd". The filtering 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: 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] [sshd_log]
group systemd-journal group systemd-journal
env.logfile journald env.logfile journald
env.journalctlarg --unit=sshd.service env.journalctlargs --unit=sshd.service
=head1 MAGIC MARKERS =head1 MAGIC MARKERS
@ -70,15 +70,16 @@ Revision 1.0 2009/04/22 22:00:00 zlati
LOG=${logfile:-/var/log/secure} LOG=${logfile:-/var/log/secure}
JOURNALCTL_ARG=${journalctlarg:-_COMM=sshd} JOURNALCTL_ARGS=${journalctlargs:-_COMM=sshd}
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ "$LOG" = "journald" ]; 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" echo "yes"
else else
echo "no (journald empty log for '$JOURNALCTL_ARG' not found)" echo "no (journald empty log for '$JOURNALCTL_ARGS' not found)"
fi fi
else else
if [ -r "$LOG" ]; then if [ -r "$LOG" ]; then
@ -151,7 +152,8 @@ else
fi fi
if [ "$LOG" = "journald" ]; then 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 else
cat "$LOG" cat "$LOG"
fi | \ fi | \