From e14f45651de73584aaca54597fb387f59437a600 Mon Sep 17 00:00:00 2001 From: Yoann LAMY Date: Tue, 26 Apr 2011 19:05:58 +0200 Subject: [PATCH] check_esx3.pl: Added power consumption --- check_esx3.pl | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/check_esx3.pl b/check_esx3.pl index a887b9c..73075e8 100755 --- a/check_esx3.pl +++ b/check_esx3.pl @@ -175,6 +175,7 @@ my $np = Nagios::Plugin->new( . " + adapter - list bus adapters\n" . " + lun - list SCSI logical units\n" . " + path - list logical unit paths\n" + . " * power - shows power consumption in watts\n" . " DC specific :\n" . " * io - shows disk io info\n" . " + aborted - aborted commands count\n" @@ -433,6 +434,10 @@ eval { ($result, $output) = host_net_info($esx, $np, $subcommand); } + elsif (uc($command) eq "POWER") + { + ($result, $output) = host_power_info($esx, $np); + } elsif (uc($command) eq "IO") { ($result, $output) = host_disk_io_info($esx, $np, $subcommand); @@ -903,6 +908,25 @@ sub host_mem_info return ($res, $output); } +sub host_power_info +{ + my ($host, $np, $subcommand) = @_; + + my $res = CRITICAL; + my $output = 'HOST POWER Unknown error'; + + $values = return_host_performance_values($host, 'power', ('power.average')); + if (defined($values)) + { + my $value = simplify_number(convert_number($$values[0][0]->value)); + $np->add_perfdata(label => "power", value => $value, uom => 'W', threshold => $np->threshold); + $output = "power=" . $value . " Watts"; + $res = $np->check_threshold(check => $value); + } + + return ($res, $output); +} + sub host_net_info { my ($host, $np, $subcommand) = @_; -- 1.7.5