#!/usr/bin/perl -w # nagios: -epn ############################################################################## # # NAME: lcg-tags-probe # # AUTHORS: Simone Badoer # # CREATED: 5-Apr-2011 # ############################################################################## =head1 NAME lcg-tags-probe =head1 SYNOPSIS B -H --vo =head1 DESCRIPTION B is called as a Nagios check. It gets tags for a CE. =cut use strict; use warnings; use Nagios::Plugin; use constant PROGNAME => "$0"; use constant VERSION => '1.0'; use constant DESCRIPTION => 'lcg-tags-probe gets tags for a CE.'; use constant EXTRA_DESC => ""; use constant LICENSE => ''; use constant SHORTNAME => 'TagProbe'; use constant TIMEOUT => 0.1; use constant USAGE => "usage lcg-tags-probe -H --vo \n"; # Create Nagios::Plugin instance my $plugin = Nagios::Plugin->new (usage => USAGE, shortname => SHORTNAME, version => VERSION, blurb => DESCRIPTION, extra => EXTRA_DESC, license => LICENSE, plugin => PROGNAME); $plugin->add_arg( spec => 'H=s', help => "-H\n Hostname.\n", required => 1, ); $plugin->add_arg( spec => 'vo=s', help => "--vo\n VO.\n", required => 1, ); $plugin->add_arg( spec => 'x=s', help => "-x\n X509_USER_PROXY.\n", required => 1, ); $plugin->getopts(); local $SIG{ALRM} = sub { $plugin->nagios_die("Timeout occured during lcg-tags-probe."); }; local $SIG{TERM} = sub { $plugin->nagios_die("Plugin received TERM signal."); }; ######################## # # MAIN # ######################## my $ce=$plugin->opts->get('H'); my $vo=$plugin->opts->get('vo'); my $proxy=$plugin->opts->get('x'); my $tags; my $tag; my $msgOut; my @tags=`X509_USER_PROXY=$proxy; /opt/glite/bin/lcg-tags --ce $ce --vo $vo --list`; foreach $tag (@tags) { chop($tag); } $msgOut=join(", ",@tags); if ($msgOut) { $plugin->nagios_exit(OK,"$msgOut"); } else { $plugin->nagios_exit(WARNING, "No tags found."); }