WIP
This commit is contained in:
Quentin Garnier 2014-10-21 15:30:42 +02:00
parent d5862c4495
commit 0870631b9f
4 changed files with 19 additions and 10 deletions

View File

@ -23,9 +23,9 @@ sub getCommandName {
sub checkArgs {
my ($self, %options) = @_;
if (!defined($options{arguments}->{esx_hostname}) || $options{arguments}->{esx_hostname} eq "") {
if (defined($options{arguments}->{esx_hostname}) && $options{arguments}->{esx_hostname} eq "") {
$options{manager}->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Argument error: need esx hostname");
short_msg => "Argument error: esx hostname cannot be null");
return 1;
}
return 0;
@ -103,7 +103,7 @@ sub run {
}
# Storage
if ($self->{storage_status} == 1 && defined($storageStatusInfo)) {
if (defined($self->{storage_status}) && defined($storageStatusInfo)) {
foreach (@$storageStatusInfo) {
if ($_->status->key =~ /^red$/i) {
$self->{manager}->{output}->output_add(long_msg => $_->name . ": " . $_->status->summary);

View File

@ -13,6 +13,7 @@ use centreon::plugins::output;
use centreon::plugins::perfdata;
my $manager_display = {};
my $flag = ZMQ_NOBLOCK | ZMQ_SNDMORE;
sub init_response {
$manager_display->{options} = centreon::plugins::options->new();
@ -39,11 +40,14 @@ sub response {
my $context = zmq_init();
$options{endpoint} = zmq_socket($context, ZMQ_DEALER);
zmq_connect($options{endpoint}, $options{reinit});
# we wait 10 seconds after. If not there is a problem... so we can quit
# dialog from vsphere response to router
zmq_setsockopt($options{endpoint}, ZMQ_LINGER, 10000);
}
if (defined($options{identity})) {
zmq_sendmsg($options{endpoint}, $options{identity}, ZMQ_SNDMORE);
zmq_sendmsg($options{endpoint}, $options{identity}, $flag);
}
zmq_sendmsg($options{endpoint}, $options{token} . " " . $stdout);
zmq_sendmsg($options{endpoint}, $options{token} . " " . $stdout, ZMQ_NOBLOCK);
}
sub vmware_error {

View File

@ -34,7 +34,6 @@ sub new {
$connector->{perfcounter_refreshrate} = 20;
$connector->{perfcounter_speriod} = -1;
$connector->{stop} = 0;
$connector->{childs_vpshere_pid} = {};
$connector->{session1} = undef;
$connector->{modules_registry} = $options{modules_registry};
@ -120,7 +119,10 @@ sub verify_child {
# Verify process
foreach (keys %{$self->{child_proc}}) {
# Check ctime
if (time() - $self->{child_proc}->{$_}->{ctime} > $self->{config_child_timeout}) {
if (defined($self->{return_child}->{$self->{child_proc}->{$_}->{pid}})) {
delete $self->{return_child}->{$_};
delete $self->{child_proc}->{$_};
} elsif (time() - $self->{child_proc}->{$_}->{ctime} > $self->{config_child_timeout}) {
$self->response_router(severity => 'UNKNOWN', msg => 'Timeout process',
identity => $_);
kill('INT', $self->{child_proc}->{$_}->{pid});
@ -196,6 +198,7 @@ sub run {
$backend = zmq_socket($context, ZMQ_DEALER);
zmq_setsockopt($backend, ZMQ_IDENTITY, "server-" . $connector->{whoaim});
zmq_setsockopt($backend, ZMQ_LINGER, 0); # we discard
zmq_connect($backend, 'ipc://routing.ipc');
# Initialize poll set
@ -209,7 +212,7 @@ sub run {
while (1) {
my $progress = $connector->verify_child();
#####
# Manage ending
#####

View File

@ -291,8 +291,9 @@ sub request {
return ;
}
zmq_sendmsg($frontend, "server-" . $result->{container}, ZMQ_SNDMORE);
zmq_sendmsg($frontend, 'REQCLIENT ' . $options{data});
my $flag = ZMQ_NOBLOCK | ZMQ_SNDMORE;
zmq_sendmsg($frontend, "server-" . $result->{container}, $flag);
zmq_sendmsg($frontend, 'REQCLIENT ' . $options{data}, ZMQ_NOBLOCK);
}
sub repserver {
@ -374,6 +375,7 @@ sub run {
my $context = zmq_init();
$frontend = zmq_socket($context, ZMQ_ROUTER);
zmq_setsockopt($frontend, ZMQ_LINGER, 0); # we discard
zmq_bind($frontend, 'tcp://*:5700');
zmq_bind($frontend, 'ipc://routing.ipc');