Nagios-Plugin-OverHTTP

 view release on metacpan or  search on metacpan

lib/Nagios/Plugin/OverHTTP/Formatter/Nagios/Auto.pm  view on Meta::CPAN

		map { _get_nagios_version($_) }
		@nagios_executables;

	# The module to use
	my $formatter = $DEFAULT_FORMATTER;

	# Look for the formatter
	VERSION:
	foreach my $version (@nagios_versions) {
		# Split the version into the different dot parts
		my @parts = split m{\.}msx, $version;

		VERSION_PART:
		while (@parts) {
			# Construct version to check for
			my $check_for_version = join q{.}, @parts;
			my $module_name = join q{::Version},
				$NAGIOS_FORMATTER_PRE,
				$check_for_version;

			if (eval "require $module_name; 1;") {

lib/Nagios/Plugin/OverHTTP/Formatter/Nagios/Version2.pm  view on Meta::CPAN

	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;
}

###########################################################################

lib/Nagios/Plugin/OverHTTP/Formatter/Nagios/Version3.pm  view on Meta::CPAN

}
sub stdout {
	my ($self) = @_;

	if (!$self->response->has_performance_data) {
		# If there is no performance data, the output is the message
		return $self->response->message;
	}

	# Cut into lines
	my @message_lines = split m{\n}msx, $self->response->message;
	my @performance_data_lines = split m{\n}msx, $self->response->performance_data;

	# Build stdout with first two lines
	my $stdout = join q{ | },
		shift(@message_lines),
		shift @performance_data_lines;

	# Rest of stdout is the rest of the message
	$stdout .= join qq{\n}, q{}, @message_lines;

	if (@performance_data_lines) {

lib/Nagios/Plugin/OverHTTP/Middleware/PerformanceData.pm  view on Meta::CPAN


	if (!$response->has_performance_data) {
		# This response has no performance data
		return $response;
	}

	# Parse the performance data, keeping the line order
	my @performance_data = map {
		# Create array of data for each line to keep line order
		[ _parse_data($_) ]
	} split m{\n}msx, $response->performance_data;

	# Set the new status to the current status
	my $new_status = $response->status;

	# Set the new performance data to the current performance data
	my $new_performance_data = $response->performance_data;

	# Get a list of data objects
	my @data_objects = grep { ref ne q{} } map { @{$_} } @performance_data;

lib/Nagios/Plugin/OverHTTP/Parser/Standard.pm  view on Meta::CPAN


	# Make a HASH for the collected information
	my %collected_information;

	# Get the body content
	my $body = $self->auto_correct_html ? $self->_strip_html($response)
	                                    : $response->decoded_content
	                                    ;

	# Split the body content into lines
	my @lines = split m{(?:\r?\n|\n?\r)}msx, $body;

	if (!@lines) {
		# There is no content to parse
		return {};
	}

	# First line is message + optional performance data
	@collected_information{qw(message performance_data)} = shift(@lines)
		=~ m{\A ([^\|]+?) (?:\s* \| \s* (.*))? \z}msx;

lib/Nagios/Plugin/OverHTTP/PerformanceData.pm  view on Meta::CPAN

	# Equal sign must be present here
	if (q{=} ne substr $string, 0, 1) {
		croak 'Invalid performance string format';
	}

	# Remove equal sign
	$string = substr $string, 1;

	# Get all the arguments split out
	@args{qw(value warning_threshold critical_threshold minimum_value maximum_value)} =
		split m{;}msx, $string;

	# Remove all undefined values
	while (my ($key, $value) = each %args) {
		if (!defined $value || $value eq q{}) {
			delete $args{$key};
		}
	}

	if (exists $args{value}) {
		# Scrape out the units



( run in 1.742 second using v1.01-cache-2.11-cpan-71847e10f99 )