[Nagiosplug-devel] (No output error in Centreon) // no problem in console mode

boulard erwan ivibration at hotmail.com
Wed Mar 19 10:19:02 CET 2008


Hi list

I have a problem with my plugin nagios => check http connexion login/passd and check the presence of a word in the next page.

In console mode , i have no problem my plugin work well , but in Centreon i have the answer => (no output!).

It's possible that in Centreon process the plugin d'ont work because of the use of a specific library (WWW:mechanize)??

I join the code of the plugin :

#! /usr/bin/perl -w
###############################################
#
#       TEST CONNEXION HTTPS ITIM
#
# Description : Script perl Verifiant l etat de disponibilite 
#               de l application ITIM en testant une URL en 
#               saisissant un user/password et verifiant la 
#               page de retour
#
# Author      : Erwan Boulard
#
###############################################

use utils qw(%ERRORS $TIMEOUT);
use Getopt::Long;
use strict;
use WWW::Mechanize;
use vars qw($o_uri $o_login $o_passwd $o_host $o_port $o_vers $o_help);

# Sortie Verbose
#sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }

# parse command line options
    Getopt::Long::Configure("bundling");
    GetOptions(
        'h'             => \$o_help,
        'help'          => \$o_help,
        #'v'             => \$o_verb,
        #'verbose'       => \$o_verb,
        'H:s'           => \$o_host,
        'hostaddress:s' => \$o_host,
        'u:s'           => \$o_uri,
        'uri:s'         => \$o_uri,
        'i:s'           => \$o_login,
        'identifiant:s' => \$o_login,
        'm:s'           => \$o_passwd,
        'motdepasse:s'  => \$o_passwd,
        'p:i'           => \$o_port,
        'port:i'        => \$o_port,
    );
if ( defined($o_help) )    { &help();  exit $ERRORS{"UNKNOWN"} }

my $output;
my $statut;

# URL/identifiant/motdepasse obligatoire
if ( !defined($o_uri) || !defined($o_login) || !defined($o_passwd) || !defined($o_host)) {
    &print_usage;
    print "\nErreur : Une variable n a pas ete definie \n";
    exit $ERRORS{'UNKNOWN'};
}

########## MENU PRINCIPAL #######

{  
    my $m = WWW::Mechanize->new;
    my $url;
    if(defined($o_port)){
    $url = 'http://'.$o_host.':'.$o_port.$o_uri;
    }
    else { 
    $url = 'http://'.$o_host.$o_uri; 
     }
   
    # formulaire de login
    #print $url;
    $m->get($url);
    if($m->success){
   
    # remplissage et validation
    $m->set_fields(
        useralias => $o_login,
        password => $o_passwd,
    );
    $m->click;
    die $m->res->status_line unless $m->success;
    if($m->content =~ m/Host Stats/) {
        $output="OK - Test de connexion";
        $statut='OK';
    }
    else {
        $output="KO - Test de connexion";
        $statut='CRITICAL';
    }
    }
    else {
       $output="KO - Test de connexion";
       $statut='CRITICAL';
    }
print $output;
exit $ERRORS{$statut};
}
sub print_usage {
print "Usage : ./check_itim_testconnexion.pl -H[--hostaddress]HostAddress -u[--uri]URI -i[--identifiant]IDENTIFIANT -m[--motdepasse]MOT DE PASSE  -p[--port]Port \n";
}

sub help {
print <<EOT;    
******************************************************************************
* Verification de l etat de disponibilite de l application ITIM Version 0.1  *
* by Erwan Boulard                                                           *
******************************************************************************
Usage : ./check_itim_testconnexion.pl -H[--hostaddress]HostAddress -u[--uri]URI -i[--identifiant]IDENTIFIANT -m[--motdepasse]MOT DE PASSE  -p[--port]Port
    

 -v, --verbose             Affichage du mode debug
 -h, --help                Affichage de l aide
 -H, --hostaddress         IP de l host
 -u, --uri=STRING          URI de l application ITIM
 -i, --identifiant=STRING  Identifiant
 -m, --motdepasse=STRING   Mot de passe
 -p, --port=INTEGER        Port

  Exemple : ./check_itim_testconnexion3.pl -H 194.4.225.81 -u /oreon/index.php -i admin -m admin -p 80 
EOT
}



Thk you for your help!!


- boulard erwan (katachana)

-----------------------
The mailing list archive is found here:
http://www.nagiosexchange.org/nagiosplug-devel.31.0.html
				




More information about the Devel mailing list