|
NAMEParse::Syslog - Parse Unix syslog filesSYNOPSISmy $parser = Parse::Syslog->new( '/var/log/syslog', year => 2001); while(my $sl = $parser->next) { ... access $sl->{timestamp|host|program|pid|text} ... } DESCRIPTIONUnix 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 new) and call next to get one line at a time with Unix-timestamp, host, program, pid and text returned in a hash-reference. Constructing a Parsernew requires as first argument a source from where to get the syslog lines. It can be:
After the file-name (or File::Tail object), you can specify options as a hash. The following options are defined:
Parsing the fileThe file is parse one line at a time by calling the next method, which returns a hash-reference containing the following keys:
BUGSThere 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. COPYRIGHTCopyright (c) 2001, Swiss Federal Institute of Technology, Zurich. All Rights Reserved.LICENSEThis module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.AUTHORDavid Schweikert <dws@ee.ethz.ch>HISTORY2001-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
Visit the GSP FreeBSD Man Page Interface. |