Laisser une note du shell de surveillance des messages
log-monitor.sh
#!/bin/bash
########################################################
#Shell de surveillance des messages de journal
#
########################################################
#---Réglage commun------------------------------
HOME=`dirname $0`
CONF=${HOME}/_conf
SHELLNAME=`basename $0`
#---Attribution de valeur initiale variable------------------------
MONITOR_FILE=/var/log/messages
RESULT_FILE=/var/log/messages.result
MATCH_FILE=${CONF}/match.list
EXCLUSTION_FILE=${CONF}/exclustion.list
#---Définition de la fonction interne--------------------------
_CHECK_ACTION () {
while IFS= read -r LINE
do
egrep -f ${MATCH_FILE} <(echo "${LINE}") \
| egrep -vf ${EXCLUSTION_FILE} >> ${RESULT_FILE}
done
}
#---Traitement principal---------------------------
#Processus de surveillance des messages
tail -n 0 -F ${MONITOR_FILE} | _CHECK_ACTION
exit
/etc/systemd/system/log-monitor.service
[Unit]
Description = Log Monitor File:/var/log/tstlog
[Service]
ExecStart = /path/to/file/log-monitor.sh
Restart = always
Type = simple
[Install]
WantedBy = multi-user.target
cmd.result
# systemctl enable log-monitor.service
# systemctl start log-monitor.service