Douglas Christopher Wilson


Nagios::Plugin::OverHTTP - Nagios plugin to check over the HTTP protocol.


Version 0.13


  my $plugin = Nagios::Plugin::OverHTTP->new(
      url => '',

  my $plugin = Nagios::Plugin::OverHTTP->new(
      hostname => '',
      path     => '/nagios/check_some_service.cgi',
      ssl      => 1,

  my $status  = $plugin->status;
  my $message = $plugin->message;


This Nagios plugin provides a way to check services remotely over the HTTP protocol.


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.


This will construct a new plugin object.


%attributes is a HASH where the keys are attributes (specified in the "ATTRIBUTES" section).


$attributes is a HASHREF where the keys are attributes (specified in the "ATTRIBUTES" section).


This is identical to "new", except with the additional feature of reading the @ARGV in the invoked scope. @ARGV will be parsed for command-line arguments. The command-line can contain any variable that "new" can take. Arguments should be in the following format on the command line:

  # Note that quotes may be used, based on your shell environment

  # For bools, like SSL, you would use:
  --ssl    # Enable SSL
  --no-ssl # Disable SSL


  # Set an attribute

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


Added in version 0.10; be sure to require this version for this feature.

This is a Boolean of wether or not to attempt to add a meaningful first line to the message when the HTTP response did not include the Nagios plugin status and the message looks like HTML and has multiple lines. The title of the web page will be added to the first line, or the first H1 element will. The default for this is on.


Added in version 0.09; be sure to require this version for this feature.

This is the default status that will be used if the remote plugin does not return a status. The default is "UNKNOWN." The status may be the status number, or a string with the name of the status, like:



This is the hostname of the remote server. This will automatically be populated if "url" is set.


This is the path to the remove Nagios plugin on the remote server. This will automatically be populated if "url" is set.


This is a Boolean of whether or not to use SSL over HTTP (HTTPS). This defaults to false and will automatically be updated to true if a HTTPS URL is set to "url".


This is a positive integer for the timeout of the HTTP request. If set, this will override any timeout defined in the useragent for the duration of the request. The plugin will not permanently alter the timeout in the useragent. This defaults to not being set, and so the useragent's timeout is used.


This is the URL of the remote Nagios plugin to check. If not supplied, this will be constructed automatically from the "hostname" and "path" attributes.


This is the useragent to use when making requests. This defaults to LWP::Useragent with no options. Currently this must be an LWP::Useragent object.


Added in version 0.12; be sure to require this version for this feature.

This is the HTTP verb that will be used to make the HTTP request. The default value is GET.



This will run the remote check. This is usually not needed, as attempting to access the message or status will result in the check being performed.


This will run the plugin in a standard way. The message will be printed to standard output and the status code will be returned. Good for doing the following:

  my $plugin = Plugin::Nagios::OverHTTP->new_with_options;

  exit $plugin->run;



The protocol that this plugin uses to communicate with the Nagios plugins is unique to my knowledge. If anyone knows another way that plugins are communicating over HTTP then let me know.

A request that returns a 5xx status will automatically return as CRITICAL and the plugin will display the error code and the status message (this will typically result in 500 Internal Server Error).

A request that returns a 2xx status will be parsed using the methods listed in "HTTP BODY".

Any other status code will cause the plugin to return as UNKNOWN and the plugin will display the error code and the status message.


The body of the HTTP response will be the output of the plugin unless the header X-Nagios-Information is present. To determine what the status code will be, the following methods are used:

  1. If a the header X-Nagios-Status is present, the value from that is used as the output. The content of this header MUST be either the decimal return value of the plugin or an all capital letters. The different possibilities for this is listed in "NAGIOS STATUSES".

  2. If the header did not conform to proper specifications or was not present, then the status will be extracted from the body of the response. The very first set of all capital letters is taken from the body and used to determine the result. The different possibilities for this is listed in "NAGIOS STATUSES"

Please note that if the header X-Nagios-Information is present, then the status MUST be in the header X-Nagios-Status as described above. The status will not be extracted from any text. The X-Nagios-Information header support was added in version 0.12.


0 OK









The following is an example of a simple bootstrapping of a plugin on a remote server.

  #!/usr/bin/env perl
  use strict;
  use warnings;
  my $output = qx{/usr/local/libexec/nagios/check_users2 -w 100 -c 500};
  my $status = $? > 0 ? $? >> 8 : 3;
  printf "X-Nagios-Header: %d\n", $status;
  print  "Content-Type: text/plain\n\n";
  print  $output if $output;
  exit 0;



Douglas Christopher Wilson, <doug at>


  • Alex Wollangk contributed the idea and code for the X-Nagios-Information header.


Please report any bugs or feature requests to bug-nagios-plugin-overhttp at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

  perldoc Nagios::Plugin::OverHTTP

You can also look for information at:


Copyright 2009 Douglas Christopher Wilson, all rights reserved.

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.