2022-01-20 19:03:45 +05:30
|
|
|
#!/bin/sh
|
2022-05-21 19:13:12 +05:30
|
|
|
# shellcheck disable=SC1090
|
2022-01-20 19:03:45 +05:30
|
|
|
set -x
|
|
|
|
|
|
|
|
if [ x"${srcdir}" = x ]; then
|
|
|
|
srcdir=.
|
|
|
|
fi
|
|
|
|
. ${srcdir}/lib.sh
|
|
|
|
|
|
|
|
NOT1=${DIR}/${NM}-1.sh
|
|
|
|
NOT1STAMP=${DIR}/${NM}-1.stamp
|
|
|
|
NOT2=${DIR}/${NM}-2.sh
|
|
|
|
NOT2STAMP=${DIR}/${NM}-2.stamp
|
|
|
|
|
|
|
|
printf '#!/bin/sh -\necho script 1: $* > '${NOT1STAMP}'\n' > ${NOT1}
|
|
|
|
printf '#!/bin/sh -\necho script 2: $* > '${NOT2STAMP}'\n' > ${NOT2}
|
|
|
|
chmod 0755 ${NOT1} ${NOT2}
|
|
|
|
|
2022-03-12 21:51:43 +05:30
|
|
|
cat <<EOF > ${CONFD}/notifier.conf
|
|
|
|
notify ${NOT1}
|
2022-01-20 19:03:45 +05:30
|
|
|
# Match all log messages, store in RC5424 format and rotate every 1 KiB
|
|
|
|
*.* -${LOG} ;rotate=1k:2,RFC5424
|
|
|
|
notify ${NOT2}
|
|
|
|
EOF
|
|
|
|
|
2022-03-12 21:51:43 +05:30
|
|
|
setup
|
2022-01-20 19:03:45 +05:30
|
|
|
|
|
|
|
MSG=01234567890123456789012345678901234567890123456789
|
|
|
|
MSG=$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG
|
2022-05-21 19:13:12 +05:30
|
|
|
logger ${MSG}
|
|
|
|
logger 1${MSG}
|
|
|
|
logger 2${MSG}
|
2022-01-20 19:03:45 +05:30
|
|
|
|
2022-05-21 19:13:12 +05:30
|
|
|
if [ -f "${LOG}.0" ] &&
|
|
|
|
grep 'script 1' "${NOT1STAMP}" &&
|
|
|
|
grep 'script 2' "${NOT2STAMP}"; then
|
2022-03-12 21:51:43 +05:30
|
|
|
OK
|
2022-01-20 19:03:45 +05:30
|
|
|
else
|
2022-03-12 21:51:43 +05:30
|
|
|
FAIL 'Notifier did not run.'
|
2022-01-20 19:03:45 +05:30
|
|
|
fi
|