git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@49 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
Quentin Garnier 2013-02-05 09:52:54 +00:00
parent d153fe1bfd
commit 3572b61ed4
3 changed files with 33 additions and 4 deletions

View File

@ -30,6 +30,7 @@ if (!$@) {
}
use vars qw($libpath $port %vsphere_server $TIMEOUT_VSPHERE $TIMEOUT $TIMEOUT_KILL $REFRESH_KEEPER_SESSION);
use vars qw($credstore_use $credstore_file);
use vars qw($LOG $log_mode $log_crit $log_facility);
use vars qw($openlog_option $syslog_err_priority $syslog_info_priority);
@ -63,7 +64,6 @@ require $libpath . '/command-swapvm.pm';
require $libpath . '/command-toolsvm.pm';
require $libpath . '/command-uptimehost.pm';
our $VERSION = "1.3.1";
our $session_id;
our %sockets = ();
@ -96,6 +96,34 @@ if ($ENV{ESX_SYSLOGD_LOAD} == 1) {
require $libpath . '/esxd-syslog.pm';
}
##### credstore check #####
if (defined($credstore_use) && defined($credstore_file) &&
$credstore_use == 1 && -e "$credstore_file") {
eval 'require VMware::VICredStore';
if ($@) {
writeLogFile(LOG_ESXD_ERROR, "Could not load module VMware::VICredStore\n");
exit(1);
}
require VMware::VICredStore;
if (VMware::VICredStore::init(filename => $credstore_file) == 0) {
writeLogFile("Credstore init failed: $@\n");
exit(1);
}
###
# Get password
###
foreach (keys %vsphere_server) {
my $lpassword = VMware::VICredStore::get_password(server => $_, username => $vsphere_server{$_}->{'username'});
if (!defined($lpassword)) {
writeLogFile("Can't get password for couple host='" . $_ . "', username='" . $vsphere_server{$_}->{'username'} . "' : $@\n");
exit(1);
}
$vsphere_server{$_}->{'password'} = $lpassword;
}
}
our %ERRORS = ( "OK" => 0, "WARNING" => 1, "CRITICAL" => 2, "UNKNOWN" => 3, "PENDING" => 4);
our %MYERRORS = (0 => "OK", 1 => "WARNING", 3 => "CRITICAL", 7 => "UNKNOWN");
our %MYERRORS_MASK = ("CRITICAL" => 3, "WARNING" => 1, "UNKNOWN" => 7, "OK" => 0);

View File

@ -8,6 +8,9 @@ our %vsphere_server = ('default' => {'url' => 'https://XXXXXX/sdk',
'username' => 'XXXXX',
'password' => 'XXXXXX'}
);
# Set to '1' if you use credstore file. Don't have to specify password.
our $credstore_use = 0;
our $credstore_file = "/root/.vmware/credstore/vicredentials.xml";
our $TIMEOUT_VSPHERE = 60;
our $TIMEOUT = 60;
our $TIMEOUT_KILL = 30;

View File

@ -41,7 +41,7 @@ sub memvm_do {
return ;
}
$memory_size = $$result[0]->{'summary.config.memorySizeMB'} * 1024 * 1024;
my $memory_size = $$result[0]->{'summary.config.memorySizeMB'} * 1024 * 1024;
my $values = generic_performance_values_historic($$result[0],
[{'label' => 'mem.active.average', 'instances' => ['']},
@ -51,8 +51,6 @@ sub memvm_do {
{'label' => 'mem.shared.average', 'instances' => ['']}],
$perfcounter_speriod);
writeLogFile(1, Data::Dumper::Dumper($values));
my $mem_consumed = simplify_number(convert_number($values->{$perfcounter_cache{'mem.consumed.average'}->{'key'} . ":"}[0]));
my $mem_active = simplify_number(convert_number($values->{$perfcounter_cache{'mem.active.average'}->{'key'} . ":"}[0]));
my $mem_overhead = simplify_number(convert_number($values->{$perfcounter_cache{'mem.overhead.average'}->{'key'} . ":"}[0]));