commit new version of trap and rename oreon.pm by centreon.pm
git-svn-id: http://svn.centreon.com/trunk/plugins@3286 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
parent
dcce7ee0fb
commit
2b71ba02fe
|
@ -30,12 +30,12 @@ use FindBin;
|
|||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
if (eval "require oreon" ) {
|
||||
if (eval "require centreon" ) {
|
||||
use oreon qw(get_parameters);
|
||||
use vars qw($VERSION %oreon);
|
||||
%oreon=get_parameters();
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@ use FindBin;
|
|||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
if (eval "require oreon" ) {
|
||||
use oreon qw(get_parameters);
|
||||
use vars qw($VERSION %oreon);
|
||||
%oreon = get_parameters();
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
use vars qw($PROGNAME);
|
||||
|
|
|
@ -30,7 +30,6 @@ use lib "$FindBin::Bin";
|
|||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
|
|
|
@ -36,7 +36,7 @@ if (eval "require centreon" ) {
|
|||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ if (eval "require centreon" ) {
|
|||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ use FindBin;
|
|||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
if (eval "require oreon" ) {
|
||||
use oreon qw(get_parameters);
|
||||
use vars qw($VERSION %oreon);
|
||||
%oreon=get_parameters();
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ if (eval "require centreon" ) {
|
|||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -38,11 +38,11 @@ use utils qw(%ERRORS $TIMEOUT);
|
|||
# centreon specific
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use oreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@ use lib "@NAGIOS_PLUGINS@";
|
|||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use oreon qw(get_parameters);
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw(%centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
use vars qw($PROGNAME);
|
||||
|
|
|
@ -30,12 +30,12 @@ use FindBin;
|
|||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
if (eval "require oreon" ) {
|
||||
use oreon qw(get_parameters);
|
||||
use vars qw(%oreon);
|
||||
%oreon=get_parameters();
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw(%centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
use vars qw($PROGNAME);
|
||||
|
|
|
@ -30,12 +30,12 @@ use lib "$FindBin::Bin";
|
|||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require oreon" ) {
|
||||
use oreon qw(get_parameters);
|
||||
use vars qw($VERSION %oreon);
|
||||
%oreon=get_parameters();
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ use lib "$FindBin::Bin";
|
|||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require oreon" ) {
|
||||
use oreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %oreon);
|
||||
%oreon=get_parameters();
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load oreon perl module\n";
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ sub getServicesIncludeTemplate($$$$) {
|
|||
my @service;
|
||||
$sth_st->execute();
|
||||
while (my @temp = $sth_st -> fetchrow_array()) {
|
||||
my $tr_query = "select traps_id from traps_service_relation where service_id ='".$temp[0]."' and traps_id='".$trap_id."'";
|
||||
my $tr_query = "SELECT `traps_id` FROM `traps_service_relation` WHERE `service_id` = '".$temp[0]."' AND `traps_id` = '".$trap_id."'";
|
||||
my $sth_st3 = $dbh->prepare($tr_query);
|
||||
$sth_st3->execute();
|
||||
my @trap = $sth_st3 -> fetchrow_array();
|
||||
|
@ -65,12 +65,12 @@ sub getServicesIncludeTemplate($$$$) {
|
|||
my $found = 0;
|
||||
my $service_template = $temp[2];
|
||||
while (!$found) {
|
||||
my $st1_query = "select service_id, service_template_model_stm_id, service_description from service s where service_id ='".$service_template."'";
|
||||
my $st1_query = "SELECT `service_id`, `service_template_model_stm_id`, `service_description` FROM service s WHERE `service_id` = '".$service_template."'";
|
||||
my $sth_st1 = $dbh->prepare($st1_query);
|
||||
$sth_st1 -> execute();
|
||||
my @st1_result = $sth_st1 -> fetchrow_array();
|
||||
if (defined($st1_result[0])) {
|
||||
my $sth_st2 = $dbh->prepare("select traps_id from traps_service_relation where service_id ='".$service_template."' and traps_id='".$trap_id."'");
|
||||
my $sth_st2 = $dbh->prepare("SELECT `traps_id` FROM `traps_service_relation` WHERE `service_id` = '".$service_template."' AND `traps_id` = '".$trap_id."'");
|
||||
$sth_st2 -> execute();
|
||||
my @st2_result = $sth_st2 -> fetchrow_array();
|
||||
if (defined($st2_result[0])) {
|
||||
|
@ -100,15 +100,15 @@ sub getServicesIncludeTemplate($$$$) {
|
|||
|
||||
sub getServiceInformations($$$) {
|
||||
|
||||
my $sth = $_[0]->prepare("SELECT host_id from host WHERE host_name ='$_[2]'");
|
||||
my $sth = $_[0]->prepare("SELECT `host_id` FROM `host` WHERE `host_name` = '$_[2]'");
|
||||
$sth->execute();
|
||||
my $host_id = $sth->fetchrow_array();
|
||||
exit if (!defined $host_id);
|
||||
$sth->finish();
|
||||
|
||||
$sth = $_[0]->prepare("SELECT traps_id, traps_status from traps where traps_oid='$_[1]'");
|
||||
$sth = $_[0]->prepare("SELECT `traps_id`, `traps_status`, `traps_submit_result_enable`, `traps_execution_command`, `traps_reschedule_svc_enable`, `traps_execution_command_enable` FROM `traps` WHERE `traps_oid` = '$_[1]'");
|
||||
$sth->execute();
|
||||
my ($trap_id, $trap_status) = $sth->fetchrow_array();
|
||||
my ($trap_id, $trap_status, $traps_submit_result_enable, $traps_execution_command, $traps_reschedule_svc_enable, $traps_reschedule_svc_enable) = $sth->fetchrow_array();
|
||||
exit if (!defined $trap_id);
|
||||
$sth->finish();
|
||||
|
||||
|
@ -131,7 +131,7 @@ sub getServiceInformations($$$) {
|
|||
$sth_st->execute();
|
||||
@service = (@service,getServicesIncludeTemplate($_[0], $sth_st, $host_id, $trap_id));
|
||||
$sth_st->finish;
|
||||
return $trap_status, (@service);
|
||||
return $trap_status, (@service), $traps_submit_result_enable, $traps_execution_command, $traps_reschedule_svc_enable, $traps_execution_command_enable;
|
||||
}
|
||||
|
||||
#######################################
|
||||
|
@ -148,16 +148,27 @@ sub getTrapsInfos($$$$){
|
|||
my @host = get_hostinfos($dbh, $ip, $hostname);
|
||||
foreach(@host) {
|
||||
my $this_host = $_;
|
||||
my ($status, @servicename) = getServiceInformations($dbh, $oid, $_);
|
||||
my ($status, @servicename, $traps_submit_result_enable, $traps_execution_command, $traps_reschedule_svc_enable, $traps_execution_command_enable) = getServiceInformations($dbh, $oid, $_);
|
||||
foreach (@servicename) {
|
||||
my $this_service = $_;
|
||||
my $datetime=`date +%s`;
|
||||
my $datetime = `date +%s`;
|
||||
chomp($datetime);
|
||||
my $sth = $dbh->prepare("SELECT command_file FROM cfg_nagios WHERE nagios_activate = '1' LIMIT 1");
|
||||
my $sth = $dbh->prepare("SELECT `command_file` FROM `cfg_nagios` WHERE `nagios_activate` = '1' LIMIT 1");
|
||||
$sth->execute();
|
||||
my @conf = $sth->fetchrow_array();
|
||||
$sth->finish();
|
||||
my $submit = `/bin/echo "[$datetime] PROCESS_SERVICE_CHECK_RESULT;$this_host;$this_service;$status;$arguments_line" >> $conf[0]`;
|
||||
$sth->finish();
|
||||
if (defined($traps_submit_result_enable) && $traps_submit_result_enable eq 1){
|
||||
my $submit = `/bin/echo "[$datetime] PROCESS_SERVICE_CHECK_RESULT;$this_host;$this_service;$status;$arguments_line" >> $conf[0]`;
|
||||
}
|
||||
if (defined($traps_reschedule_svc_enable) && $traps_reschedule_svc_enable eq 1){
|
||||
my $time_now = time();
|
||||
my $submit = `/bin/echo "[$datetime] SCHEDULE_FORCED_SVC_CHECK;$this_host;$this_service;$time_now" >> $conf[0]`;
|
||||
undef($time_now);
|
||||
}
|
||||
if (defined($traps_execution_command_enable) && $traps_execution_command_enable){
|
||||
system($traps_execution_command);
|
||||
}
|
||||
undef($sth);
|
||||
}
|
||||
}
|
||||
$dbh->disconnect();
|
||||
|
|
Loading…
Reference in New Issue