.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "Syslog 3pm" .TH Syslog 3pm 2025-09-28 "Lire 2.1.1" "LogReport's Lire Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Lire::Syslog \- syslog style lines parser .SH SYNOPSIS .IX Header "SYNOPSIS" use Lire::Syslog; .PP my \f(CW$parser\fR = new Lire::Syslog; .PP my \f(CW$rec\fR = \f(CW$parser\fR\->parse( \f(CW$line\fR ); .SH DESCRIPTION .IX Header "DESCRIPTION" This module defines objects able to parse logs coming from several flavours of logging daemon. .PP It currently supports the following syslog file formats: .IP "Classic BSD syslog daemon" 4 .IX Item "Classic BSD syslog daemon" The "classic" BSD syslog format: .Sp .Vb 1 \& MMM DD HH:MM:SS Hostname Message .Ve .IP "Solaris 8 syslog daemon" 4 .IX Item "Solaris 8 syslog daemon" The Solaris 8 syslog daemon also includes the facility and level: .Sp .Vb 1 \& MMM DD HH:MM:SS Hostname Process[Pid]: [ID DDDDDD Facility.Level] Message .Ve .IP "Netscape Messaging Server logging daemon" 4 .IX Item "Netscape Messaging Server logging daemon" The syslog daemon that comes with Netscape Messaging Server uses a date in common log format: .Sp .Vb 1 \& [DD/MMM/YYYY:HH:MM:SS +ZZZZ] Hostname Process[Pid]: Facility Level: Message .Ve .IP "WebTrends syslog daemon" 4 .IX Item "WebTrends syslog daemon" The format used by the syslog daemon that comes with WebTrends: .Sp .Vb 1 \& WTsyslog[YYYY\-MM\-DD HH:MM:SS ip=HOSTNAME pri=WT_PRIORITY] Message .Ve .IP "Kiwi Syslog (ISO date format)" 4 .IX Item "Kiwi Syslog (ISO date format)" The ISO log file formats used by the Kiwi Syslog daemon (http://www.kiwisyslog.com/info_sysd.htm), a logging daemon often encountered on Win32 platforms: .Sp .Vb 1 \& YYYY\-MM\-DD HH:MM:SS [TAB] Facility.Level [TAB] Hostname [TAB] Message .Ve .IP "Kiwi Syslog (US date format)" 4 .IX Item "Kiwi Syslog (US date format)" The US date format used by the Kiwi Syslog daemon: .Sp .Vb 1 \& MM\-DD\-YYYY HH:MM:SS [TAB] Facility.Level [TAB] Hostname [TAB] Message .Ve .IP "Kiwi Syslog (DD\-MM\-YYY date format)" 4 .IX Item "Kiwi Syslog (DD-MM-YYY date format)" The DD\-MM\-YYYY date format used by the Kiwi Syslog daemon: .Sp .Vb 1 \& DD\-MM\-YYYY HH:MM:SS [TAB] Facility.Level [TAB] Hostname [TAB] Message .Ve .IP "Sendmail Switch logging daemon" 4 .IX Item "Sendmail Switch logging daemon" The format used by the logging daemon coming with Sendmail Switch on Win32 platforms: .Sp .Vb 1 \& MM/DD/YY HH:MM:SS Process(Pid): Level: Message .Ve .IP "RFC 3164\-compliant Syslog daemon" 4 .IX Item "RFC 3164-compliant Syslog daemon" A format from RFC 3164\-compliant Syslog daemons which includes the encoded priority and the year in the date. RFC 3164 defines the "BSD Syslog Protocol". .Sp .Vb 1 \& MMM DD YYYY HH:MM:SS: Process[Pid]: Message .Ve .PP The first time the \fBparse()\fR method is used, the parser will try each of the supported formats to detect the syslog format. If no format matches, the module will call \fBlr_err()\fR and abort the program. Each other \fBparse()\fR invocation will use the same format. .PP The \fBparse()\fR method will return an hash reference which contains the following keys: .IP timestamp 4 .IX Item "timestamp" The timestamp of the event. .IP hostname 4 .IX Item "hostname" The name or IP address of the host that sended the message. .IP process 4 .IX Item "process" The "process" that logged the event. Formally, the syslog message doesn\*(Aqt contain a process field but its usually the first word coming before a colon in the message\*(Aqs content. .IP pid 4 .IX Item "pid" The PID of the process that logged the event. This is usually what is between [] in the process part of the message. .IP identifier 4 .IX Item "identifier" This key is only present when the log comes from a Solaris 8 syslog daemon. It contains the identifier that comes after ID in the message. .IP facility 4 .IX Item "facility" The syslog facility (kern, mail, local0, etc.) of the message. This isn\*(Aqt supported in all file formats so this key might be unavailable. .IP level 4 .IX Item "level" The syslog level (emerg, info, notice, etc. ) of the message. This isn\*(Aqt supported in all file formats so this key might be unavailable. .IP content 4 .IX Item "content" The actual syslog message (with the process and pid removed). Many network devices will also have another BSD\-style timestamp at the beginning of the message. If present, it will also be removed. .SH USAGE .IX Header "USAGE" .Vb 1 \& package Lire::Foo; \& \& use base qw/ Lire::Syslog /; \& \& sub parse { \& my $self = shift; \& my $line = shift; \& \& # this runs parse from Lire::Syslog, setting keys like \*(Aqday\*(Aq, \*(Aqprocess\*(Aq \& # and \*(Aqhostname\*(Aq \& my $rec = $self\->SUPER::parse($line); \& \& $rec\->{\*(Aqfoo\*(Aq} = dosomethingwith( $rec\->{\*(Aqcontent\*(Aq} ); \& \& return $rec \& } .Ve .PP Now, one can run in a script .PP .Vb 1 \& my $parser = new Lire::Foo(); \& \& while ( <> ) { \& chomp; \& my $log = $parser\->parse( $line ); \& } .Ve .PP which sets \f(CW$log\fR\->{\*(Aqday\*(Aq}, ... \f(CW$log\fR\->{\*(Aqprocess\*(Aq} and \f(CW$log\fR\->{\*(Aqfoo\*(Aq}. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBLire::Email\fR\|(3) .SH AUTHORS .IX Header "AUTHORS" .Vb 1 \& Joost van Baal, Francis J. Lacoste. Initial idea by Joost Kooij .Ve .SH VERSION .IX Header "VERSION" \&\f(CW$Id:\fR Syslog.pm,v 1.15 2006/07/23 13:16:30 vanbaal Exp $ .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright (C) 2000\-2002 Stichting LogReport Foundation LogReport@LogReport.org .PP This file is part of Lire. .PP Lire is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .PP This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. .PP You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html.