Nagios::Plugin::OverHTTP::Formatter::Nagios::Version2 - Format output for


Nagios-Plugin-OverHTTP documentation Contained in the Nagios-Plugin-OverHTTP distribution.

Index


Code Index:

NAME

Top

Nagios::Plugin::OverHTTP::Formatter::Nagios::Version2 - Format output for Nagios version 2

VERSION

Top

This documentation refers to Nagios::Plugin::OverHTTP::Formatter::Nagios::Version2 version 0.14

SYNOPSIS

Top

  #TODO: Write this

DESCRIPTION

Top

This formatter for Nagios::Plugin::OverHTTP will format the plugin output that corresponds to the plugin API in Nagios 2.

CONSTRUCTOR

Top

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 plugin 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

Top

  # Set an attribute
  $object->attribute_name($new_value);

  # Get an attribute
  my $value = $object->attribute_name;

response

Required. This is the Nagios::Plugin::OverHTTP::Response object to format.

METHODS

Top

exit_code

This will return the integer to use as the argument to exit.

stderr

This will return the string to print to stderr.

  print {*STDERR} $formatter->stderr;

stdout

This will return the string to print to stdout. The Nagios 2 plugin API supports only one line of output, and so only the first line of the message is given plus all the performance data on a single line.

  print {*STDOUT} $formatter->stdout;

DEPENDENCIES

Top

This module is dependent on the following modules:

* Moose 0.74
* MooseX::StrictConstructor 0.08
* namespace::clean 0.04

AUTHOR

Top

Douglas Christopher Wilson, <doug at somethingdoug.com>

BUGS AND LIMITATIONS

Top

Please report any bugs or feature requests to bug-nagios-plugin-overhttp at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Nagios-Plugin-OverHTTP. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

LICENSE AND COPYRIGHT

Top


Nagios-Plugin-OverHTTP documentation Contained in the Nagios-Plugin-OverHTTP distribution.

package Nagios::Plugin::OverHTTP::Formatter::Nagios::Version2;

use 5.008001;
use strict;
use warnings 'all';

###########################################################################
# METADATA
our $AUTHORITY = 'cpan:DOUGDUDE';
our $VERSION   = '0.14';

###########################################################################
# MOOSE
use Moose 0.74;
use MooseX::StrictConstructor 0.08;

###########################################################################
# ROLES
with 'Nagios::Plugin::OverHTTP::Formatter';

###########################################################################
# ALL IMPORTS BEFORE THIS WILL BE ERASED
use namespace::clean 0.04 -except => [qw(meta)];

###########################################################################
# METHODS
sub exit_code {
	my ($self) = @_;

	# Just return the default
	return $self->standard_status_exit_code($self->response->status);
}
sub stderr {
	# N/A
	return q{};
}
sub stdout {
	my ($self) = @_;

	# The message is only the first line
	my $message = [split m{\n}msx, $self->response->message]->[0];

	if ($self->response->has_performance_data) {
		# Get the performance data on one line
		my $performance_data = join q{ }, split m{\n}msx,
			$self->response->performance_data;

		# Add on the performance data
		$message .= q{ | } . $performance_data;
	}

	return $message;
}

###########################################################################
# MAKE MOOSE OBJECT IMMUTABLE
__PACKAGE__->meta->make_immutable;

1;

__END__