How to use `Nagios::Plugin::WWW::Mechanize`
Posted: Tue Jul 07, 2015 12:23 pm
I'm writing a simple Perl plugin to check the response times of a few different webpages. I want to extract links from a url using Mechanize. The documentation seems pretty straight forward but my test is already failing to run with only a few simple lines:
This test runs fine:
But with the addition of these Mechanize related lines, the test fails:
I realize the addition of Mechanize at this point doesn't add any functionality or do anything, but I don't think it should be failing.
Do I need to add the Mechanize plugin to my plugins folder on the server? I thought they worked like Ruby gems in that you can just require them and they work.
Any help would be great, thanks!
This test runs fine:
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
my $response = $ua->get("somewebsite.com");
if ($response->is_success) {
print $response->status_line;
exit(0);
} else {
print $response->status_line;
exit(2);
}
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use LWP::UserAgent;
use Nagios::Plugin::WWW::Mechanize; # new line
my $mech = Nagios::Plugin::WWW::Mechanize->new(); # new line
$mech->get("somewebsite.com"); # new line
my $ua = LWP::UserAgent->new();
my $response = $ua->get("somewebsite.com");
if ($response->is_success) {
print $response->status_line;
exit(0);
} else {
print $response->status_line;
exit(2);
}
Do I need to add the Mechanize plugin to my plugins folder on the server? I thought they worked like Ruby gems in that you can just require them and they work.
Any help would be great, thanks!