/Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Nagios-Cmd/blib/lib/Nagios/Cmd/Read.pm


NAME

Nagios::Cmd


DESCRIPTION

A module for reading a fifo or regular file similar to the way Nagios does.


SYNOPSIS

 use Nagios::Cmd;
 use Nagios::Cmd::Read;
 use POSIX qw/mkfifo/;
 my $fifo = '/var/tmp/test.pipe';
 mkfifo( $fifo, 600 );
 my $writer = Nagios::Cmd->new( $fifo );
 my $reader = Nagios::Cmd::Read->new( $fifo );
 $writer->service_check('SSH', 'localhost', 0, 'version 1 waiting');
 print $reader->readcmd(), " was written to $fifo\n";


METHODS

new()
Pass in the name of a fifo to open and read from. The fifo must already exist.
 my $reader = Nagios::Cmd::Read->new( $fifo );

new_anyfile()
Same as new, but can be any type of file such as regular files or /dev/null.
 my $reader = Nagios::Cmd::Read->new_anyfile( '/tmp/commands.txt' );

readcmd()
Read a single command. Just like in Nagios, the filehandle is kept open for the duration of the program. If the target file is a regular file, sysseek() will be used to rewind to the top of the file (which may not be what you want).

To turn of seeking for regular files, call $object->seek(undef);.

seek()
Turn seek on/off. Default is off.
 $reader->seek(undef); # turn off seeking
 $reader->seek(1);     # turn it back on
 Nagios::Cmd::Read::seek(undef);

safe()
Turn use of flock() on/off. Setting it to a defined value will enable flock()ing of filehandles before reading. Setting to undef turns it off.
 $reader->lock(1);     # turn on use of flock() around reads
 $reader->lock(undef); # turn it off
 Nagios::Cmd::Read::lock(1);


AUTHOR

Al Tobey <tobeya@cpan.org>

 /Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Nagios-Cmd/blib/lib/Nagios/Cmd/Read.pm