fetchlog

Fetch new logfile messages
Download

fetchlog Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Alexander Haderer
  • Publisher web site:
  • http://search.cpan.org/~afrika/DBIx-FileSystem-1.7/FileSystem.pm

fetchlog Tags


fetchlog Description

Fetch new logfile messages The fetchlog utility displays the last new messages of a logfile. It is similar like tail but offers some extra functionality for output formatting and message filtering using extended regular expressions for pattern matching. To show only the new messages appeared since the last call fetchlog uses a bookmark to remember which messages have been fetched.fetchlog scans backwards a logfile and collects all messages, optionally only those matching any of the given regular expression patterns. Then fetchlog converts found message lines for output. It stops scanning when one of these conditions become true: The bookmark from bookmarkfile is reached, or more than len characters are ready for output, or an error occurs. fetchlog knows about rotated and uncompressed logfiles and continues scanning in rotated logfiles by appending '.0', '.1' upto '.9' to logfile when scanning in rotated logfiles. Scanning stops without error when a rotated logfile does not exist.fetchlog may be used as a local plugin for the Nagios (formerly Netsaint) network monitoring system to monitor a local logfile. It follows the calling convention for Nagios plugins when conversion is set at least to 'no' and len is short enough for Nagios.fetchlog can be used to watch/monitor remote logfiles: * With NET-SNMP to look into remote logfiles via SNMP. The package contains a README that shows how to setup this. * Nagios together with NET-SNMP and fetchlog using the check-snmp plugin. The package contains a README that shows how to setup this. * Nagios together with Nagios Remote Plugin Executor NRPG to let Nagios execute plugins on a remote host. * Nagios together with Nagios Service Check Acceptor NSCA. to make Nagios accept passive service checks send by the client via the send_nsca command.ExampleTo send out an email containing the messages appeared within the last 60 minutes in /var/log/messages, regarding the 'bubbled', create a shell script similar like this: #!/bin/sh HOST=`hostname` FETCHLOG="/usr/local/bin/fetchlog -F 1:80:1000:s" MSG=`$FETCHLOG /var/log/messages /tmp/msgbm 'bubbled'` if ; then echo -e "$MSG" | \ /usr/bin/mail -s "SYSLOG: $HOST" admin@your.domain fiand add an entry in the crontab: 0 * * * * /path/to/shellscript >/dev/null 2>&1 It is not necessary to run the cronjob as root if /var/log/messages is readable for other users.What it does: If fetchlog detects new messages in /var/log/messages it collects all new message lines containing 'bubbled', from column 1 upto column 80, at most 1000 character, removes critical shell metacharacters and exits with 2. The collected messages are then send via email to the admin.Other ExampleA tail -f thing that beeps whenever there is something with device0..3 or the sun is going down: #!/bin/sh FETCHLOG="/usr/local/bin/fetchlog -F 1:100:1000:" while true; do MSG=`$FETCHLOG /var/log/messages /tmp/msgbm 'device' 'sun.*down'` if ; then echo -e "$MSG" echo ^G; sleep 1; echo ^G fi sleep 5 done


fetchlog Related Software