Fix when syslog not installed
git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@18 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
parent
1d139af98d
commit
1a7c914784
|
@ -3,8 +3,10 @@
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
|
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
|
||||||
|
$ENV{ESX_SYSLOGD_LOAD} = 0;
|
||||||
eval 'require Unix::Syslog;';
|
eval 'require Unix::Syslog;';
|
||||||
if (!$@) {
|
if (!$@) {
|
||||||
|
$ENV{ESX_SYSLOGD_LOAD} = 1;
|
||||||
require Unix::Syslog;
|
require Unix::Syslog;
|
||||||
Unix::Syslog->import(qw(:subs :macros));
|
Unix::Syslog->import(qw(:subs :macros));
|
||||||
}
|
}
|
||||||
|
@ -22,6 +24,8 @@ use Data::Dumper;
|
||||||
|
|
||||||
use vars qw($libpath $port $service_url $username $password $TIMEOUT_VSPHERE $TIMEOUT $TIMEOUT_KILL $REFRESH_KEEPER_SESSION);
|
use vars qw($libpath $port $service_url $username $password $TIMEOUT_VSPHERE $TIMEOUT $TIMEOUT_KILL $REFRESH_KEEPER_SESSION);
|
||||||
use vars qw($LOG $log_mode $log_crit $log_facility);
|
use vars qw($LOG $log_mode $log_crit $log_facility);
|
||||||
|
use vars qw($openlog_option $syslog_err_priority $syslog_info_priority);
|
||||||
|
|
||||||
use constant {
|
use constant {
|
||||||
LOG_ESXD_ERROR => 1,
|
LOG_ESXD_ERROR => 1,
|
||||||
LOG_ESXD_INFO => 2
|
LOG_ESXD_INFO => 2
|
||||||
|
@ -70,6 +74,14 @@ our $session1;
|
||||||
our $counter = 0;
|
our $counter = 0;
|
||||||
our $global_id;
|
our $global_id;
|
||||||
|
|
||||||
|
our $openlog_option;
|
||||||
|
our $syslog_err_priority;
|
||||||
|
our $syslog_info_priority;
|
||||||
|
|
||||||
|
if ($ENV{ESX_SYSLOGD_LOAD} == 1) {
|
||||||
|
require $libpath . '/esxd-syslog.pm';
|
||||||
|
}
|
||||||
|
|
||||||
our %ERRORS = ( "OK" => 0, "WARNING" => 1, "CRITICAL" => 2, "UNKNOWN" => 3, "PENDING" => 4);
|
our %ERRORS = ( "OK" => 0, "WARNING" => 1, "CRITICAL" => 2, "UNKNOWN" => 3, "PENDING" => 4);
|
||||||
our %MYERRORS = (0 => "OK", 1 => "WARNING", 3 => "CRITICAL", 7 => "UNKNOWN");
|
our %MYERRORS = (0 => "OK", 1 => "WARNING", 3 => "CRITICAL", 7 => "UNKNOWN");
|
||||||
our %MYERRORS_MASK = ("CRITICAL" => 3, "WARNING" => 1, "UNKNOWN" => 7, "OK" => 0);
|
our %MYERRORS_MASK = ("CRITICAL" => 3, "WARNING" => 1, "UNKNOWN" => 7, "OK" => 0);
|
||||||
|
@ -283,7 +295,7 @@ if ($log_mode == 1) {
|
||||||
open STDERR, '>&', $centesx_fh;
|
open STDERR, '>&', $centesx_fh;
|
||||||
}
|
}
|
||||||
if ($log_mode == 2) {
|
if ($log_mode == 2) {
|
||||||
openlog $0, LOG_PID, $log_facility;
|
openlog($0, $openlog_option, $log_facility);
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe($reader_pipe_one, $writer_pipe_one);
|
pipe($reader_pipe_one, $writer_pipe_one);
|
||||||
|
|
|
@ -11,8 +11,8 @@ sub writeLogFile($$) {
|
||||||
printf LOG "%04d-%02d-%02d %02d:%02d:%02d - %s", $year+1900, $mon+1, $mday, $hour, $min, $sec, $_[1];
|
printf LOG "%04d-%02d-%02d %02d:%02d:%02d - %s", $year+1900, $mon+1, $mday, $hour, $min, $sec, $_[1];
|
||||||
close LOG;
|
close LOG;
|
||||||
} elsif ($log_mode == 2) {
|
} elsif ($log_mode == 2) {
|
||||||
syslog LOG_ERR, $_[1] if ($_[0] == LOG_ESXD_ERROR);
|
syslog($syslog_err_priority, $_[1]) if ($_[0] == LOG_ESXD_ERROR);
|
||||||
syslog LOG_INFO, $_[1] if ($_[0] == LOG_ESXD_INFO);
|
syslog($syslog_info_priority, $_[1]) if ($_[0] == LOG_ESXD_INFO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
$openlog_option = LOG_PID;
|
||||||
|
$syslog_err_priority = LOG_ERR;
|
||||||
|
$syslog_info_priority = LOG_INFO;
|
||||||
|
|
||||||
|
1;
|
Loading…
Reference in New Issue