GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PARSE::SYSLOG (3)

.ds Aq ’

NAME

Parse::Syslog - Parse Unix syslog files

CONTENTS

SYNOPSIS



 my $parser = Parse::Syslog->new( /var/log/syslog, year => 2001);
 while(my $sl = $parser->next) {
     ... access $sl->{timestamp|host|program|pid|text} ...
 }



DESCRIPTION

Unix syslogs are convenient to read for humans but because of small differences between operating systems and things like ’last message repeated xx times’ not very easy to parse by a script.

Parse::Syslog presents a simple interface to parse syslog files: you create a parser on a file (with <B>newB>) and call <B>nextB> to get one line at a time with Unix-timestamp, host, program, pid and text returned in a hash-reference.

    Constructing a Parser

<B>newB> requires as first argument a source from where to get the syslog lines. It can be:
o a file-name for the syslog-file to be parsed.
o an IO::Handle object.
o a File::Tail object as first argument, in which case the read method will be called to get lines to process.
After the file-name (or File::Tail object), you can specify options as a hash. The following options are defined:
<B>typeB> Format of the syslog file. Can be one of:
syslog Traditional syslog (default)
metalog Metalog (see http://metalog.sourceforge.net/)
<B>yearB> Syslog files usually do store the time of the event without year. With this option you can specify the start-year of this log. If not specified, it will be set to the current year.
<B>GMTB> If this option is set, the time in the syslog will be converted assuming it is GMT time instead of local time.
<B>repeatB> Parse::Syslog will by default repeat xx times events that are followed by messages like ’last message repeated xx times’. If you set this option to false, it won’t do that.
<B>arrayrefB> If this option is true, next will return an array-ref instead of a hash-ref (and is thus a bit faster), with the following contents:
0: timestamp
1: host
2: program
3: pid
4: text
<B>localeB> Optional. Specifies an additional locale name or the array of locale names for the parsing of log files with national characters.
<B>allow_futureB> If true will allow for timestamps in the future. Otherwise timestamps of one day in the future and more will not be returned (as a safety measure against wrong configurations, bogus --year arguments, etc.)

    Parsing the file

The file is parse one line at a time by calling the <B>nextB> method, which returns a hash-reference containing the following keys:
<B>timestampB> Unix timestamp for the event.
<B>hostB> Host-name where the event did happen.
<B>programB> Program-name of the program that generated the event.
<B>pidB> PID of the Program that generated the event. This information is not always available for every operating system.
<B>textB> Text description of the event.
<B>msgidB> Message numeric identifier, available only on Solaris >= 8 with message ID generation enabled".
<B>facilityB> Log facility name, available only on Solaris >= 8 with message ID generation enabled".
<B>levelB> Log level, available only on Solaris >= 8 with message ID generation enabled".

    BUGS

There are many small differences in the syslog syntax between operating systems. This module has been tested for syslog files produced by the following operating systems:



    Debian GNU/Linux 2.4 (sid)
    Solaris 2.6
    Solaris 8



Report problems for these and other operating systems to the author.

COPYRIGHT

Copyright (c) 2001, Swiss Federal Institute of Technology, Zurich. All Rights Reserved.

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

David Schweikert <dws@ee.ethz.ch>

HISTORY



 2001-08-12 ds 0.01 first version
 2001-08-19 ds 0.02 fix last message repeated xx times, Solaris 8 problems
 2001-08-20 ds 0.03 implemented GMT option, year specification, File::Tail
 2001-10-31 ds 0.04 faster time parsing, implemented arrayref option, better time-increment algorithm
 2002-01-29 ds 0.05 ignore -- MARK -- lines, low-case months, space in program names
 2002-05-02 ds 1.00 HP-UX fixes, parse above message repeats xx times
 2002-05-25 ds 1.01 added support for localized month names (uchum@mail.ru)
 2002-10-28 ds 1.02 fix off-by-one-hour error when running during daylight saving time switch
 2004-01-19 ds 1.03 do not allow future dates (if allow_future is not true)
 2004-07-11 ds 1.04 added support for type metalog
 2005-12-24 ds 1.05 allow passing of a IO::Handle object to new



Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PARSE::SYSLOG (3) 2007-12-30

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.