mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 08:34:46 +02:00
parent
92db819eae
commit
d5862c4495
@ -20,6 +20,7 @@ sub new {
|
|||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
$connector = {};
|
$connector = {};
|
||||||
bless $connector, $class;
|
bless $connector, $class;
|
||||||
|
$connector->set_signal_handlers;
|
||||||
|
|
||||||
$connector->{child_proc} = {};
|
$connector->{child_proc} = {};
|
||||||
$connector->{return_child} = {};
|
$connector->{return_child} = {};
|
||||||
@ -82,13 +83,13 @@ sub class_handle_CHLD {
|
|||||||
|
|
||||||
sub handle_TERM {
|
sub handle_TERM {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{logger}->writeLogInfo("$$ Receiving order to stop...");
|
$self->{logger}->writeLogInfo("connector '" . $self->{whoaim} . "' Receiving order to stop...");
|
||||||
$self->{stop} = 1;
|
$self->{stop} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub handle_HUP {
|
sub handle_HUP {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{logger}->writeLogInfo("$$ Receiving order to reload...");
|
$self->{logger}->writeLogInfo("connector $$ Receiving order to reload...");
|
||||||
# TODO
|
# TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +164,7 @@ sub reqclient {
|
|||||||
$self->{modules_registry}->{$result->{command}}->run();
|
$self->{modules_registry}->{$result->{command}}->run();
|
||||||
|
|
||||||
centreon::esxd::common::response(token => 'RESPSERVER2', endpoint => $backend, reinit => 'ipc://routing.ipc');
|
centreon::esxd::common::response(token => 'RESPSERVER2', endpoint => $backend, reinit => 'ipc://routing.ipc');
|
||||||
|
zmq_close($backend);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -223,8 +225,10 @@ sub run {
|
|||||||
eval {
|
eval {
|
||||||
$connector->{session1}->logout();
|
$connector->{session1}->logout();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
exit (0);
|
|
||||||
|
zmq_close($backend);
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -193,6 +193,11 @@ sub handle_TERM {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{logger}->writeLogInfo("$$ Receiving order to stop...");
|
$self->{logger}->writeLogInfo("$$ Receiving order to stop...");
|
||||||
$self->{stop} = 1;
|
$self->{stop} = 1;
|
||||||
|
|
||||||
|
foreach (keys %{$self->{childs_vpshere_pid}}) {
|
||||||
|
kill('TERM', $_);
|
||||||
|
$self->{logger}->writeLogInfo("Send -TERM signal to '" . $self->{childs_vpshere_pid}->{$_} . "' process..");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub handle_HUP {
|
sub handle_HUP {
|
||||||
@ -208,6 +213,7 @@ sub handle_CHLD {
|
|||||||
while (($child_pid = waitpid(-1, &WNOHANG)) > 0) {
|
while (($child_pid = waitpid(-1, &WNOHANG)) > 0) {
|
||||||
$self->{return_child}{$child_pid} = {status => 1, rtime => time()};
|
$self->{return_child}{$child_pid} = {status => 1, rtime => time()};
|
||||||
}
|
}
|
||||||
|
|
||||||
$SIG{CHLD} = \&class_handle_CHLD;
|
$SIG{CHLD} = \&class_handle_CHLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,20 +235,20 @@ sub verify_child_vsphere {
|
|||||||
foreach (keys %{$self->{return_child}}) {
|
foreach (keys %{$self->{return_child}}) {
|
||||||
delete $self->{return_child}->{$_};
|
delete $self->{return_child}->{$_};
|
||||||
|
|
||||||
# We need to quit
|
|
||||||
if ($self->{stop} != 0) {
|
|
||||||
my $name = $self->{childs_vpshere_pid}->{$_};
|
|
||||||
$self->{centreonesxd_config}->{vsphere_server}->{$name}->{running} = 0;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined($self->{childs_vpshere_pid}->{$_})) {
|
if (defined($self->{childs_vpshere_pid}->{$_})) {
|
||||||
$self->{logger}->writeLogError("Sub-process for '" . $self->{childs_vpshere_pid}->{$_} . "' dead ???!! We relaunch it");
|
if ($self->{stop} == 0) {
|
||||||
$self->create_vsphere_child(vsphere_name => $self->{childs_vpshere_pid}->{$_});
|
$self->{logger}->writeLogError("Sub-process for '" . $self->{childs_vpshere_pid}->{$_} . "'???!! we relaunch it!!!");
|
||||||
|
|
||||||
|
$self->create_vsphere_child(vsphere_name => $self->{childs_vpshere_pid}->{$_});
|
||||||
|
} else {
|
||||||
|
$self->{logger}->writeLogInfo("Sub-process for '" . $self->{childs_vpshere_pid}->{$_} . "' dead ???!!");
|
||||||
|
$self->{centreonesxd_config}->{vsphere_server}->{$self->{childs_vpshere_pid}->{$_}}->{running} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
delete $self->{childs_vpshere_pid}->{$_};
|
delete $self->{childs_vpshere_pid}->{$_};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
foreach (keys %{$self->{centreonesxd_config}->{vsphere_server}}) {
|
foreach (keys %{$self->{centreonesxd_config}->{vsphere_server}}) {
|
||||||
if ($self->{centreonesxd_config}->{vsphere_server}->{$_}->{running} == 1) {
|
if ($self->{centreonesxd_config}->{vsphere_server}->{$_}->{running} == 1) {
|
||||||
@ -399,14 +405,9 @@ sub run {
|
|||||||
# No childs
|
# No childs
|
||||||
if ($count == 0) {
|
if ($count == 0) {
|
||||||
$centreonesxd->{logger}->writeLogInfo("Quit main process");
|
$centreonesxd->{logger}->writeLogInfo("Quit main process");
|
||||||
|
zmq_close($frontend);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
foreach (keys %{$centreonesxd->{centreonesxd_config}->{vsphere_server}}) {
|
|
||||||
$centreonesxd->{logger}->writeLogInfo("Send STOP command to '$_' child.");
|
|
||||||
zmq_sendmsg($frontend, "server-" . $_, ZMQ_SNDMORE);
|
|
||||||
zmq_sendmsg($frontend, "STOP");
|
|
||||||
}
|
|
||||||
$centreonesxd->{stop} = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zmq_poll(\@poll, 5000);
|
zmq_poll(\@poll, 5000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user