Gestion de plusieurs VirtualCenter


git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@39 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
Quentin Garnier 2012-10-08 09:46:34 +00:00
parent 642c14fc91
commit c4cdaceee4
3 changed files with 19 additions and 16 deletions

View File

@ -6,7 +6,7 @@ use IO::Socket;
use Getopt::Long;
my $PROGNAME = $0;
my $VERSION = "1.0";
my $VERSION = "1.3";
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
my $socket;

View File

@ -17,7 +17,6 @@ use VMware::VIRuntime;
use VMware::VILib;
use IO::Socket;
use File::Basename;
use Net::hostent; # for OOish version of gethostbyaddr
use IO::Select;
use POSIX ":sys_wait_h";
use Data::Dumper;
@ -61,6 +60,8 @@ require $libpath . '/command-statushost.pm';
require $libpath . '/command-swaphost.pm';
require $libpath . '/command-toolsvm.pm';
our $VERSION = "1.3";
our $session_id;
our %sockets = ();
our %child_proc;
@ -451,7 +452,7 @@ while (1) {
}
my $tmp_handle = ${$vsphere_server{$vsphere_name}->{'writer_two'}};
print $tmp_handle $current_fileno . "." . $sockets{$current_fileno}->{'counter'} . "|$name|@args\n";
print $tmp_handle $current_fileno . "." . $sockets{$current_fileno}->{'counter'} . "|$name|" . join('|', @args) . "\n";
} else {
delete $sockets{$current_fileno};
$rh->send("3|Need arguments\n");

View File

@ -23,7 +23,7 @@ sub snapshotvm_compute_args {
sub snapshotvm_do {
my ($lvm, $older, $warn, $crit) = @_;
if ($module_date_parse_loaded == 0) {
if ($older != -1 && $module_date_parse_loaded == 0) {
my $status |= $MYERRORS_MASK{'UNKNOWN'};
print_response($ERRORS{$MYERRORS{$status}} . "|Need to install DateTime::Format::ISO8601 CPAN Module.\n");
return ;
@ -45,10 +45,11 @@ sub snapshotvm_do {
return ;
}
# 2012-09-21T14:16:17.540469Z
foreach my $snapshot (@{$$result[0]->{'snapshot.rootSnapshotList'}}) {
if ($older != -1) {
# 2012-09-21T14:16:17.540469Z
my $create_time = DateTime::Format::ISO8601->parse_datetime($snapshot->createTime);
if ($older != -1 && time() - $create_time->epoch > $older) {
if (time() - $create_time->epoch > $older) {
if ($warn == 1) {
$output = 'Older snapshot problem (' . $snapshot->createTime . ').';
$status |= $MYERRORS_MASK{'WARNING'};
@ -57,13 +58,14 @@ sub snapshotvm_do {
$output = 'Older snapshot problem (' . $snapshot->createTime . ').';
$status |= $MYERRORS_MASK{'CRITICAL'};
}
}
} elsif ($older == -1) {
if ($warn == 1) {
$output = 'There is at least one snapshot (' . $snapshot->createTime . ').';
$output = 'There is at least one snapshot.';
$status |= $MYERRORS_MASK{'WARNING'};
}
if ($crit == 1) {
$output = 'There is at least one snapshot (' . $snapshot->createTime . ').';
$output = 'There is at least one snapshot.';
$status |= $MYERRORS_MASK{'CRITICAL'};
}
}