#!/usr/bin/perl -w # Copyright 2006 VMware, Inc. All rights reserved. # Script modificado para chequear la temperatura ambiente reportada por ESXi3 # en un servidor Dell PE2950 - fcanepa 20090831 ############################################################################# # modified version of the modified version from Carlos Tronco # http://cars.lostroncos.org/2008/02/21/checking-storage-on-a-dell-poweredge-2900-running-esx-3i # originally from the VMware VI-Perl toolkit samples. # Written to work with a DELL 2959. It queries the host to get ambient # (chassis) temp info status. It works with ESX 3i and maybe on vSPHERE. # sample cmdline for checking one host: # check_dell2950_temp -password -username -server # # use strict; use warnings; use VMware::VIRuntime; #Set the version # for this script so it can be queried from command line $Util::script_version = "1.5"; # my %ERRORS=('GREEN'=>0, 'YELLOW'=>1, 'RED'=>2, 'UNKNOWN'=>3, 'DEPENDENT'=>4); my $verbose = 0; # read/validate command line options and connect to the server Opts::add_options(); Opts::parse(); Opts::validate(); # Connect to the server Util::connect(); # get all hosts under this datacenter my $host = Vim::find_entity_view(view_type => 'HostSystem', filter =>{}); if (!$host) { die "Host '" . get_option('server'). "' not found\n"; } #storage element holder. my $element; # Array Index my $idx; # Status Red/Green/Yellow my $hoststatus; # Descriptive Text for status my $hoststatusdesc; # if ($verbose) {print "Hosts found:\n";} # Assume everything is green to start with $hoststatus = "Green" ; # Empty our descriptive text $hoststatusdesc = ""; #Just so we know we're getting a valid connection if ($verbose) {print "Boot time " . $host->runtime->bootTime . "\n";} $element = $host->runtime->healthSystemRuntime->systemHealthInfo->numericSensorInfo->[4]; my ($ele_baseUnits,$ele_name,$ele_status_summary, $ele_status_key, $ele_status_label, $ele_opinfo_prop, $ele_opinfo_val); $ele_name = $element->name; $ele_baseUnits = $element->baseUnits; $ele_status_summary = $element->currentReading; # TEMP VALUE $ele_status_label = $element->currentReading; # $ele_status_label = 3000; # manual value for testing print "$ele_name has status of $ele_status_label $ele_baseUnits\n"; my $worst_ele = "RED"; if ($ele_status_label lt 1500) { $worst_ele = "RED"; } elsif ($ele_status_label lt 2300) { $worst_ele = "GREEN"; } elsif ($ele_status_label lt 3000) { $worst_ele = "YELLOW"; } elsif ($ele_status_label gt 2999) { $worst_ele = "RED"; }; # disconnect from the server Util::disconnect(); #exit 0; exit $ERRORS{$worst_ele};