The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Nagios::WebTransact::Timed - An object that provides a check method (usually called by a Nagios service check) to determine if a sequence of URLs can be got inside a time threshold, returning the times for each.

SYNOPSIS

  use Nagios::WebTransact::Timed;

  # Constructors
  $web_trx = Nagios::WebTransact::Timed->new(\@url_set);

DESCRIPTION

WebTransact::Timed is a subclass of WebTransact that checks web performance by downloading a sequence of URLs.

The check is successfull if no more than fail_ratio of the URLs fail ie a URL is downloaded inside the timeout period with a successfull HTTP return code and no indications of invalid content.

Note that unlike WebTransact, this object only returns FAIL if all URLs fail or timeout.

CONSTRUCTOR

Nagios::WebTransact::Timed->new(ref_to_array_of_hash_refs)

This is the constructor for a new Nagios::WebTransact object. ref_to_array_of_hash_refs is a reference to an array of records (anon hash refs) in the format :-

{ Method => HEAD|GET|POST, Url => 'http://foo/bar', Qs_fixed => [cgi_var_name_1 => val1, ... ] NB that now square brackets refer to a Perl array ref Qs_var => [cgi_var_name_1 => val_at_run_time], Exp => blah, Exp_Fault=> blurb }

Exp and Exp_Fault are normal Perl patterns without pattern match delimiters. Most often they are strings.

Exp is the pattern that when matched against the respose to the URL (in the same hash) indicates success.
Exp_Fault is the pattern that indicates the response is a failure.

If these patterns contain parentheses eg 'match a lot (.*)', then the match is saved for use by Qs_var. Note that there should be only one pattern per element of the Exp list. Nested patterns ( yada(blah(.+)blurble(x|y|zz(top.*)) ) will not work as expected.

Qs_fixed and Qs_var are used to generate a query string.

Qs_fixed contains the name value pairs that are known at compile time whereas
Qs_var contains placeholders for values that are not known until run time.

In both cases, the format of these fields is a reference to an array containing alternating CGI variable names and values eg \(name1, v1, name2, v2, ...) produces a query string name1=v1&name2=v2&..

METHODS

Unless otherwise stated all methods return either a true or false value, with true meaning that the check of the web transaction was a success. false is a zero (0).

check( CGI_VALUES, OPTIONS )

Performs a check of the Web transaction by getting the sequence or URLs specified in the constructor argument.

<OPTIONS> are passed in a hash like fashion, using key and value pairs. Possible options other than those specified by the super class are

timeout specifies a timeout different to the default (10 seconds) for each URL. When a URL cannot be fetched, it is recorded as having taken 10 (ten) seconds.

fail_ratio_percent specifies that the check will return immediately (with a failure) if the proportion of failures (ie if HTTP::Response::is_success says it is or a timeout) as a percentage, is greater than this threshold. eg if fail_ratio_percent is 100, fetching all the URls must fail before the check returns false.

verbose is meant for CLI use (or in a CGI). It reports the time taken for each URL on standard error.

download_images is meant for CLI use (or in a CGI). It reports the time taken to download each of the images found in the page provided that image has not been downloaded by the Nagios::WebTransact object session. Download time is displayed on standard error.

check returns a boolean indication of success and a reference to an array containing the time taken for each URL. If a URL cannot be download (invalid content, HTTP failure or timeout), the time is marked as 10.

EXAMPLE

see check_inter_perf.pl in t directory.

BUGS

1 Timeout is approximate and applies independently to image download and HTML - if you ask for image download, the timeout is applied to the images and the HTML separately effectively doubling the timeout.
2 A more flexible approach may be for this module to decorate the super class,
3 Having to supply the list of URLs to the constructor is strange.

AUTHOR

S Hopcroft, Stanley.Hopcroft@IPAustralia.Gov.AU

SEE ALSO

  perl(1).
  Nagios::WebTransact
  Nagios   http://www.Nagios.ORG