Nagios:...chanize(3)

πŸ“¦
version 0.13 Β· 2 versions
, in fedora 43

πŸ’– 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 a WWW::Mechanize object and die if not πŸ’€. If $opts{mech} is a hash ref, it will pass those to a WWW::Mechanize->new() call. Otherwise it will create a WWW::Mechanize object with autocheck => 0, because otherwise any failures are exited immediately. no chill at all.
  • It also looks for $opts{include_time}. Defaults to 1, which means that performance data for time will be returned. ⏱️
  • All other options are passed to Monitoring::Plugin.

πŸ’… METHODS πŸ’…

  • mech β€” Returns the WWW::Mechanize object. that's it, that's the method πŸŽ€
  • get( @args ) β€” Calls $self->mech->get( @args ). If $self->include_time is 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 to get. 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 (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