Watching Multiple Logs

How swatch watches more than one log.

You will need a separate process for each log file that you want swatch to watch. Here is an example.

/tmp/swatch1.conf

# first configuration file:
watchfor /hello/
exec /usr/local/bin/monitor.chat.sh "<DOG1> Hello Test" 1>/dev/null 2>&1
threshold track_by=$1,type=limit,count=1,seconds=120

/tmp/swatch2.conf

# second configuration file:
watchfor /goodbye/
exec /usr/local/bin/monitor.chat.sh "<CAT1> Goodbye Test" 1>/dev/null 2>&1
threshold track_by=$1,type=limit,count=1,seconds=120

Make sure the two log file exist:

touch /var/log/test1.log
touch /var/log/test2.log

Start the two processes:

/usr/bin/swatch --daemon --config-file=/tmp/swatch1.conf --tail-file=/var/log/test1.log
/usr/bin/swatch --daemon --config-file=/tmp/swatch2.conf --tail-file=/var/log/test2.log

Test them:

echo "hello" >> /var/log/test1.log
echo "goodbye" >> /var/log/test2.log

Two logs were watched, and each one triggers an instant message.

Last modified November 10, 2020