The
8.7.3. What About...
8.7.3.1. ...sending log messages to a program?
The standard Fedora
This example emails log messages to a pager or cell phone text service:
#!/bin/bash
DESTINATION=
tail -0f /var/log/messages|
while read LINE
do
echo $LINE|
mail $DESTINATION
done
To use this script, place it in the file /
# chmod u+rx /usr/local/bin/log-mail
# log-mail
You may want to use this script with a lower-volume logfile than
To filter messages by content, place a
You can also have log output read to you over the system's speakers:
#!/bin/bash
logger -t log-speak 'Starting log reading.'
sleep 0.3
tail -1f /var/log/messages|
while read LINE
do
# The sed expressions remove the date/time and PIDs
# from messages to shorten the text.
echo $LINE|
sed -e 's/^.{17}[^ ]*//'
-e 's/[.*]//g'|
festival --tts
done
8.7.3.2. ...outputting to a named pipe?
A named pipe is a special type of file that can be used to pass messages between two programs. While
To output to a named pipe, you must first disable SELinux protection for
# setsebool -P syslogd_disable_trans=1
# mkfifo
Next, create an entry in
*.* |/var/log/messagepipe
Restart
# service syslog restart
Shutting down kernel logger: [ OK ]
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]
# cat
...(Messages appear as they are logged)...
8.7.3.3. ...logging messages from printers, routers, and other network devices?
Most network hardware offers the option of logging messages to a
8.7.3.4. ...using patterns within the message text to determine message routing?
The
The original