<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Hi list<BR>
I have a problem with my plugin nagios => check http connexion login/passd and check the presence of a word in the next page.<BR>
In console mode , i have no problem my plugin work well , but in Centreon i have the answer => (no output!).<BR>
It's possible that in Centreon process the plugin d'ont work because of the use of a specific library (WWW:mechanize)??<BR>
I join the code of the plugin :<BR>
#! /usr/bin/perl -w<BR>###############################################<BR>#<BR>#       TEST CONNEXION HTTPS ITIM<BR>#<BR># Description : Script perl Verifiant l etat de disponibilite <BR>#               de l application ITIM en testant une URL en <BR>#               saisissant un user/password et verifiant la <BR>#               page de retour<BR>#<BR># Author      : Erwan Boulard<BR>#<BR>###############################################<BR>
use utils qw(%ERRORS $TIMEOUT);<BR>use Getopt::Long;<BR>use strict;<BR>use WWW::Mechanize;<BR>use vars qw($o_uri $o_login $o_passwd $o_host $o_port $o_vers $o_help);<BR>
# Sortie Verbose<BR>#sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }<BR>
# parse command line options<BR>    Getopt::Long::Configure("bundling");<BR>    GetOptions(<BR>        'h'             => \$o_help,<BR>        'help'          => \$o_help,<BR>        #'v'             => \$o_verb,<BR>        #'verbose'       => \$o_verb,<BR>        'H:s'           => \$o_host,<BR>        'hostaddress:s' => \$o_host,<BR>        'u:s'           => \$o_uri,<BR>        'uri:s'         => \$o_uri,<BR>        'i:s'           => \$o_login,<BR>        'identifiant:s' => \$o_login,<BR>        'm:s'           => \$o_passwd,<BR>        'motdepasse:s'  => \$o_passwd,<BR>        'p:i'           => \$o_port,<BR>        'port:i'        => \$o_port,<BR>    );<BR>if ( defined($o_help) )    { &help();  exit $ERRORS{"UNKNOWN"} }<BR>
my $output;<BR>my $statut;<BR>
# URL/identifiant/motdepasse obligatoire<BR>if ( !defined($o_uri) || !defined($o_login) || !defined($o_passwd) || !defined($o_host)) {<BR>    &print_usage;<BR>    print "\nErreur : Une variable n a pas ete definie \n";<BR>    exit $ERRORS{'UNKNOWN'};<BR>}<BR>
########## MENU PRINCIPAL #######<BR>
{  <BR>    my $m = WWW::Mechanize->new;<BR>    my $url;<BR>    if(defined($o_port)){<BR>    $url = 'http://'.$o_host.':'.$o_port.$o_uri;<BR>    }<BR>    else { <BR>    $url = 'http://'.$o_host.$o_uri; <BR>     }<BR>   <BR>    # formulaire de login<BR>    #print $url;<BR>    $m->get($url);<BR>    if($m->success){<BR>   <BR>    # remplissage et validation<BR>    $m->set_fields(<BR>        useralias => $o_login,<BR>        password => $o_passwd,<BR>    );<BR>    $m->click;<BR>    die $m->res->status_line unless $m->success;<BR>    if($m->content =~ m/Host Stats/) {<BR>        $output="OK - Test de connexion";<BR>        $statut='OK';<BR>    }<BR>    else {<BR>        $output="KO - Test de connexion";<BR>        $statut='CRITICAL';<BR>    }<BR>    }<BR>    else {<BR>       $output="KO - Test de connexion";<BR>       $statut='CRITICAL';<BR>    }<BR>print $output;<BR>exit $ERRORS{$statut};<BR>}<BR>sub print_usage {<BR>print "Usage : ./check_itim_testconnexion.pl -H[--hostaddress]HostAddress -u[--uri]URI -i[--identifiant]IDENTIFIANT -m[--motdepasse]MOT DE PASSE  -p[--port]Port \n";<BR>}<BR>
sub help {<BR>print <<EOT;    <BR>******************************************************************************<BR>* Verification de l etat de disponibilite de l application ITIM Version 0.1  *<BR>* by Erwan Boulard                                                           *<BR>******************************************************************************<BR>Usage : ./check_itim_testconnexion.pl -H[--hostaddress]HostAddress -u[--uri]URI -i[--identifiant]IDENTIFIANT -m[--motdepasse]MOT DE PASSE  -p[--port]Port<BR>    <BR>
 -v, --verbose             Affichage du mode debug<BR> -h, --help                Affichage de l aide<BR> -H, --hostaddress         IP de l host<BR> -u, --uri=STRING          URI de l application ITIM<BR> -i, --identifiant=STRING  Identifiant<BR> -m, --motdepasse=STRING   Mot de passe<BR> -p, --port=INTEGER        Port<BR>
  Exemple : ./check_itim_testconnexion3.pl -H 194.4.225.81 -u /oreon/index.php -i admin -m admin -p 80 <BR>EOT<BR>}<BR>
 <BR>
Thk you for your help!!<BR>
<BR>- boulard erwan (katachana)<BR>
-----------------------<BR>The mailing list archive is found here:<BR><A href="http://www.nagiosexchange.org/nagiosplug-devel.31.0.html">http://www.nagiosexchange.org/nagiosplug-devel.31.0.html</A><BR>    <BR><br /><hr />Avec Windows Live Messenger restez en contact avec tous vos amis !  <a href='http://www.windowslive.fr/messenger/' target='_new'>Téléchargez Messenger, c'est gratuit !</a></body>
</html>