Nagios::Plugin::Getopt 0.14 review
DownloadNagios::Plugin::Getopt is a OO perl module providing standardised argument processing for Nagios plugins. SYNOPSIS use Nagios
|
|
Nagios::Plugin::Getopt is a OO perl module providing standardised argument processing for Nagios plugins.
SYNOPSIS
use Nagios::Plugin::Getopt;
# Instantiate object (usage and version are mandatory)
$ng = Nagios::Plugin::Getopt->new(
usage => "Usage: %s -H -w
-c ",
version => '0.01',
url => 'http://www.openfusion.com.au/labs/nagios/',
blurb => 'This plugin tests various stuff.',
);
# Add argument - named parameters (spec and help are mandatory)
$ng->arg(
spec => 'critical|c=s',
help => qq(-c, --critical=INTEGERn Exit with CRITICAL status if fewer than INTEGER foobars are free),
required => 1,
default => 10,
);
# Add argument - positional parameters - arg spec, help text,
# default value, required? (first two mandatory)
$ng->arg(
'warning|w=s',
qq(-w, --warning=INTEGERn Exit with WARNING status if fewer than INTEGER foobars are free),
5,
1);
# Parse arguments and process standard ones (e.g. usage, help, version)
$ng->getopts;
# Access arguments using named accessors or or via the generic get()
print $ng->warning;
print $ng->get('critical');
Nagios::Plugin::Getopt is an OO perl module providing standardised and simplified argument processing for Nagios plugins. It implements a number of standard arguments itself (--help, --version, --usage, --timeout, --verbose, and their short form counterparts), produces standardised nagios plugin help output, and allows additional arguments to be easily defined.
Requirements:
Perl
Nagios::Plugin::Getopt 0.14 keywords