Andreas Marschke > Nagios-NRPE-0.003 > Nagios::NRPE::Packet

Download:
Nagios-NRPE-0.003.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.003   Source  

NAME ^

Nagios::NRPE::Packet - Assembly and de-assembly of an NRPE packet

SYNOPSIS ^

 use IO::Socket;
 use IO::Socket::INET;
 # Import necessary constants into Namespace
 use Nagios::NRPE::Packet qw(NRPE_PACKET_VERSION_2
                             NRPE_PACKET_QUERY
                             MAX_PACKETBUFFER_LENGTH
                             STATE_UNKNOWN
                             STATE_CRITICAL
                             STATE_WARNING
                             STATE_OK);

 my $packet = Nagios::NRPE::Packet->new();

 my $socket = IO::Socket::INET->new(
                    PeerAddr => $host,
                    PeerPort => $port,
                    Proto    => 'tcp',
                    Type     => SOCK_STREAM) or die "ERROR: $@ \n";

 print $socket $packet->assemble(type => QUERY_PACKET,
                              buffer => "check_load 1 2 3",
                              version => NRPE_PACKET_VERSION_2 );

 my $data = <$socket>
 my $response = $packet->deassemble($data);

 print $response->{buffer};

DESCRIPTION ^

This class is meant to be used when an active connection exists and is ready to send the packet.

CONSTRUCTION ^

new

Takes the following options as a hashref

FUNCTIONS ^

Following functions can be used after the creation of the packet

CONSTANTS ^

These constants can be exported upon request with the 'use' pragma like this:

 # Will only import the constant NRPE_PACKET_VERSION_2 into your namespace
 use Nagios::NRPE::Packet qw(NRPE_PACKET_VERSION_2);

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Andreas Marschke <andreas.marschke@googlemail.com>.

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

crc32

Checksumming for the packet. Necessary for sending a valid Packet.

packet_dump

Debugging function for hexdumping a binary string.

syntax highlighting: