All,<br> how do you parse multiple of same argument in Nagios::Plungin. I am calling my check as this<br><br>perl check_htturl -H <a href="http://wind.columbia.edu">wind.columbia.edu</a> -u username -p pass -P /login -q me -q you<br clear="all">
<br>when I print -q it should print me&you but its not doing that. This is my code. Please advise on this. Thanks<br><br><br><br><br>#!/usr/bin/perl -w<br><br>=head1 NAME<br>check_httpurl - Check httpurl with sequential query.<br>
=head1 AUTHOR<br>Shadhin Rahman <<a href="mailto:sr2690@columbia.edu">sr2690@columbia.edu</a>><br>=head1 SYNOPSYS<br> This particular plugin can do sequential query upon first query, ideal for CAS type authentication check<br>
=head1 REQUIRES<br>Perl5.004, strict, URI, Nagios::Plugin, HTTP::Request::Common, LWP::UserAgent<br>=head1 EXPORTS<br>Nothing<br><br>=head1 DESCRIPTION<br> OK if response code is 200 and regex checks succeed, or<br>
if response code is 200 and no regex checks were specified<br> UNKNOWN if HTTP response status code class is not recognized <br> WARNING if HTTP response status code is class 1xx or 3xx<br> CRITICAL if HTTP response status code is class 4xx or 5xx,<br>
or if class is 200 and $matchregex not found<br> or if class is 200 and $errorregex is found<br>=cut<br><br>use warnings;<br>use strict;<br>no warnings qw( redefine prototype );<br><br>BEGIN {<br>use Nagios::Plugin;<br>
use URI;<br>use HTTP::Request::Common;<br>use LWP::UserAgent;<br>} # END BEGIN<br><br>my( $usagemsg ) = <<USAGE;<br>Usage: %s -H <hostname> [-w <warning seconds>] [-c <critical seconds>][-v|d] [-h]<br>
USAGE<br>my( $blurb ) = <<BLURB;<br>This particular plugin can do sequential query upon first query, ideal for CAS type authentication check<br>BLURB<br>my( $license ) = <<LICENSE;<br>Copyright (c) 2008 - 2009 <br>
LICENSE<br><br>Nagios::Plugin->new( <br> usage => "Usage: %s [ -v|--verbose ] [-H <host>] "<br> . "[ -c|--critical=<threshold> ] [ -w|--warning=<threshold> ]",<br> );<br>
my( $plugin ) = Nagios::Plugin->new( <br> shortname => 'check_httpurl',<br> usage => $usagemsg,<br> version => '0.2',<br>
blurb => $blurb,<br> license => $license,<br> );<br>=head2 Plugin Metadata<br><br>Metadata is documented in L<Nagios::Plugin> and L<Nagios::Plugin::Getopt>.<br>
<br>Other available options of interest include C<url>, C<extra>, and C<timeout>.<br><br>=cut<br><br>$plugin->add_arg( <br> spec => 'hostname|H=s', <br> help => [ <br>
"Hostname to query",<br> "IP address to query",<br> ],<br> label => [ 'HOSTNAME', 'IP' ],<br> required => 1,<br>
); <br><br>$plugin->add_arg(<br> spec => 'ssl|S=s', <br> help => [ <br> "confifrms ssl transmission", <br>
],<br> label => [ 'SSL' ],<br> required => 0, <br> );<br><br>$plugin->add_arg( <br> spec => 'username|u=s', <br>
help => "username for authentication",<br> label => [ 'username' ],<br> required => 1,<br> ); <br><br>$plugin->add_arg( <br>
spec => 'password|p=s', <br> help => "password for authentication",<br> label => [ 'password' ],<br> required => 1,<br>
); <br><br>$plugin->add_arg( <br> spec => 'url|P=s', <br> help => "path of the url",<br> label => [ 'path' ],<br>
required => 1,<br> ); <br><br>$plugin->add_arg( <br> spec => 'query|q=s', <br> help => "additional query to inject",<br>
label => [ 'query' ],<br> required => 0,<br> ); <br><br>$plugin->add_arg( <br> spec => 'regex|r=s', <br> help => "regex to match",<br>
label => [ 'regex' ],<br> required => 0,<br> ); <br><br><br>$plugin->getopts;<br><br>my ( $opts ) =$plugin->opts;<br><br>my ( $server, $username, $password, $path, $query, $regex );<br>
<br>$server=$opts->get('hostname');<br>$username = $opts->get('username');<br>$password=$opts->get('password');<br>$path=$opts->get('url');<br>if ( $query = $opts->get( 'query' ) ) {<br>
$query=join ( '&', $opts->get('query') );<br>}<br>$regex=$opts->get('regex');<br><br><br>print $query ."\n";<br><br><br>-- <br>Cordially,<br>Shadhin Rahman<br>