[host] Avoir uniquement l'average totale dans les perfdata


git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@43 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
Quentin Garnier 2012-10-08 13:34:23 +00:00
parent 5d11abb2e5
commit 8aa332fa74
2 changed files with 12 additions and 5 deletions

View File

@ -19,6 +19,7 @@ my %OPTION = (
"esxd-host" => undef, "esxd-port" => 5700,
"vsphere" => '',
"usage" => undef,
"light-perfdata" => undef,
"esx-host" => undef,
"datastore" => undef,
"nic" => undef,
@ -39,6 +40,7 @@ GetOptions(
"e|esx-host=s" => \$OPTION{'esx-host'},
"vm=s" => \$OPTION{'vm'},
"light-perfdata" => \$OPTION{'light-perfdata'},
"datastore=s" => \$OPTION{'datastore'},
"nic=s" => \$OPTION{'nic'},
@ -97,6 +99,7 @@ sub print_usage () {
print " -e (--esx-host) Esx Host to check (required)\n";
print " -w (--warning) Warning Threshold in percent (default 80)\n";
print " -c (--critical) Critical Threshold in percent (default 90)\n";
print " --light-perfdata Display only total average cpu perfdata\n";
print "\n";
print "'nethost':\n";
print " -e (--esx-host) Esx Host to check (required)\n";
@ -289,11 +292,14 @@ sub cpuhost_check_arg {
if (!defined($OPTION{'critical'})) {
$OPTION{'critical'} = 90;
}
if (!defined($OPTION{'light-perfdata'})) {
$OPTION{'light-perfdata'} = 0;
}
return 0;
}
sub cpuhost_get_str {
return "cpuhost|" . $OPTION{'vsphere'} . "|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
return "cpuhost|" . $OPTION{'vsphere'} . "|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'} . "|" . $OPTION{'light-perfdata'};
}
sub datastoreshost_check_arg {

View File

@ -1,5 +1,5 @@
sub cpuhost_check_args {
my ($host, $warn, $crit) = @_;
my ($host, $warn, $crit, $light_perfdata) = @_;
if (!defined($host) || $host eq "") {
writeLogFile(LOG_ESXD_ERROR, "ARGS error: need hostname\n");
return 1;
@ -23,11 +23,12 @@ sub cpuhost_compute_args {
my $lhost = $_[0];
my $warn = (defined($_[1]) ? $_[1] : 80);
my $crit = (defined($_[2]) ? $_[2] : 90);
return ($lhost, $warn, $crit);
my $light_perfdata = (defined($_[3]) ? $_[3] : 0);
return ($lhost, $warn, $crit, $light_perfdata);
}
sub cpuhost_do {
my ($lhost, $warn, $crit) = @_;
my ($lhost, $warn, $crit, $light_perfdata) = @_;
if (!($perfcounter_speriod > 0)) {
my $status |= $MYERRORS_MASK{'UNKNOWN'};
print_response($ERRORS{$MYERRORS{$status}} . "|Can't retrieve perf counters.\n");
@ -66,7 +67,7 @@ sub cpuhost_do {
$cib = -1 if (!defined($cib) || $cib eq "");
$cia <=> $cib} keys %$values) {
my ($counter_id, $instance) = split /:/, $id;
if ($instance ne "") {
if ($instance ne "" and $light_perfdata != 1) {
$output .= " cpu$instance=" . simplify_number(convert_number($values->{$id}[0]) * 0.01) . "%;;0;100";
}
}