|
NAMEfetchlog - fetch and convert new messages of a logfileSYNOPSISfetchlog -f first:last:len:conv logfile bookmarkfile [ pattern .. ]fetchlog -F first:last:len:conv logfile bookmarkfile [ pattern .. ] fetchlog [-h|-V] DESCRIPTIONThe fetchlog utility displays the last new messages of a logfile. It is similar like tail(1) but offers some extra functionality for output formatting. 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 logfile and collects all messages, optionally only those matching any of the given regex-style 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 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', if that file does not exist '.1', then upto '.9' to logfile when scanning in rotated logfiles. Scanning stops without error when a rotated logfile does not exist. OPTIONS
MULTIPLE FETCHINGFetching the same logfile with different bookmarks works without problem. Simultanously fetching with option -F (update mode) using the same bookmark file works too, but unpredictable results will occur. For safety reasons bookmarkfile will never be opened for writing directly, instead a temporary file will be used and renamed to bookmarkfile when writing has finished.PERFORMANCEBefore opening logfiles for scanning fetchlog first checks the modification time of logfile and compares this time with the modification time stored in bookmarkfile. If both timestamps are the same then fetchlog exits with 0 (no messages). Otherwise the logfile(s) get mapped to memory step by step and are scanned backwards line by line until one of the end conditions become true. fetchlog uses the logfiles inode to distinguish different logs.NAGIOSfetchlog may be used as a local plugin for the Nagios network monitoring system to monitor a local logfile. It follows the calling convention for Nagios plugins if at least conversions on are set and len is 'short' enough for Nagios (330 prior to Nagios 3, 4000 since Nagios 3). It is recommended to use conversion s also because shell metacharacters in fetched messages may confuse Nagios' notification system.Nagios 3 introduces a new interface for plugins sending out multiline output as fetchlog does. Even with conversion 'n' Nagios reads this as a multiline message. To be compatible with Nagios 3 plugin format enable conversion '3' also. Output format is then: SHORT_MESSAGE|\nMESSAGE_LINE_1\n...\nMESSAGE_LINE_N where SHORT_MESSAGE will be the last line fetched MESSAGE_LINE_N. Please see README.Nagios for details. When using fetchlog as a local plugin for Nagios then exit status is as follows:
Nagios can monitor remote logfiles together with NET-SNMP and fetchlog using the check-snmp plugin. Please read the README files coming with fetchlog how to setup this. SNMPThe motivation for fetchlog was to create a helper tool for NET-SNMP's snmpd to enable monitoring of remote kernel syslogs using SNMP. If configured properly, snmpd replies to a specific SNMP request with the output of an external helper program. With fetchlog using update mode -F and conversions on one can peek at a remote syslog file and gets either 'OK: no messages' or one line with the new syslog messages appeared since the last SNMP request.Because of some limitiations of SNMP itself and the monitoring applications using SNMP, the length of the SNMP reply must not exceed a specific size. To ease the integration of SNMP in monitoring software it is useful to have the SNMP reply only consist of a single line of text rather than multiple lines. COMPRESSING OUTPUTThe syslog messages fetched can be compressed by increasing first to skip the timestamp and host entry from syslog. Lowering last gives even more compression for long syslog lines. As a result one gets a very short message that gives an idea of what is going wrong.DIAGNOSTICSfetchlog sends all output and error messages to stdout. Exit codes:
Note: Since version 0.93 the meanings of exit code 1 and 2 have been exchanged. AUTHORAlexander Haderer, LoeScap Technology GmbH, Berlin - GermanySEE ALSOtail(1), cat(1), head(1), sed(1), re_format(7), syslogd(8), newsyslog(8)NET-SNMP - Various tools relating to the Simple Network Management
Protocol SNMP (NET-SNMP: formerly known as UCD-SNMP)
Nagios - A Network monitoring system
Nagios Plugins - Plugins for Nagios
fetchlog homepage - download, support and bugtracking
BUGSBookmarkfiles are not portable across plattforms or fetchlog versions.Logfiles are expected not to shrink. fetchlog does not work with compressed logfiles. Fetching when logfile rotation takes place may result in some messages to appear twice. If an regex error occurs during pattern matching this error is silently ignored and will be handled as non-match. LEGALNagios is a registered trademark of Ethan Galstad.
Visit the GSP FreeBSD Man Page Interface. |