From c24590b654fae848dc5eb4b3a106954f232f2378 Mon Sep 17 00:00:00 2001 From: Julien Mathis Date: Wed, 6 Jun 2007 21:04:59 +0000 Subject: [PATCH] =?UTF-8?q?hop=20fonctionnel=20et=20nettoy=C3=A9...=20auto?= =?UTF-8?q?matique=20a=20l'install=20avec=20fichier=20de=20conf=20pour=20m?= =?UTF-8?q?ysql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.centreon.com/Plugins/Dev@2457 6bcd3966-0018-0410-8128-fd23d134de7e --- centreon-plugins/src/traps/trapHandler | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/centreon-plugins/src/traps/trapHandler b/centreon-plugins/src/traps/trapHandler index 128ad7ca9..a9744c5f2 100644 --- a/centreon-plugins/src/traps/trapHandler +++ b/centreon-plugins/src/traps/trapHandler @@ -26,15 +26,8 @@ use strict; use DBI; -############################# -## SET DATABASE CONFIGURATION -# - -sub set_db { - require "@OREON_PATH@/ODS/etc/conf.pm" - my $dsn = "dbi:mysql:database=$mysql_database_oreon;host=$mysql_host"; - return $dsn, $mysql_user, $mysql_passwd; -} +use vars qw($mysql_database_oreon $mysql_database_ods $mysql_host $mysql_user $mysql_passwd); +require "@OREON_PATH@/ODS/etc/conf.pm"; ############################### ## GET HOSTNAME FROM IP ADDRESS @@ -66,7 +59,7 @@ sub get_servicename($$$) { my $query_trap = "SELECT traps_id, traps_args, traps_status from traps where traps_oid='$_[1]'"; $sth = $_[0]->prepare($query_trap); $sth->execute(); - my ($trap_id,$argument, $trap_status) = $sth->fetchrow_array(); + my ($trap_id, $argument, $trap_status) = $sth->fetchrow_array(); exit if (!defined $trap_id); my $query_services = "SELECT service_description FROM service s, host_service_relation h, traps_service_relation t"; @@ -101,8 +94,9 @@ sub getTrapsInfos($$$){ my $ip = shift; my $oid = shift; my $arguments_line = shift; - my @db = set_db(); - my $dbh = DBI->connect($db[0], $db[1], $db[2]) or die "Echec de la connexion\n"; + + my $dsn = "dbi:mysql:$mysql_database_oreon"; + my $dbh = DBI->connect($dsn, $mysql_user, $mysql_passwd) or die "Echec de la connexion\n"; my @host = get_hostinfos($dbh, $ip); foreach(@host) { my $this_host = $_; @@ -115,9 +109,9 @@ sub getTrapsInfos($$$){ chomp($datetime); $sth = $_[0]->prepare("SELECT command_file FROM cfg_nagios WHERE nagios_activate = '1' LIMIT 1"); $sth->execute(); - my $conf = $sth->fetchrow_array(); + my @conf = $sth->fetchrow_array(); $sth->finish(); - my $submit = `/usr/bin/printf "[$datetime] PROCESS_SERVICE_CHECK_RESULT;$this_host;$this_service;$status;$argument" >> $conf->{'command_file'}`; + my $submit = `/usr/bin/printf "[$datetime] PROCESS_SERVICE_CHECK_RESULT;$this_host;$this_service;$status;$argument" >> $conf[0]`; } } $dbh->disconnect();