Nagios:...chanize(3)
π Nagios::Plugin::WWW::Mechanize π
okay bestie, this is the Nagios:...chanize(3) page β yes that's the manual name, it's giving abbreviated-and-iconic π
β and it's here to teach you how to log into a web page as a user and pull data out of it like a Nagios plugin. no cap.
β¨ NAME β¨
Nagios::Plugin::WWW::Mechanize β log in to a web page as a user and get data back as a Nagios plugin. literally that's the whole job description π
πΈ SYNOPSIS πΈ
use Nagios::Plugin::WWW::Mechanize;
$np = Nagios::Plugin::WWW::Mechanize->new(
usage => "Checks number of mailing list users"
);
$np->getopts;
$np->get( "http://lists.opsview.org/lists/admin/opsview-users/members" );
$np->submit_form( form_name => "f", fields => { adminpw => "****" } );
$content = $np->content;
($number_of_users) = ($content =~ /(\d+) members total/);
$np->nagios_exit( CRITICAL, "Cannot get number of users" ) unless defined $number_of_users;
$np->add_perfdata(
label => "users",
value => $number_of_users,
);
$np->nagios_exit(
OK,
"Number of mailing list users: $number_of_users"
);
π¦ DESCRIPTION π¦
This module ties Monitoring::Plugin with WWW::Mechanize so that there's less code in your perl script and the most common work is done for you. it's giving "I got you, bestie" π«Ά
For example, the plugin will automatically call nagios_exit(CRITICAL, ...) if a page is unavailable or a submit_form fails. The plugin will also keep a track of the time for responses from the remote web server and output that as performance data. obsessed with a module that does your chores for you fr fr β¨
π INITIALISE π
Nagios::Plugin::WWW::Mechanize->new( %opts )
Takes %opts. Here's the tea:
- If
$opts{mech}is specified and is an object, it will check if it is aWWW::Mechanizeobject and die if not π. If$opts{mech}is a hash ref, it will pass those to aWWW::Mechanize->new()call. Otherwise it will create aWWW::Mechanizeobject withautocheck => 0, because otherwise any failures are exited immediately. no chill at all. - It also looks for
$opts{include_time}. Defaults to1, which means that performance data for time will be returned. β±οΈ - All other options are passed to
Monitoring::Plugin.
π METHODS π
mechβ Returns theWWW::Mechanizeobject. that's it, that's the method πget( @args )β Calls$self->mech->get( @args ). If$self->include_timeis set, it will start a timer before the get, calculate the duration, and add it to a total timer. β±οΈ
If the mech->get call failed, it will call nagios_exit with a CRITICAL error. π
Returns the value from mech->get.
submit_form( @args )β Similar toget. same energy, different method πcontentβ Shortcut for$self->mech->content. lazy-girl coding at its finest, and we respect it π«Άnagios_exitβ Override to add performance data for time if required.
π AUTHOR π
Ton Voon, <ton.voon@opsera.com>
π COPYRIGHT AND LICENSE π
Copyright (C) 2006-2009 Opsera Limited. All rights reserved
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
π POD ERRORS π
Hey! The above document had some coding errors, which are explained below:
- Around line 116:
You forgot a '=back' before '=head1'
- Around line 188:
You forgot a '=back' before '=head1'
not the =back jumpscare π it's fine, it's fine, the docs still ate.
and that's the whole page, bestie π this was perl v5.42.0, dated 2025-07-25, from the Nagios:...chanize(3) manual β slay, go monitor something, periodt πβ¨
π¦ where this page comes from
- fedora 43: perl-Nagios-Plugin-WWW-Mechanize 0.13-45.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms