NAME
Net::Nmsg::Output - Perl interface for nmsg outputs
SYNOPSIS
use Net::Nmsg::Input;
use Net::Nmsg::Output;
my $in = Net::Nmsg::Input->open('input.nmsg');
my $out = Net::Nmsg::Output->open('output.nmsg');
my $c = 0;
while (my $msg = <$in>) {
print "got message $c $msg\n";
$out->write($msg);
}
# alternatively:
my $cb = sub {
print "got message $c ", shift, "\n"
$out->write($msg);
};
$in->loop($cb);
DESCRIPTION
Net::Nmsg::Output provides the perl interface for the Net::Nmsg::XS::output extension.
CONSTRUCTORS
- open($spec, %options)
-
Creates and opens new output object. The output can be specified as a file name or handle, callback reference, or socket.
Available options:
- filter_vendor
- filter_msgtype
-
Restricts the output to messages of the given vendor and msgtype. Both are required if filtering is desired.
- source
- operator
- group
-
Set the source, operator, and group fields on outputs (nmsg only)
- buffered_io
-
Control whether or not the output socket is buffered (default: 1).
- zlibout
-
Enable or disable zlib compression of output (nmsg only)
- rate =item freq
-
Limit the payload output rate
- bufsz
-
Set the buffer size for the output (the default value is based on whether the output is a file or socket)
- endline
-
Set the line ending character for presentation outputs.
- open_nmsg($spec, %options)
-
Opens an output in nmsg format, as specified by file name, file handle, socket specification, or socket handle.
- open_pres($spec, %options)
-
Opens an output in presentation format, as specified by file name or file handle. The 'filter_vendor' and 'filter_msgtype' options are required.
- open_cb($callback)
-
Opens a callback output using the provided code reference. The callback will be invoked with a Net::Nmsg::Msg reference each time a message is 'written' to the output.
ACCESSORS
- set_msgtype($vendor, $msgtype)
- get_msgtype
- set_source($source)
- get_source()
- set_operator($operator)
- get_operator()
- set_group($group)
- get_group()
- set_rate($rate, $freq)
- get_rate()
- set_buffered_io($bool)
- get_buffered_io()
- set_zlibout($bool)
- get_zlibout()
- set_endline($eol)
- get_endline()
- get_bufsz()
METHODS
SEE ALSO
Net::Nmsg::IO, Net::Nmsg::Input, Net::Nmsg::Msg, nmsgtool(1)
AUTHOR
Matthew Sisk, <sisk@cert.org>
COPYRIGHT AND LICENSE
Copyright (C) 2010-2011 by Carnegie Mellon University
This program 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, under the terms pursuant to Version 2, June 1991.
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.