NAME
Net::NSCA::Client::ServerConfig - Specify configuration data for the remote NSCA server
VERSION
This documentation refers to version 0.009001
SYNOPSIS
use Net::NSCA::Client::ServerConfig;
# Specify the non-default server configuration
my $config = Net::NSCA::Client::ServerConfig->new(
max_hostname_length => 100,
max_description_length => 128,
max_pluginoutput_length => 3072, # 3 KiB!
);
# Create a new connection with the configuration
my $connection = Net::NSCA::Client::Connection->new(
remote_host => 'nagios.example.net',
server_config => $config,
);
# Create a new client with the configuration
my $nsca = Net::NSCA::Client->new(
remote_host => 'nagios.example.net',
server_config => $config,
);
# Data packets will adhere to the server configuration
$nsca->send_report(
hostname => 'web1.example.net',
service => 'MYSQL',
message => $plugin_output,
status => $Net::NSCA::Client::STATUS_OK,
);
DESCRIPTION
When NSCA is compiled, there are constants that define the size of the packets that will be generated and accepted. If NSCA was compiled with custom values for these constants, then this module will allow the client to generate corresponding packets.
CONSTRUCTOR
This is fully object-oriented, and as such before any method can be used, the constructor needs to be called to create an object to work with.
new
This will construct a new object.
- new(%attributes)
-
%attributes
is a HASH where the keys are attributes (specified in the "ATTRIBUTES" section). - new($attributes)
-
$attributes
is a HASHREF where the keys are attributes (specified in the "ATTRIBUTES" section).
ATTRIBUTES
# Get an attribute
my $value = $object->attribute_name;
initialization_vector_length
This specifies the byte length of the initialization vector in the initial packet as specified in the TRANSMITTED_IV_SIZE
constant in common.h.
max_description_length
This specifies the maximum description length in bytes as specified in the MAX_DESCRIPTION_LENGTH
constant in common.h.
max_hostname_length
This specifies the maximum host name length in bytes as specified in the MAX_HOSTNAME_LENGTH
constant in common.h.
max_service_message_length
This specifies the maximum service message (plugin output) length in bytes as specified in the MAX_PLUGINOUTPUT_LENGTH
constant in common.h.
METHODS
is_compatible_with
This takes another Net::NSCA::Client::ServerConfig instance and returns a Boolean specifying if the two server configurations are compatible with each other. This method is also accessible through an overloaded ==
and !=
.
pack_data_packet
This takes a HASHREF that specify the members of the C structure and the values to pack in each member. This will return a string that is the raw packed byte data.
pack_initial_packet
This takes a HASHREF that specify the members of the C structure and the values to pack in each member. This will return a string that is the raw packed byte data.
repack_data_packet
This takes the raw packet as the first argument and a HASHREF (as specified in "pack_data_packet") as the second argument. The first argument (the raw packet) may be a scalar reference and the packet will be modified in place. The new raw packet or the same scalar reference will be returned, based on if the first argument was a scalar reference or not.
# Repack by copying packet around
my $no_crc32 = $packer->repack_data_packet($raw_packet, {crc32_value => 0});
# Repack in place
$packer->repack_data_packet(\$raw_packet, {crc32_value => 0});
repack_initial_packet
This takes the raw packet as the first argument and a HASHREF (as specified in "pack_initial_packet") as the second argument. The first argument (the raw packet) may be a scalar reference and the packet will be modified in place. The new raw packet or the same scalar reference will be returned, based on if the first argument was a scalar reference or not. See "repack_data_packet" for usage examples.
unpack_data_packet
This takes the raw packet and returns a HASHREF of the C structure names and values. The raw packet may be given as a string or as a scalar reference.
unpack_initial_packet
This takes the raw packet and returns a HASHREF of the C structure names and values. The raw packet may be given as a string or as a scalar reference.
DEPENDENCIES
Convert::Binary::C 0.74
Moose 0.89
namespace::clean 0.04
AUTHOR
Douglas Christopher Wilson, <doug at somethingdoug.com>
BUGS AND LIMITATIONS
Please report any bugs or feature requests to bug-net-nsca-client at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-NSCA-Client. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
I highly encourage the submission of bugs and enhancements to my modules.
LICENSE AND COPYRIGHT
Copyright 2009 Douglas Christopher Wilson.
This program is free software; you can redistribute it and/or modify it under the terms of either:
the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or
the Artistic License version 2.0.