$ logdo -w 1800 -s 'mailx foo@example.com' ' sshd' /var/log/secure.log
logdo - watch logfiles and execute commands with selective log output
logdo {[-w wait] [-n nlines] [-s script] [-v vregex] regex filename}..
logdo {[-w wait] [-n nlines] [-s script] [-v vregex] regex filename}.. -C config [-q]
logdo [OPTIONS] -c config
logdo(1) watches the logfile filename and executes the command script which inputs the pipe from log output lines matching with the regular expression regex every wait seconds.
The several sets of normal OPTIONS, the arguments regex and filename are concurrently managed.
Set the delay between executions of the command to <wait> seconds. The default value is 1 second.
Set the number of past lines to be process. The default value is 0.
Set the command which inputs the pipe from added log. For example, setting cat as <script> prints added log to standard output.
Set the regular expression vregex with matching lines not to be process in log outputs.
Set the <config> file which saves the sets of options, arguments regex and filename.
Quit in parsing options. Use it if you want to save config file which is generated from options and arguments without watching logfiles.
Set the <config> file which is saved the sets of wait, script, vregex, regex and filename, which are concurrently executed.
Set the regular expression regex with matching lines to be process in log outputs.
Set the logfile filename.
logdo exits 0 on success, and !0 if an error occurs.
If you watch /var/log/secure.log matching ' sshd' lines every 30 minutes, typing the following command line mails such lines to foo@example.com by the 'mailx' utility.
$ logdo -w 1800 -s 'mailx foo@example.com' ' sshd' /var/log/secure.log
Additionally if you watch /var/log/git-daemon.log matching 'Connection from ' and not matching '(127\.0\.0\.1|192\.168\.)' lines every 24 hours, typing the following command line mails such lines to foo@example.com likewise.
$ logdo -w 1800 -s 'mailx foo@example.com' ' sshd' /var/log/secure.log \ -w 86400 -s 'mailx foo@example.com' -v '(127\.0\.0\.1|192\.168\.)' 'Connection from ' /var/log/git-daemon.log
As mentioned above you may specify the several sets of a logfile to be watch and its characteristics, but it is too long to type in a line.
Now you may save the sets of such a command line to logdo.xml with '-C logdo.xml -q' without watching logfiles as follows:
$ logdo -w 1800 -s 'mailx foo@example.com' ' sshd' /var/log/secure.log \ -w 86400 -s 'mailx foo@example.com' -v '(127\.0\.0\.1|192\.168\.)' 'Connection from ' /var/log/git-daemon.log \ -C logdo.xml -q
Then you may specify the equal sets with such a command line by '-c logdo.xml' option as follows:
$ logdo -c logdo.xml
Taiji Yamada <taiji@aihara.co.jp>
Copyright (C) 2009 Taiji Yamada. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3) or (at your option) any later version.