#!/usr/bin/perl -w # Copyright (c) 2009-2010 William Lam All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author or contributors may not be used to endorse or # promote products derived from this software without specific prior # written permission. # 4. Consent from original author prior to redistribution # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. ################################################################## # Author: William Lam # 03/03/2010 # http://www.virtuallyghetto.com ################################################################## use strict; use warnings; use Math::BigInt; use Tie::File; use POSIX qw/mktime/; use Socket; use Getopt::Long; use POSIX qw(ceil floor); use VMware::VIRuntime; use VMware::VILib; use Net::SMTP; ########### DO NOT MODIFY PAST HERE ########### ################################ # VERSION ################################ my $version = "5.0.2"; $Util::script_version = $version; my @supportedVersion = qw(4.0.0 4.1.0 5.0.0); my %opts = ( cluster => { type => "=s", help => "The name of a vCenter cluster to query", required => 0, }, datacenter => { type => "=s", help => "The name of a vCenter datacenter to query", required => 0, }, hostlist => { type => "=s", help => "File containting list of ESX/ESXi host(s) to query", required => 0, }, vmlist => { type => "=s", help => "File containting list of VM(s) to query", required => 0, }, type => { type => "=s", help => "Type: [vcenter|datacenter|cluster|host]\n", required => 1, }, report => { type => "=s", help => "The name of the report to output. Please add \".html\" extension", required => 0, default => "vmware_health_report.html", }, logcount => { type => "=s", help => "The number of lines to output from hostd logs", required => 0, default => 15, }, vmperformance => { type => "=s", help => "Enable VM Performance gathering [yes|no] (Can potentially double your runtime)", required => 0, default => "no", }, hostperformance => { type => "=s", help => "Enable Host Performance gathering [yes|no] (Can potentially increase your runtime)", required => 0, default => "no", }, clusterperformance => { type => "=s", help => "Enable Cluster Performance gathering [yes|no] (Can potentially increase your runtime)", required => 0, default => "no", }, email => { type => "=s", help => "[yes|no]", required => 0, default => "no", }, demo => { type => "=s", help => "[yes|no]", required => 0, default => "no", }, conf => { type => "=s", help => "File containing Host and VM specific configurations to output", required => 0, }, printerfriendly => { type => "=s", help => "Whether the html output will be printer friendly [yes|no]", required => 0, default => "no", }, debug => { type => "=s", help => "Enable/Disable debugging to help William troubleshot [0|1]", required => 0, }, ); # validate options, and connect to the server Opts::add_options(%opts); # validate options, and connect to the server Opts::parse(); Opts::validate(); Util::connect(); ############### # GLOBAL VARS ############### my ($system_name, $host_name,$hostlist,$vmlist,$service_content,$hostType,$apiType,$apiVersion,$report,$my_time,$start_time,$demo,$email,$printerfriendly,$logcount,$vmperformance,$hostperformance,$clusterperformance,$type,$clusterInput,$datacenterInput,$hostfileInput,$cluster_view,$cluster_views,$datacenter_views,$datacenter_view,$host_view,$conf,$debug); my (@vmw_apps,@perf_host_list,@vms_perf,@hosts_in_cluster,@portgroups_in_cluster,@hosts_seen,@datastores_seen,@hosts_in_portgroups,@dvs,@vmsnapshots,@vmdeltas) = (); my (%hostlists,%vmlists,%configurations,%vmmac_to_portgroup_mapping,%vswitch_portgroup_mappping,%lun_row_info,%luns,%datastore_row_info,%datastores,%portgroup_row_info,%seen_dvs) = (); my ($hardwareConfigurationString,$stateString,$hostString,$healthHardwareString,$healthSoftwareString,$nicString,$configString,$hbaString,$cdpString,$lunString,$datastoreString,$cacheString,$portgroupString,$multipathString,$dvsString,$logString,$taskString,$numaString,$hostPerfString,$vmString,$vmstateString,$vmconfigString,$vmstatString,$vmftString,$vmeztString,$vmtoolString,$vmstorageString,$vmnetworkString,$vmthinString,$vmPerfString,$vmsnapString,$vmcdString,$vmflpString,$vmrdmString,$vmdeltaString,$vmnpivString,$advString,$agentString,$mgmtString,$vmrscString,$capString,$vmdeviceString,$iscsiString) = ("","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""); my (@datastore_cluster_jump_tags,@cluster_jump_tags,@host_jump_tags,@vm_jump_tags) = (); ############### # COLORS ############### my $green = "#00FF00"; my $red = "#FF0000"; my $orange = "#FF6600"; my $yellow = "#FFFF33"; my $white = "#FFFFFF"; my $light_green = "#66FF99"; my $light_red = "#FF6666"; ############################ # PARSE COMMANDLINE OPTIONS ############################# $system_name = Opts::get_option('server'); $report = Opts::get_option('report'); $demo = Opts::get_option('demo'); $email = Opts::get_option('email'); $logcount = Opts::get_option('logcount'); $vmperformance = Opts::get_option('vmperformance'); $hostperformance = Opts::get_option('hostperformance'); $clusterperformance = Opts::get_option('clusterperformance'); $type = Opts::get_option('type'); $clusterInput = Opts::get_option('cluster'); $datacenterInput = Opts::get_option('datacenter'); $conf = Opts::get_option('conf'); $hostlist = Opts::get_option('hostlist'); $vmlist = Opts::get_option('vmlist'); $printerfriendly = Opts::get_option('printerfriendly'); $debug = Opts::get_option('debug'); ########################## # DEFAULT CONFIGUFRATION ########################## my $EMAIL_HOST = ''; my $EMAIL_DOMAIN = ''; my @EMAIL_TO = ''; my $EMAIL_FROM = ''; my $YELLOW_WARN = 30; my $ORANGE_WARN = 15; my $RED_WARN = 10; my $SNAPSHOT_YELLOW_WARN = 15; my $SNAPSHOT_ORANGE_WARN = 30; my $SNAPSHOT_RED_WARN = 60; my $SYSTEM_LICENSE="yes"; my $SYSTEM_FEATURE="yes"; my $SYSTEM_PERMISSION="yes"; my $SYSTEM_SESSION="yes"; my $SYSTEM_HOST_PROFILE="yes"; my $SYSTEM_PLUGIN="yes"; my $DVS_SUMMARY="yes"; my $DVS_CAPABILITY="yes"; my $DVS_CONFIG="yes"; my $DATASTORE_CLUSTER_SUMMARY="yes"; my $DATASTORE_CLUSTER_POD_CONFIG="yes"; my $DATASTORE_CLUSTER_POD_ADV_CONFIG="yes"; my $DATASTORE_CLUSTER_POD_STORAGE="yes"; my $CLUSTER_SUMMARY="yes"; my $CLUSTER_PERFORMANCE="no"; my $CLUSTER_HA="yes"; my $CLUSTER_DRS="yes"; my $CLUSTER_DPM="yes"; my $CLUSTER_AFFINITY="yes"; my $CLUSTER_GROUP="yes"; my $CLUSTER_RP="yes"; my $CLUSTER_VAPP="yes"; my $HOST_HARDWARE_CONFIGURATION="yes"; my $HOST_MGMT="yes"; my $HOST_STATE="yes"; my $HOST_HEALTH="yes"; my $HOST_PERFORMANCE="no"; my $HOST_NIC="yes"; my $HOST_HBA="yes"; my $HOST_CAPABILITY="yes"; my $HOST_CONFIGURATION="yes"; my $HOST_VMOTION="yes"; my $HOST_GATEWAY="yes"; my $HOST_ISCSI="yes"; my $HOST_IPV6="yes"; my $HOST_FT="yes"; my $HOST_SSL="yes"; my $HOST_DNS="yes"; my $HOST_UPTIME="yes"; my $HOST_DIAGONISTIC="yes"; my $HOST_AUTH_SERVICE="yes"; my $HOST_SERVICE="yes"; my $HOST_NTP="yes"; my $HOST_VSWIF="yes"; my $HOST_VMKERNEL="yes"; my $HOST_VSWITCH="yes"; my $HOST_SNMP="yes"; my $HOST_FIREWALL="yes"; my $HOST_POWER="yes"; my $HOST_FEATURE_VERSION="yes"; my $HOST_ADVOPT="yes"; my $HOST_AGENT="yes"; my $HOST_NUMA="yes"; my $HOST_CDP="yes"; my $HOST_DVS="yes"; my $HOST_LUN="yes"; my $HOST_DATASTORE="yes"; my $HOST_CACHE="yes"; my $HOST_MULTIPATH="yes"; my $HOST_PORTGROUP="yes"; my $HOST_LOG="yes"; my $HOST_TASK="yes"; my $VM_STATE = "yes"; my $VM_CONFIG="yes"; my $VM_STATS="yes"; my $VM_RESOURCE_ALLOCATION="yes"; my $VM_PERFORMANCE="no"; my $VM_FT="yes"; my $VM_EZT="yes"; my $VM_THIN="yes"; my $VM_DEVICE="yes"; my $VM_STORAGE="yes"; my $VM_NETWORK="yes"; my $VM_SNAPSHOT="yes"; my $VM_DELTA="no"; my $VM_CDROM="yes"; my $VM_FLOPPY="yes"; my $VM_RDM="yes"; my $VM_NPIV="yes"; my $VM_TOOL="yes"; my $VMW_APP="yes"; my $VPX_SETTING="yes"; #mwpreston - additions my $HOST_ISSUES="no"; my $SEND_EMAIL=""; ############################ # START OF SCRIPT ############################ ($service_content,$hostType,$apiType,$apiVersion) = &getServiceInfo(); &validateSystem($apiVersion); &processOptions($type,$apiType,$conf); &processAdditionalConf(); &startReport(); &startBody($apiType,$apiVersion); &getSystemSummary($service_content,$hostType,$apiType,$apiVersion); &getCluster($type,$apiType,$apiVersion); &getDatastoreCluster($type,$apiType,$apiVersion,$service_content); &getHost($type,$apiType,$apiVersion,$service_content); &getVM($type,$apiType,$apiVersion,$service_content); &getVPXSettings($VPX_SETTING,$apiType,$service_content); &getVMwareApps($VMW_APP,$apiType,$service_content); &endBody(); &endReport(); &emailReport(); ############################ # END OF SCRIPT ############################ Util::disconnect(); ##################### # HELPER FUNCTIONS ##################### sub emailReport { #MWPRESTON - modified if statement to include HOSTISSUES if($email eq "yes" and $HOSTISSUES ne "no") { my $smtp = Net::SMTP->new($EMAIL_HOST ,Hello => $EMAIL_DOMAIN,Timeout => 30,); unless($smtp) { die "Error: Unable to setup connection with email server: \"" . $EMAIL_HOST . "\"!\n"; } open(DATA, $report) || die("Could not open the file"); my @report = ; close(DATA); my @EMAIL_RECIPIENTS = $smtp->recipient(@EMAIL_TO,{SkipBad => 1}); my $boundary = 'frontier'; $smtp->mail($EMAIL_FROM); $smtp->to(@EMAIL_TO); $smtp->data(); $smtp->datasend('From: '.$EMAIL_FROM."\n"); $smtp->datasend('To: '.@EMAIL_TO."\n"); $smtp->datasend('Subject: VMware vSphere Health Check Report Completed - '.giveMeDate('MDYHMS'). " (" . $system_name . ")\n"); $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-type: multipart/mixed;\n\tboundary=\"$boundary\"\n"); $smtp->datasend("\n"); $smtp->datasend("--$boundary\n"); $smtp->datasend("Content-type: text/plain\n"); $smtp->datasend("Content-Disposition: quoted-printable\n"); #MWPRESTON - added following 2 lines. $smtp->datasend("\nProblems have been detected with the following\n"); $smtp->datasend("\n$emailMessage\n"); $smtp->datasend("\nReport $report is attached!\n"); $smtp->datasend("--$boundary\n"); $smtp->datasend("Content-Type: application/text; name=\"$report\"\n"); $smtp->datasend("Content-Disposition: attachment; filename=\"$report\"\n"); $smtp->datasend("\n"); $smtp->datasend("@report\n"); $smtp->datasend("--$boundary--\n"); $smtp->dataend(); $smtp->quit; } } sub getServiceInfo { my $sc = Vim::get_service_content(); # service content # esx,embeddedEsx,gsx,vpx # HostAgent,VirtualCenter # 4.0.0 return ($sc,$sc->about->productLineId,$sc->about->apiType,$sc->about->version); } sub getSystemSummary { my ($sc,$htype,$atype,$aversion) = @_; my $summary_start = "
\n"; ########################### # SYSTEM BUILD INFO ########################### if($atype eq 'VirtualCenter') { $summary_start .= "

VMware vCenter System Summary

" } else { if($htype eq 'esx') { $summary_start .= "

VMware ESX System Summary

" }elsif($htype eq 'embeddedEsx') { $summary_start .= "

VMware ESXi System Summary

" } } $summary_start .= "\n\n"; $summary_start .= "\n"; #$summary_start .= "\n"; $summary_start .= "
FULL NAMEVCENTER SERVERINSTANCE UUID
".$sc->about->fullName."$system_name".$sc->about->instanceUuid."
\n"; ########################### # LICENSE ########################### my ($features,$feature_string,$feature_info_string) = ("","",""); if($SYSTEM_LICENSE eq "yes") { my $licenseMgr = Vim::get_view (mo_ref => $sc->licenseManager); $summary_start .= "

Licenses:

\n"; $summary_start .= "\n"; $summary_start .= "\n"; my $licenses = $licenseMgr->licenses; foreach(@$licenses) { if($demo eq "no") { $summary_start .= "\n"; my $licenseProperties = $_->properties; if($licenseProperties) { $feature_info_string .= "\n"; $feature_info_string .= "\n"; } foreach(@$licenseProperties) { if($_->key ne 'feature') { if($_->key eq 'expirationHours' ) { $feature_info_string .= ""; } if($_->key eq 'expirationMinutes' ) { $feature_info_string .= ""; } if($_->key eq 'expirationDate' ) { $feature_info_string .= "\n"; } } else { my $feature = $_->value; $features .= "\n"; } } } else { $summary_start .= "\n"; } $feature_string .= $feature_info_string . $features; ($features,$feature_info_string) = ("",""); } $summary_start .= "
NAMEEDITIONLICENSECOST UNITTOTALCONSUMEDAVAILABLE
".$_->name."".$_->editionKey."".$_->licenseKey."".$_->costUnit."".$_->total."".$_->used."".($_->total - $_->used)."
EDITION w/FEATURESEXPIRATION (HOURS)EXPIRATION (MINS)EXPIRATION DATE
".$_->editionKey."".$_->value."".$_->value."".$_->value."
".$feature->value."
DEMO_MODEDEMO_MODEDEMO_MODEDEMO_MODEDEMO_MODEDEMO_MODEDEMO_MODE
\n"; } ########################### # FEATURES ########################### if($SYSTEM_FEATURE eq "yes" && $SYSTEM_LICENSE eq "yes") { $summary_start .= "

Features:

\n"; $summary_start .= "\n"; if($demo eq "no") { $summary_start .= $feature_string; } else { $summary_start .= "\n"; } $summary_start .= "
DEMO_MODE
\n"; } ########################### # PERMISSIONS ########################### if($SYSTEM_PERMISSION eq "yes") { $summary_start .= "

Permissions:

\n"; $summary_start .= "\n"; $summary_start .= "\n"; my $authMgr = Vim::get_view (mo_ref => $sc->authorizationManager); my $roleLists = $authMgr->roleList; my %rolemapping; foreach(@$roleLists) { $rolemapping{$_->roleId} = $_->name; } if($demo eq "no") { eval { my $permissions = $authMgr->RetrieveAllPermissions(); foreach(@$permissions) { my $ent = Vim::get_view(mo_ref => $_->entity, properties => ['name']); $summary_start .= "\n"; } }; if($@) { print "ERROR: Unable to query for permissions: " . $@ . "\n"; } } else { $summary_start .= "\n"; } $summary_start .= "
USER/GROUPROLEDEFINED INPROPAGATEIS GROUP
" . $_->principal . "" . $rolemapping{$_->roleId} . "" . $ent->{'name'} . "" . (($_->propagate) ? "YES" : "NO") . "" . (($_->group) ? "YES" : "NO") . "
DEMO_MODEDEMO_MODEDEMO_MODEDEMO_MODEDEMO_MODE
\n"; } ########################### # SESSIONS ########################### if($SYSTEM_SESSION eq "yes") { $summary_start .= "

Active Session(s):

\n"; $summary_start .= "\n"; $summary_start .= "\n"; if($demo eq "no") { my $sessionMgr = Vim::get_view (mo_ref => $sc->sessionManager); my $sess_list = $sessionMgr->sessionList; foreach(sort {$a->userName cmp $b->userName} @$sess_list) { $summary_start .= "\n"; } } else { $summary_start .= "\n"; } $summary_start .= "
USERNAMEFULL NAMELOGON TIMELAST ACTIVE
".$_->userName."".$_->fullName."".$_->loginTime."".$_->lastActiveTime."
DEMO_MODEDEMO_MODEDEMO_MODEDEMO_MODE
\n"; } ########################### # HOST PROFILES ########################### if($SYSTEM_HOST_PROFILE eq "yes") { my $hostProfileMgr; eval { $hostProfileMgr = Vim::get_view (mo_ref => $sc->hostProfileManager); }; if(!$@) { my $profiles = Vim::get_views (mo_ref_array => $hostProfileMgr->profile); my $hasProfile = 0; my $profile_string = ""; foreach(sort {$a->name cmp $b->name} @$profiles) { $hasProfile = 1; my $profileDescription = "N/A"; if($_->config->annotation) { $profileDescription = $_->config->annotation; } $profile_string .= "".$_->name."".$profileDescription."".$_->createdTime."".$_->modifiedTime."".(($_->config->enabled) ? "YES" : "NO")."".$_->complianceStatus."\n"; } if($hasProfile eq 1) { $summary_start .= "

Host Profile(s):

\n"; $summary_start .= "\n"; $summary_start .= "\n"; $summary_start .= $profile_string; } } $summary_start .= "
PROFILE NAMEDESCRIPTIONCREATION TIMELAST MODIFIEDENABLEDCOMPLIANCE STATUS
\n"; } ########################### # PLUGIN ########################### if($SYSTEM_PLUGIN eq "yes") { my $extMgr; eval { $extMgr = Vim::get_view (mo_ref => $sc->extensionManager); }; if(!$@) { my $extList = $extMgr->extensionList; my $ext_string = ""; foreach(sort {$a->description->label cmp $b->description->label} @$extList) { $ext_string .= ""; $ext_string .= "".$_->description->label.""; $ext_string .= "".($_->version ? $_->version : "N/A").""; $ext_string .= "".($_->company ? $_->company : "N/A").""; $ext_string .= "\n"; } $summary_start .= "

Plugin(s):

\n"; $summary_start .= "\n"; $summary_start .= "\n"; $summary_start .= $ext_string; $summary_start .= "
PLUGIN NAMEVERSIONCOMPANY
\n"; } } $summary_start .= "\n
"; print REPORT_OUTPUT $summary_start; } sub getCluster { my ($type,$atype,$aversion) = @_; my $cluster_count = 0; if($type eq 'cluster') { print REPORT_OUTPUT "
"; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; $cluster_count++; &printClusterSummary($cluster_view,$cluster_count,$atype,$aversion); print REPORT_OUTPUT "
\n"; }elsif($type eq 'datacenter') { $cluster_views = Vim::find_entity_views(view_type => 'ClusterComputeResource',begin_entity => $datacenter_view); if($cluster_views) { print REPORT_OUTPUT "
"; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; foreach(sort {$a->name cmp $b->name} @$cluster_views) { $cluster_count++; if($_->isa("ClusterComputeResource")) { &printClusterSummary($_,$cluster_count,$atype,$aversion); } } print REPORT_OUTPUT "
\n"; } }elsif($type eq 'vcenter') { if($cluster_views) { print REPORT_OUTPUT "
"; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; foreach(sort {$a->name cmp $b->name} @$cluster_views) { $cluster_count++; if($_->isa("ClusterComputeResource")) { &printClusterSummary($_,$cluster_count,$atype,$aversion); } } } print REPORT_OUTPUT "
\n"; } } sub getDatastoreCluster { my ($type,$atype,$aversion) = @_; my $datastore_cluster_count = 0; if($type eq 'cluster' && $aversion eq '5.0.0') { print REPORT_OUTPUT "
"; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; my $cluster_folder = Vim::get_view(mo_ref => $cluster_view->parent); my $cluster_parent = Vim::get_view(mo_ref => $cluster_folder->parent); $datastore_cluster_count++; &printDatacenterSummary($cluster_parent,$datastore_cluster_count,$atype,$aversion); print REPORT_OUTPUT "
\n"; } elsif($type eq 'datacenter' && $aversion eq '5.0.0') { print REPORT_OUTPUT "
"; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; $datastore_cluster_count++; &printDatacenterSummary($datacenter_view,$datastore_cluster_count,$atype,$aversion); print REPORT_OUTPUT "
\n"; } elsif($type eq 'vcenter' && $aversion eq '5.0.0') { print REPORT_OUTPUT "
"; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; $datacenter_views = Vim::find_entity_views(view_type => 'Datacenter'); foreach(sort {$a->name cmp $b->name} @$datacenter_views) { $datastore_cluster_count++; &printDatacenterSummary($_,$datastore_cluster_count,$atype,$aversion); } print REPORT_OUTPUT "
\n"; } } sub getHost { my ($type,$atype,$aversion,$sc) = @_; print REPORT_OUTPUT "
\n"; my $cluster_count = 0; if($type eq 'host') { #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; &printHostSummary($host_view,undef,$cluster_count,$type,$atype,$aversion,$sc); }elsif($type eq 'datacenter') { #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) { $cluster_count++; my $clusterTag = "host-".$cluster->name."-$cluster_count"; my $clusterShortTag = $cluster->name; push @host_jump_tags,"   Cluster: $clusterShortTag
\n"; print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

Cluster: $clusterShortTag

\n"; my $hosts = Vim::get_views (mo_ref_array => $cluster->host); &printHostSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc); } }elsif($type eq 'cluster') { $cluster_count++; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; my $clusterTag = "host-".$cluster_view->name."-$cluster_count"; my $clusterShortTag = $cluster_view->name; push @host_jump_tags,"   Cluster: $clusterShortTag
\n"; print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

Cluster: $clusterShortTag

\n"; my $hosts = Vim::get_views (mo_ref_array => $cluster_view->host); &printHostSummary($hosts,$cluster_view->name,$cluster_count,$type,$atype,$aversion,$sc); }elsif($type eq 'vcenter') { #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) { $cluster_count++; my $clusterTag = "host-".$cluster->name."-$cluster_count"; my $clusterShortTag = $cluster->name; push @host_jump_tags,"   Cluster: $clusterShortTag
\n"; print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

Cluster: $clusterShortTag

\n"; my $hosts = Vim::get_views (mo_ref_array => $cluster->host); &printHostSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc); } } print REPORT_OUTPUT "
\n"; } sub getVM { my ($type,$atype,$aversion,$sc) = @_; print REPORT_OUTPUT "
\n"; my $cluster_count = 0; if($type eq 'host') { #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; &printVMSummary($host_view,undef,$cluster_count,$type,$atype,$aversion,$sc); }elsif($type eq 'datacenter') { #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) { $cluster_count++; my $clusterTag = "vm-".$cluster->name."-$cluster_count"; my $clusterShortTag = $cluster->name; push @vm_jump_tags,"   Cluster: $clusterShortTag
\n"; print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

Cluster: $clusterShortTag

\n"; my $hosts = Vim::get_views (mo_ref_array => $cluster->host); &printVMSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc); } }elsif($type eq 'cluster') { $cluster_count++; #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; my $clusterTag = "vm-".$cluster_view->name."-$cluster_count"; my $clusterShortTag = $cluster_view->name; push @vm_jump_tags,"   Cluster: $clusterShortTag
\n"; print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

Cluster: $clusterShortTag

\n"; my $hosts = Vim::get_views (mo_ref_array => $cluster_view->host); &printVMSummary($hosts,$cluster_view->name,$cluster_count,$type,$atype,$aversion,$sc); }elsif($type eq 'vcenter') { #please do not touch this, else the jump tags will break print REPORT_OUTPUT "\n//\n"; foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) { $cluster_count++; my $clusterTag = "vm-".$cluster->name."-$cluster_count"; my $clusterShortTag = $cluster->name; push @vm_jump_tags,"   Cluster: $clusterShortTag
\n"; print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

Cluster: $clusterShortTag

\n"; my $hosts = Vim::get_views (mo_ref_array => $cluster->host); &printVMSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc); } } print REPORT_OUTPUT "
\n"; } sub getVPXSettings { my ($vpxcheck,$atype,$sc) = @_; if($vpxcheck eq "yes" && $atype eq "VirtualCenter") { my $setting = Vim::get_view(mo_ref => $sc->setting); my $vpxSettings = $setting->setting; my $vpxString = ""; if($vpxSettings) { print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

vCenter VPX Configurations

\n"; print REPORT_OUTPUT "\n"; print REPORT_OUTPUT "\n"; foreach(sort {$a->key cmp $b->key} @$vpxSettings) { my $key = $_->key; my $value = $_->value; if($demo eq "yes" && ($key eq "VirtualCenter.InstanceName" || $key eq "VirtualCenter.DBPassword" || $key eq "VirtualCenter.LDAPAdminPrincipal" || $key eq "VirtualCenter.ManagedIP" || $key eq "VirtualCenter.VimApiUrl" || $key eq "VirtualCenter.VimWebServicesUrl" || $key eq "vpxd.motd" || $key =~ m/config.registry/ || $key =~ m/mail/ || $key =~ m/snmp/)) { $value = "DEMO_MODE"; } $vpxString .= "\n"; } print REPORT_OUTPUT $vpxString; print REPORT_OUTPUT "
KEYVALUE
".$key."".$value."
\n"; print REPORT_OUTPUT "
\n"; } } } sub getVMwareApps { my ($vmwcheck,$atype,$sc) = @_; if($vmwcheck eq "yes" && $atype eq "VirtualCenter") { my $vmwAppString = ""; if(@vmw_apps) { print REPORT_OUTPUT "
\n"; print REPORT_OUTPUT "

VMware and 3rd Party Applications in a VM

\n"; print REPORT_OUTPUT "\n"; print REPORT_OUTPUT "\n"; foreach(@vmw_apps) { $vmwAppString .= $_; } print REPORT_OUTPUT $vmwAppString; print REPORT_OUTPUT "
CLUSTERVM NAMEVMWARE/3RD PARTY APPLICATION
\n"; print REPORT_OUTPUT "
\n"; } } } sub printVMSummary { my ($local_hosts,$cluster_name,$cluster_count,$type,$atype,$aversion,$sc) = @_; if(@$local_hosts) { foreach my $local_host(sort {$a->summary->config->name cmp $b->summary->config->name} @$local_hosts) { if($demo eq "no") { $host_name = $local_host->name; } #skip if host is not accessible next if($local_host->runtime->connectionState->val ne "connected"); #skip if VM is not in valid list if($hostlist) { next if(!$hostlists{$local_host->name}); } my $vms = Vim::get_views(mo_ref_array => $local_host->vm); foreach my $vm (sort {$a->name cmp $b->name} @$vms) { #skip if vm is disconnected next if(!defined($vm->config)); #skip if VM is not in valid list if($vmlist) { my $vmname = $vm->name; next if(!$vmlists{$vmname}); } ###################### # VM TAG ###################### if(defined($vm->tag)) { my $vmTags = $vm->tag; foreach(sort {$a->key cmp $b->key} @$vmTags) { my $tagString = "".$cluster_name."".$vm->name."".$_->key."\n"; push @vmw_apps, $tagString; } } ###################### # VM STATE ###################### if($VM_STATE eq "yes") { $vmstateString .= ""; ## ESX/ESXi host ## $vmstateString .= "".$host_name.""; ## DISPLAY NAME ## $vmstateString .= "".$vm->name.""; ## BOOT TIME ## $vmstateString .= "".($vm->runtime->bootTime ? $vm->runtime->bootTime : "N/A").""; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { ## UPTIME ## $vmstateString .= "".($vm->summary->quickStats->uptimeSeconds ? &getUptime($vm->summary->quickStats->uptimeSeconds) : "N/A").""; } ## OVERALL STATUS ## my $vm_health = $vm->summary->overallStatus->val; if ($vm_health eq 'green') { $vmstateString .= "VM is OK"; } elsif ($vm_health eq 'red') { $vmstateString .= "VM has a problem"; } elsif ($vm_health eq 'yellow') { $vmstateString .= "VM"; } else { $vmstateString .="UNKNOWN"; } if($aversion eq "5.0.0") { ## HA PROTECTION ## if($vm->runtime->dasVmProtection) { $vmstateString .= "".($vm->runtime->dasVmProtection->dasProtected ? "YES" : "NO").""; } else { $vmstateString .= "N/A"; } } else { $vmstateString .= "N/A"; } if($aversion eq "4.1.0" || $aversion eq "5.0.0") { ## APP HEARTBEAT ## $vmstateString .= "".($vm->guest->appHeartbeatStatus ? $vm->guest->appHeartbeatStatus : "N/A").""; } ## CONNECTION STATE ## $vmstateString .= "".$vm->runtime->connectionState->val.""; ## POWER STATE ## $vmstateString .= "".$vm->runtime->powerState->val.""; ## CONSOLIDATION ## if($aversion eq "5.0.0") { $vmstateString .= "".($vm->runtime->consolidationNeeded ? "YES" : "NO").""; } else { $vmstateString .= "N/A"; } $vmstateString .= ""; } ###################### # VM CONFIG ###################### if($VM_CONFIG eq "yes") { $vmconfigString .= ""; ## ESX/ESXi host ## $vmconfigString .= "".$host_name.""; ## DISPLAY NAME ## $vmconfigString .= "".$vm->name.""; ## VIRTUAL HARDWARE VER ## $vmconfigString .= "".$vm->config->version.""; ## GUEST HOSTNAME ## $vmconfigString .= "".($vm->guest->hostName ? $vm->guest->hostName : "N/A").""; ## UUID ## $vmconfigString .= "".($vm->summary->config->uuid ? $vm->summary->config->uuid : "N/A").""; ## FIRMWARE ## if($aversion eq "5.0.0") { $vmconfigString .= "".($vm->config->firmware ? $vm->config->firmware : "N/A").""; } else { $vmconfigString .= "N/A"; } ## OS ## $vmconfigString .= "".($vm->config->guestFullName ? $vm->config->guestFullName : "N/A").""; ## vCPU ## $vmconfigString .= "".($vm->summary->config->numCpu ? $vm->summary->config->numCpu : "N/A").""; ## vMEM ## $vmconfigString .= "".($vm->summary->config->memorySizeMB ? &prettyPrintData($vm->summary->config->memorySizeMB,'M') : "N/A").""; ## vDISK ## $vmconfigString .= "".($vm->summary->config->numVirtualDisks ? $vm->summary->config->numVirtualDisks : "N/A").""; ## DISK CAPACITY ## if($vm->summary->storage) { my ($commit,$uncommit) = (0,0); if(defined($vm->summary->storage->committed)) { $commit = $vm->summary->storage->committed; } if(defined($vm->summary->storage->uncommitted)) { $uncommit = $vm->summary->storage->uncommitted; } $vmconfigString .= "".&prettyPrintData(($commit + $uncommit),'B').""; } else { $vmconfigString .= "N/A"; } ## vNIC ## $vmconfigString .= "".($vm->summary->config->numEthernetCards ? $vm->summary->config->numEthernetCards : "N/A").""; if(!$vm->config->template) { ## CPU RESERV ## $vmconfigString .= "".($vm->summary->config->cpuReservation ? &prettyPrintData($vm->summary->config->cpuReservation,'MHZ') : "N/A").""; ## MEM RESERV ## $vmconfigString .= "".($vm->summary->config->memoryReservation ? &prettyPrintData($vm->summary->config->memoryReservation,'M') : "N/A").""; } else { $vmconfigString .= "N/A"; $vmconfigString .= "N/A"; } ## TEMPLATE ## $vmconfigString .= "".($vm->config->template ? "YES" : "NO").""; $vmconfigString .= "\n"; } ###################### # STATISTICS ###################### if($VM_STATS eq "yes") { if(!$vm->config->template) { $vmstatString .= ""; ## ESX/ESXi host ## $vmstatString .= "".$host_name.""; ## DISPLAY NAME ## $vmstatString .= "".$vm->name.""; ## CPU USAGE ## $vmstatString .= "".($vm->summary->quickStats->overallCpuUsage ? &prettyPrintData($vm->summary->quickStats->overallCpuUsage,'MHZ') : "N/A" ).""; ## MEM USAGE ## $vmstatString .= "".($vm->summary->quickStats->guestMemoryUsage ? &prettyPrintData($vm->summary->quickStats->guestMemoryUsage,'M') : "N/A").""; ## MAX CPU USAGE ## $vmstatString .= "".($vm->runtime->maxCpuUsage ? &prettyPrintData($vm->runtime->maxCpuUsage,'MHZ') : "N/A").""; ## MAX MEM USAGE ## $vmstatString .= "".($vm->runtime->maxMemoryUsage ? &prettyPrintData($vm->runtime->maxMemoryUsage,'M') : "N/A").""; ## ACTIVE MEM ## $vmstatString .= "".($vm->summary->quickStats->guestMemoryUsage ? &prettyPrintData($vm->summary->quickStats->guestMemoryUsage,'M') : "N/A").""; ## CONSUMED MEM ## $vmstatString .= "".($vm->summary->quickStats->hostMemoryUsage ? &prettyPrintData($vm->summary->quickStats->hostMemoryUsage,'M') : "N/A").""; ## INITIAL MEM RESV OVERHEAD + INITIAL MEM SWAP RESV OVERHEAD ## if($aversion eq "5.0.0" && $vm->config->initialOverhead) { $vmstatString .= "".($vm->config->initialOverhead->initialMemoryReservation ? &prettyPrintData($vm->config->initialOverhead->initialMemoryReservation,'B') : "N/A").""; $vmstatString .= "".($vm->config->initialOverhead->initialSwapReservation ? &prettyPrintData($vm->config->initialOverhead->initialSwapReservation,'B') : "N/A").""; } else { $vmstatString .= "N/AN/A"; } ## MEM OVERHEAD ## $vmstatString .= "".($vm->summary->quickStats->consumedOverheadMemory ? &prettyPrintData($vm->summary->quickStats->consumedOverheadMemory,'M') : "N/A").""; ## MEM BALLON ## $vmstatString .= "".($vm->summary->quickStats->balloonedMemory ? &prettyPrintData($vm->summary->quickStats->balloonedMemory,'M') : "N/A").""; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { ## COMPRESSED MEM ## if(defined($vm->summary->quickStats->compressedMemory)) { if($debug) { print "---DEBUG compressedMemory for " . $vm->name . ": \"" . $vm->summary->quickStats->compressedMemory . "\" ---DEBUG\n"; } my $compressedMem = "N/A"; if($vm->summary->quickStats->compressedMemory > 0) { $compressedMem = &prettyPrintData($vm->summary->quickStats->compressedMemory,'K'); } $vmstatString .= "".$compressedMem.""; } else { $vmstatString .= "N/A"; } } $vmstatString .= "\n"; } } ###################### # VM RESOURCE ###################### if($VM_RESOURCE_ALLOCATION eq "yes") { if(!$vm->config->template && $vm->resourceConfig) { $vmrscString .= ""; ## ESX/ESXi host ## $vmrscString .= "".$host_name.""; ## DISPLAY NAME ## $vmrscString .= "".$vm->name.""; ## MODIFIED ## $vmrscString .= "".($vm->resourceConfig->lastModified ? $vm->resourceConfig->lastModified : "N/A").""; my $cpuAllocation = $vm->resourceConfig->cpuAllocation; my $memAllocation = $vm->resourceConfig->memoryAllocation; #cpu ## RESERVATION ## $vmrscString .= "".($cpuAllocation->reservation ? &prettyPrintData($cpuAllocation->reservation,'MHZ') : "N/A").""; ## LIMIT ## $vmrscString .= "".($cpuAllocation->limit ? &prettyPrintData($cpuAllocation->limit,'MHZ') : "N/A").""; ## SHARES ## # SHARES VALUE $vmrscString .= "".($cpuAllocation->shares->shares ? $cpuAllocation->shares->shares : "N/A").""; # SHARES LEVEL $vmrscString .= "".($cpuAllocation->shares->level->val ? $cpuAllocation->shares->level->val : "N/A").""; ## EXPAND RESERVATION ## $vmrscString .= "".($cpuAllocation->expandableReservation ? "YES" : "NO").""; ## OVERHEAD LIMIT ## $vmrscString .= "".($cpuAllocation->overheadLimit ? &prettyPrintData($cpuAllocation->overheadLimit,'MHZ') : "N/A").""; #mem ## RESERVATION ## $vmrscString .= "".($memAllocation->reservation ? &prettyPrintData($memAllocation->reservation,'M') : "N/A").""; ## LIMIT ## $vmrscString .= "".($memAllocation->limit ? &prettyPrintData($memAllocation->limit,'M') : "N/A").""; ## SHARES ## # SHARES VALUE $vmrscString .= "".($memAllocation->shares->shares ? $memAllocation->shares->shares : "N/A").""; # SHARES LEVEL $vmrscString .= "".($memAllocation->shares->level->val ? $memAllocation->shares->level->val : "N/A").""; ## EXPAND RESERVATION ## $vmrscString .= "".($memAllocation->expandableReservation ? "YES" : "NO").""; ## OVERHEAD LIMIT ## $vmrscString .= "".($memAllocation->overheadLimit ? &prettyPrintData($memAllocation->overheadLimit,'M') : "N/A").""; $vmrscString .= "\n"; } } ###################### # VM PERFORMANCE ###################### if($VM_PERFORMANCE eq "yes" || $vmperformance eq "yes") { if($vm->runtime->powerState->val eq 'poweredOn') { my $vmperf = &getCpuAndMemPerf($vm); $vmPerfString .= $vmperf; } } ###################### # FT ###################### if($VM_FT eq "yes") { if(!$vm->config->template && defined($vm->summary->config->ftInfo)) { $vmftString .= ""; ## ESX/ESXi host ## $vmftString .= "".$host_name.""; ## DISPLAY NAME ## $vmftString .= "".$vm->name.""; ## FT STATE ## $vmftString .= "".$vm->runtime->faultToleranceState->val.""; ## FT ROLE ## my $role = ""; if($vm->summary->config->ftInfo->role eq 1) { $role = "PRIMARY"; } else { $role = "SECONDARY"; } $vmftString .= "".$role.""; ## FT INSTANCE UUIDS ## my $ftuuids = $vm->summary->config->ftInfo->instanceUuids; my $instanceuuids = ""; if($vm->summary->config->ftInfo->role eq 1) { $instanceuuids = $ftuuids->[0]; } else { $instanceuuids = $ftuuids->[1]; } $vmftString .= "".$instanceuuids.""; ## FT SECONDARY LATENCY ## $vmftString .= "".($vm->summary->quickStats->ftSecondaryLatency ? $vm->summary->quickStats->ftSecondaryLatency : "N/A").""; ## FT BW ## $vmftString .= "".($vm->summary->quickStats->ftLogBandwidth ? $vm->summary->quickStats->ftLogBandwidth : "N/A").""; $vmftString .= "\n"; } } ###################### # EZT ###################### if($VM_EZT eq "yes" && $aversion eq "5.0.0") { if(!$vm->config->template) { my $devices = $vm->config->hardware->device; my ($ezt_disk_string,$ezt_size_string,$ezt_label_string) = ("","",""); my $hasEZT = 0; foreach(@$devices) { if($_->isa('VirtualDisk') && $_->backing->isa('VirtualDiskFlatVer2BackingInfo')) { my $diskName = $_->backing->fileName; my $label = ($_->deviceInfo->label ? $_->deviceInfo->label : "N/A"); if(!$_->backing->thinProvisioned && defined($_->backing->eagerlyScrub)) { if($_->backing->eagerlyScrub) { $hasEZT = 1; $ezt_label_string .= $label."
"; $ezt_disk_string .= $diskName."
"; $ezt_size_string .= &prettyPrintData($_->capacityInKB,'K')."
"; } } } } if($hasEZT eq 1) { $vmeztString .= ""; ## ESX/ESXi host ## $vmeztString .= "".$host_name.""; ## DISPLAY NAME ## $vmeztString .= "".$vm->name.""; ## EZT LABEL ## $vmeztString .= "".$ezt_label_string.""; ## EZT DISKS ## $vmeztString .= "".$ezt_disk_string.""; ## EZT DISKS SIZE ## $vmeztString .= "".$ezt_size_string.""; $vmeztString .= "\n"; } } } ###################### # THIN ###################### if($VM_THIN eq "yes") { if(!$vm->config->template) { my $devices = $vm->config->hardware->device; my ($thin_disk_string,$thin_size_string,$thin_label_string) = ("","",""); my $hasThin = 0; foreach(@$devices) { if($_->isa('VirtualDisk') && $_->backing->isa('VirtualDiskFlatVer2BackingInfo')) { my $diskName = $_->backing->fileName; my $label = ($_->deviceInfo->label ? $_->deviceInfo->label : "N/A"); if($_->backing->thinProvisioned) { $hasThin = 1; $thin_label_string .= $label."
"; $thin_disk_string .= $diskName."
"; $thin_size_string .= &prettyPrintData($_->capacityInKB,'K')."
"; } } } if($hasThin eq 1) { $vmthinString .= ""; ## ESX/ESXi host ## $vmthinString .= "".$host_name.""; ## DISPLAY NAME ## $vmthinString .= "".$vm->name.""; ## THIN LABEL ## $vmthinString .= "".$thin_label_string.""; ## THIN DISKS ## $vmthinString .= "".$thin_disk_string.""; ## THIN DISKS SIZE ## $vmthinString .= "".$thin_size_string.""; $vmthinString .= "\n"; } } } ###################### # DEVICE ###################### if($VM_DEVICE eq "yes") { if(!$vm->config->template) { $vmdeviceString .= ""; ## ESX/ESXi host ## $vmdeviceString .= "".$host_name.""; ## DISPLAY NAME ## $vmdeviceString .= "".$vm->name.""; my %deviceMapper = (); my $devices = $vm->config->hardware->device; #foreach(@$devices) { # $deviceMapper{$_->key} = $_->deviceInfo->label; #} my ($cdrom,$idecontroller,$pcicontroller,$ps2controller,$paracontroller,$buscontroller,$lsicontroller,$lsilogiccontroller,$siocontroller,$usbcontroller,$disk,$e1000ethernet,$pcnet32ethernet,$vmxnet2ethernet,$vmxnet3ethernet,$floppy,$keyboard,$videocard,$vmci,$vmi,$parallelport,$pcipassthrough,$pointingdevice,$scsipassthrough,$serialport,$ensoniqsoundcard,$blastersoundcard,$usb) = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); foreach my $device (@$devices) { if($device->isa('VirtualCdrom')) { $cdrom++; }elsif($device->isa('VirtualController')) { if($device->isa('VirtualIDEController')) { $idecontroller++; }elsif($device->isa('VirtualPCIController')) { $pcicontroller++; }elsif($device->isa('VirtualPS2Controller')) { $ps2controller++; }elsif($device->isa('VirtualSCSIController')) { if($device->isa('ParaVirtualSCSIController')) { $paracontroller++; }elsif($device->isa('VirtualBusLogicController')) { $buscontroller++; }elsif($device->isa('VirtualLsiLogicController')) { $lsicontroller++; }elsif($device->isa('VirtualLsiLogicSASController')) { $lsilogiccontroller++; } }elsif($device->isa('VirtualSIOController')) { $siocontroller++; }elsif($device->isa('VirtualUSBController')) { $usbcontroller++; } }elsif($device->isa('VirtualDisk')) { $disk++; }elsif($device->isa('VirtualEthernetCard')) { if($device->isa('VirtualE1000')) { $e1000ethernet++; }elsif($device->isa('VirtualPCNet32')) { $pcnet32ethernet++; }elsif($device->isa('VirtualVmxnet')) { if($device->isa('VirtualVmxnet2')) { $vmxnet2ethernet++; }elsif($device->isa('VirtualVmxnet3')) { $vmxnet3ethernet++; } } }elsif($device->isa('VirtualFloppy')) { $floppy++; }elsif($device->isa('VirtualKeyboard')) { $keyboard++; }elsif($device->isa('VirtualMachineVideoCard')) { $videocard++; }elsif($device->isa('VirtualMachineVMCIDevice')) { $vmci++; }elsif($device->isa('VirtualMachineVMIROM')) { $vmi++; }elsif($device->isa('VirtualParallelPort')) { $parallelport++; }elsif($device->isa('VirtualPCIPassthrough')) { $pcipassthrough++; }elsif($device->isa('VirtualPointingDevice')) { $pointingdevice++; }elsif($device->isa('VirtualSCSIPassthrough')) { $scsipassthrough++; }elsif($device->isa('VirtualSerialPort')) { $serialport++; }elsif($device->isa('VirtualSoundCard')) { if($device->isa('VirtualEnsoniq1371')) { $ensoniqsoundcard++; }elsif($device->isa('VirtualSoundBlaster16')) { $blastersoundcard++; } }elsif($device->isa('VirtualUSB')) { $usb++; } } ## OS ## $vmdeviceString .= "".($vm->config->guestFullName ? $vm->config->guestFullName : "N/A").""; ## CDROM ## $vmdeviceString .= "".$cdrom.""; ## CONTROLER ## my $controllerString = ""; if($idecontroller != 0) { $controllerString .= $idecontroller . " x IDE Controller
"; } if($pcicontroller != 0) { $controllerString .= $pcicontroller . " x PCI Controller
"; } if($ps2controller != 0) { $controllerString .= $ps2controller . " x PS2 Controller
"; } if($paracontroller != 0) { $controllerString .= $paracontroller . " x PARA-VIRT Controller
"; } if($buscontroller != 0) { $controllerString .= $buscontroller . " x BUS Controller
"; } if($lsicontroller != 0) { $controllerString .= $lsicontroller . " x LSI LOGIC Controller
"; } if($lsilogiccontroller != 0) { $controllerString .= $lsilogiccontroller . " x LSI LOGIC SAS Controller
"; } if($siocontroller != 0) { $controllerString .= $siocontroller . " x SIO Controller
"; } if($usbcontroller != 0) { $controllerString .= $usbcontroller . " x USB Controller
"; } if($controllerString eq "") { $controllerString = "N/A"; } $vmdeviceString .= "".$controllerString.""; ## DISK ## $vmdeviceString .= "".$disk.""; ## ETHERNET CARD ## my $ethString = ""; if($e1000ethernet != 0) { $ethString .= $e1000ethernet . " x e1000
"; } if($pcnet32ethernet != 0) { $ethString .= $pcnet32ethernet . " x PCNET32
"; } if($vmxnet2ethernet != 0) { $ethString .= $vmxnet2ethernet . " x VMXNET2
"; } if($vmxnet3ethernet != 0) { $ethString .= $vmxnet3ethernet . " x VMXNET3
"; } if($ethString eq "") { $ethString = "N/A"; } $vmdeviceString .= "".$ethString.""; ## FLOPPY ## $vmdeviceString .= "".$floppy.""; ## KEYBOARD ## $vmdeviceString .= "".$keyboard.""; ## VIDEO CARD ## $vmdeviceString .= "".$videocard.""; ## VMCI ## $vmdeviceString .= "".$vmci.""; ## VMIROM ## $vmdeviceString .= "".$vmi.""; ## PARALLEL PORT ## $vmdeviceString .= "".$parallelport.""; ## PCI PASS THROUGH ## $vmdeviceString .= "".$pcipassthrough.""; ## POINTING DEVICE ## $vmdeviceString .= "".$pointingdevice.""; ## SCSI PASS THROUGH ## $vmdeviceString .= "".$scsipassthrough.""; ## SERIAL PORT ## $vmdeviceString .= "".$serialport.""; ## SOUND CARD ## my $soundString = ""; if($ensoniqsoundcard != 0) { $soundString .= $ensoniqsoundcard . " x Ensoiq1373 Sound Card
"; } if($blastersoundcard != 0) { $soundString .= $blastersoundcard . " x Soundblaster Sound Card
"; } if($soundString eq "") { $soundString = "N/A"; } $vmdeviceString .= "".$soundString.""; ## USB ## $vmdeviceString .= "".$usb.""; $vmdeviceString .= "\n"; } } ###################### # VM STORAGE ###################### if($VM_STORAGE eq "yes") { if(!$vm->config->template && $vm->guest->disk) { $vmstorageString .= ""; ## ESX/ESXi host ## $vmstorageString .= "".$host_name.""; ## DISPLAY NAME ## $vmstorageString .= "".$vm->name.""; my $vdisks = $vm->guest->disk; my $disk_string = ""; foreach my $disk (@$vdisks) { my $vm_disk_path = $disk->diskPath; my $vm_disk_free = prettyPrintData($disk->freeSpace,'B'); my $vm_disk_cap = prettyPrintData($disk->capacity,'B'); my $vm_perc_free = &restrict_num_decimal_digits((($disk->freeSpace / $disk->capacity) * 100),2); my $perc_string = getColor($vm_perc_free); $disk_string .= "$perc_string
$vm_disk_path$vm_disk_free$vm_disk_cap
"; } $vmstorageString .= $disk_string; $vmstorageString .= "\n"; } } ###################### # VM NETWORK ###################### if($VM_NETWORK eq "yes" && $vm->guest->net) { if(!$vm->config->template) { $vmnetworkString .= ""; ## ESX/ESXi host ## $vmnetworkString .= "".$host_name.""; ## DISPLAY NAME ## $vmnetworkString .= "".$vm->name.""; my ($vm_ip_string,$vm_mac_string,$vm_pg_string,$vm_connect_string) = ("","","",""); my $vnics = $vm->guest->net; foreach(@$vnics) { ## IP ADDRESS ## if($aversion eq "4.1.0" || $aversion eq "5.0.0") { if($_->ipConfig) { my $ips = $_->ipConfig->ipAddress; foreach(@$ips) { if($demo eq "no") { $vm_ip_string .= $_->ipAddress."
"; } else { $vm_ip_string .= "demo_mode
"; } } } else { $vm_ip_string .= "N/A
"; } } else { if($_->ipAddress) { my $ips = $_->ipAddress; foreach(@$ips) { if($demo eq "no") { $vm_ip_string .= $_."
"; } else { $vm_ip_string .= "demo_mode
"; } } } else { $vm_ip_string .= "N/A
"; } } ## MAC ADDRESS ## if($_->macAddress) { if($demo eq "no") { $vm_mac_string .= $_->macAddress."
"; } else { $vm_mac_string .= "demo_mode
"; } } else { $vm_mac_string .= "N/A
"; } ## PORTGROUP ## if($_->network) { if($demo eq "no") { $vm_pg_string .= $_->network."
"; } else { $vm_pg_string .= "demo_mode
"; } } else { $vm_pg_string .= "N/A
"; } ## CONNECTED ## $vm_connect_string .= ($_->connected ? "YES
" : "NO
"); } $vmnetworkString .= "".$vm_ip_string."".$vm_mac_string."".$vm_pg_string."".$vm_connect_string.""; $vmnetworkString .= "\n"; } } ###################### # SNAPSHOT ###################### if($VM_SNAPSHOT eq "yes") { if(!$vm->config->template) { if($vm->snapshot) { &getSnapshotTree($host_name,$vm->name,$vm->snapshot->currentSnapshot,$vm->snapshot->rootSnapshotList); foreach(@vmsnapshots) { $vmsnapString .= "".$_."\n"; } @vmsnapshots = (); } } } ###################### # CDROM ###################### if($VM_CDROM eq "yes") { if(!$vm->config->template) { my $devices = $vm->config->hardware->device; my ($cd_string) = (""); my $hasCD = 0; foreach(@$devices) { if($_->isa('VirtualCdrom') && $_->connectable->connected) { $hasCD = 1; if($_->deviceInfo->summary) { $cd_string .= $_->deviceInfo->summary."
"; } else { $cd_string .= "N/A"; } } } if($hasCD eq 1) { $vmcdString .= ""; ## ESX/ESXi host ## $vmcdString .= "".$host_name.""; ## DISPLAY NAME ## $vmcdString .= "".$vm->name.""; ## ISO ## $vmcdString .= "".$cd_string.""; $vmcdString .= "\n"; } } } ###################### # FLOPPY ###################### if($VM_FLOPPY eq "yes") { if(!$vm->config->template) { my $devices = $vm->config->hardware->device; my ($flp_string) = (""); my $hasFLP = 0; foreach(@$devices) { if($_->isa('VirtualFloppy') && $_->connectable->connected) { $hasFLP = 1; if($_->deviceInfo->summary) { $flp_string .= $_->deviceInfo->summary."
"; } else { $flp_string .= "N/A"; } } } if($hasFLP eq 1) { $vmflpString .= ""; ## ESX/ESXi host ## $vmflpString .= "".$host_name.""; ## DISPLAY NAME ## $vmflpString .= "".$vm->name.""; ## FLP ## $vmflpString .= "".$flp_string.""; $vmflpString .= "\n"; } } } ###################### # TOOLS ###################### if($VM_TOOL eq "yes") { if(!$vm->config->template) { $vmtoolString .= ""; ## ESX/ESXi host ## $vmtoolString .= "".$host_name.""; ## DISPLAY NAME ## $vmtoolString .= "".$vm->name.""; if($vm->guest) { ## TOOLS VERSION ## $vmtoolString .= "".($vm->guest->toolsVersion ? $vm->guest->toolsVersion : "N/A").""; ## TOOLS RUNNING STATUS ## $vmtoolString .= "".($vm->guest->toolsRunningStatus ? $vm->guest->toolsRunningStatus : "N/A").""; ## TOOLS VERSION STATUS ## if($aversion eq "5.0.0") { $vmtoolString .= "".($vm->guest->toolsVersionStatus2 ? $vm->guest->toolsVersionStatus2 : "N/A").""; } else { $vmtoolString .= "".($vm->guest->toolsVersionStatus ? $vm->guest->toolsVersionStatus : "N/A").""; } } else { $vmtoolString .= "N/A"; $vmtoolString .= "N/A"; $vmtoolString .= "N/A"; } if($vm->config->tools) { ## TOOLS UPGRADE POLICY ## $vmtoolString .= "".($vm->config->tools->toolsUpgradePolicy ? $vm->config->tools->toolsUpgradePolicy : "N/A").""; ## SYNC TIME ## $vmtoolString .= "".($vm->config->tools->syncTimeWithHost ? "YES" : "NO").""; } else { $vmtoolString .= "N/A"; $vmtoolString .= "N/A"; } $vmtoolString .= "\n"; } } ###################### # RDM ###################### if($VM_RDM eq "yes") { if(!$vm->config->template) { my $devices = $vm->config->hardware->device; my ($rdm_string) = (""); my $hasRDM = 0; foreach(@$devices) { if($_->isa('VirtualDisk') && ($_->backing->isa('VirtualDiskRawDiskVer2BackingInfo') || $_->backing->isa('VirtualDiskRawDiskMappingVer1BackingInfo'))) { $hasRDM = 1; my $compat_mode = ($_->backing->compatibilityMode ? $_->backing->compatibilityMode : "N/A"); my $vmhba = ($_->backing->deviceName ? $_->backing->deviceName : "N/A"); my $disk_mode = ($_->backing->diskMode ? $_->backing->diskMode : "N/A"); my $lun_uuid = ($_->backing->lunUuid ? $_->backing->lunUuid : "N/A"); my $vm_uuid = ($_->backing->uuid ? $_->backing->uuid : "N/A"); $rdm_string .= "".$compat_mode."".$vmhba."".$disk_mode."".$lun_uuid."".$vm_uuid.""; } } if($hasRDM eq 1) { $vmrdmString .= ""; ## ESX/ESXi host ## $vmrdmString .= "".$host_name.""; ## DISPLAY NAME ## $vmrdmString .= "".$vm->name.""; ## RDM ## $vmrdmString .= $rdm_string; $vmrdmString .= "\n"; } } } ###################### # NPIV ###################### if($VM_NPIV eq "yes") { if(!$vm->config->template) { if($vm->config->npivNodeWorldWideName && $vm->config->npivPortWorldWideName) { $vmnpivString .= ""; ## ESX/ESXi host ## $vmnpivString .= "".$host_name.""; ## DISPLAY NAME ## $vmnpivString .= "".$vm->name.""; my $nwwns = $vm->config->npivNodeWorldWideName; my $pwwns = $vm->config->npivPortWorldWideName; my $type = ($vm->config->npivWorldWideNameType ? $vm->config->npivWorldWideNameType : "N/A"); my $desirednwwn = ($vm->config->npivDesiredNodeWwns ? $vm->config->npivDesiredNodeWwns : "N/A"); my $desiredpwwn = ($vm->config->npivDesiredPortWwns ? $vm->config->npivDesiredPortWwns : "N/A"); my $npiv_string = ""; foreach(@$nwwns) { my $nwwn = (Math::BigInt->new($_))->as_hex(); $nwwn =~ s/^..//; $nwwn = join(':', unpack('A2' x 8, $nwwn)); if($demo eq "no") { $npiv_string .= "$nwwn
"; } else { $npiv_string .= "XX:XX:XX:XX:XX:XX:XX:XX
"; } } $npiv_string .= ""; foreach(@$pwwns) { my $pwwn = (Math::BigInt->new($_))->as_hex(); $pwwn =~ s/^..//; $pwwn = join(':', unpack('A2' x 8, $pwwn)); if($demo eq "no") { $npiv_string .= "$pwwn
"; } else { $npiv_string .= "XX:XX:XX:XX:XX:XX:XX:XX
"; } } my $npivtype = ""; if($type eq "vc") { $npivtype = "Virtual Center"; } elsif($type eq "external") { $npivtype = "External Source"; } elsif($type eq "host") { $npivtype = "ESX or ESXi"; } $npiv_string .= "".$npivtype."".$desirednwwn."".$desiredpwwn.""; $vmnpivString .= $npiv_string; $vmnpivString .= "\n"; } } } if($VM_STATS eq "yesaaaaa") { if(!$vm->config->template) { $vmstatString .= ""; ## ESX/ESXi host ## $vmstatString .= "".$host_name.""; ## DISPLAY NAME ## $vmstatString .= "".$vm->name.""; $vmstatString .= "\n"; } } ## STOP ### } } ###################### # DLETA ###################### if($VM_DELTA eq "yes") { foreach(@vmdeltas) { $vmdeltaString .= "".$_."\n"; } @vmdeltas = (); } &buildVMReport($cluster_name,$cluster_count,$type,$atype,$aversion); } } sub printHostSummary { my ($local_hosts,$cluster_name,$cluster_count,$type,$atype,$aversion,$sc) = @_; if(@$local_hosts) { foreach my $local_host(sort {$a->summary->config->name cmp $b->summary->config->name} @$local_hosts) { if($demo eq "no") { $host_name = $local_host->name; } #skip if host is not accessible next if($local_host->runtime->connectionState->val ne "connected"); #skip if VM is not in valid list if($hostlist) { next if(!$hostlists{$local_host->name}); } #capture unique hosts for later use push @hosts_seen,$host_name; #host api version my $hostAPIVersion = $local_host->config->product->version; ###################### # HARDWARE ###################### if($HOST_HARDWARE_CONFIGURATION eq "yes") { $hardwareConfigurationString .= ""; $hardwareConfigurationString .= "".$host_name.""; $hardwareConfigurationString .= "".$local_host->summary->hardware->vendor.""; my $additional_vendor_info = ""; if($local_host->summary->hardware->otherIdentifyingInfo) { my $add_info = $local_host->summary->hardware->otherIdentifyingInfo; foreach (@$add_info) { $additional_vendor_info .= $_->identifierType->key.": ".$_->identifierValue." "; } if($additional_vendor_info eq '') { $additional_vendor_info = "UNKNOWN"; } } $hardwareConfigurationString .= "".$additional_vendor_info.""; $hardwareConfigurationString .= "".$local_host->summary->hardware->model.""; $hardwareConfigurationString .= "".$local_host->summary->hardware->cpuModel.""; if($aversion eq "5.0.0") { $hardwareConfigurationString .= "".(($local_host->hardware->smcPresent) ? "YES" : "NO").""; } else { $hardwareConfigurationString .= "N/A"; } $hardwareConfigurationString .= "".(($local_host->config->hyperThread->available) ? "YES" : "NO").""; $hardwareConfigurationString .= "".prettyPrintData($local_host->summary->hardware->numCpuCores*$local_host->summary->hardware->cpuMhz,'MHZ').""; $hardwareConfigurationString .= "".prettyPrintData($local_host->summary->quickStats->overallCpuUsage,'MHZ').""; $hardwareConfigurationString .= "".$local_host->summary->hardware->numCpuPkgs.""; $hardwareConfigurationString .= "".($local_host->summary->hardware->numCpuCores/$local_host->summary->hardware->numCpuPkgs).""; $hardwareConfigurationString .= "".$local_host->summary->hardware->numCpuThreads.""; $hardwareConfigurationString .= "".prettyPrintData($local_host->summary->hardware->memorySize,'B').""; $hardwareConfigurationString .= "".prettyPrintData($local_host->summary->quickStats->overallMemoryUsage,'M').""; $hardwareConfigurationString .= "".$local_host->summary->hardware->numNics.""; $hardwareConfigurationString .= "".$local_host->summary->hardware->numHBAs.""; $hardwareConfigurationString .= "\n"; } ###################### # MGMT ###################### if($HOST_MGMT eq "yes") { $mgmtString .= ""; $mgmtString .= "".$host_name.""; my $mgmtIp = "N/A"; if($local_host->summary->managementServerIp) { if($demo eq "no") { my ($ipaddress,$dnsname) = ("N/A","N/A"); eval { $ipaddress = inet_aton($local_host->summary->managementServerIp); if($debug) { print "---DEBUG managementServerIp: " . $local_host->summary->managementServerIp . " ---\n"; } $dnsname = gethostbyaddr($ipaddress, AF_INET); if(!defined($dnsname)) { $dnsname = "N/A"; } if($debug) { print "---DEBUG dnsname: " . $dnsname . " ---\n"; } }; if(!$@) { $mgmtIp = $local_host->summary->managementServerIp . " ( $dnsname )"; } else { $mgmtIp = $local_host->summary->managementServerIp . " ( UNKNOWN )"; } } else { $mgmtIp = "demo_mode"; } } $mgmtString .= "".$mgmtIp.""; if($atype eq "VirtualCenter") { if($local_host->summary->config->product) { $mgmtString .= "".($local_host->config->adminDisabled ? "YES" : "NO").""; } } else { $mgmtString .= "UNKNOWN"; } if($aversion eq "4.1.0" || $aversion eq "5.0.0") { if($hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") { my $systemFile = ""; if($local_host->config->systemFile) { my $systemfile = $local_host->config->systemFile; foreach(@$systemfile) { $systemFile .= $_ . "
"; } } else { $systemFile = "N/A"; } $mgmtString .= "$systemFile"; } else { $mgmtString .= "N/A"; } } $mgmtString .= "".$local_host->summary->hardware->uuid.""; if($local_host->config->consoleReservation) { $mgmtString .= "".($local_host->config->consoleReservation->serviceConsoleReserved ? &prettyPrintData($local_host->config->consoleReservation->serviceConsoleReserved,'B') : "N/A").""; } else { $mgmtString .= "N/A"; } $mgmtString .= "\n"; } ###################### # STATE ###################### if($HOST_STATE eq "yes") { $stateString .= ""; $stateString .= "".$host_name.""; my $host_health .= $local_host->overallStatus->val; if ($host_health eq 'green') { $stateString .= "HOST is OK"; } elsif ($host_health eq 'red') { $stateString .= "HOST has a problem"; } elsif ($host_health eq 'yellow') { $stateString .= "HOST might have a problem"; } else { $stateString .= "UNKNOWN"; } $stateString .= "".$local_host->runtime->powerState->val.""; if($local_host->runtime->bootTime) { $stateString .= "".$local_host->runtime->bootTime.""; } else { $stateString .= "UNKNOWN"; } if($aversion eq "4.1.0" || $aversion eq "5.0.0") { if($hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") { if($local_host->summary->quickStats->uptime) { my $uptime = $local_host->summary->quickStats->uptime; $stateString .= "".&getUptime($uptime).""; } else { $stateString .= "UNKNOWN"; } } else { $stateString .= "N/A"; } } if($aversion eq "5.0.0" && $atype eq "VirtualCenter") { if($local_host->runtime->dasHostState) { $stateString .= "".$local_host->runtime->dasHostState->state.""; } else { $stateString .= "N/A"; } } else { $stateString .= "N/A"; } $stateString .= "".$local_host->runtime->connectionState->val.""; $stateString .= "".(($local_host->summary->runtime->inMaintenanceMode) ? "YES" : "NO").""; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { if($hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") { $stateString .= "".(($local_host->runtime->standbyMode) ? $local_host->runtime->standbyMode : "N/A").""; } else { $stateString .= "N/A"; } } $stateString .= "".(($local_host->summary->config->vmotionEnabled) ? "YES" : "NO").""; $stateString .= "".${$local_host->summary->config->product}{'fullName'}.""; $stateString .= "\n"; } ###################### # HEALTH ###################### if($HOST_HEALTH eq "yes") { if($local_host->runtime->healthSystemRuntime) { if($local_host->runtime->healthSystemRuntime->hardwareStatusInfo) { my $hardwareStatusInfo = $local_host->runtime->healthSystemRuntime->hardwareStatusInfo; my ($cpuInfo,$memInfo,$storageInfo); $healthHardwareString .= "".$host_name."\n"; my ($sensor_health_color,$sensor_health) = ("","");; if($hardwareStatusInfo->cpuStatusInfo) { $cpuInfo = $hardwareStatusInfo->cpuStatusInfo; foreach(@$cpuInfo) { $sensor_health = $_->status->key; if ($sensor_health =~ m/green/i) { $sensor_health_color="OK"; } elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="PROBLEM"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="WARNING"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } else { $sensor_health_color="UNKNOWN"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } $healthHardwareString .= "".$_->name."".$sensor_health_color."\n"; } } if($hardwareStatusInfo->memoryStatusInfo) { $memInfo = $hardwareStatusInfo->memoryStatusInfo; foreach(@$memInfo) { $sensor_health = $_->status->key; if ($sensor_health =~ m/green/i) { $sensor_health_color="OK"; } elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="PROBLEM"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="WARNING"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } else { $sensor_health_color="UNKNOWN"; } $healthHardwareString .= "".$_->name."".$sensor_health_color."\n"; } } if($hardwareStatusInfo->storageStatusInfo) { $storageInfo = $hardwareStatusInfo->storageStatusInfo; foreach(@$storageInfo) { $sensor_health = $_->status->key; if ($sensor_health =~ m/green/i) { $sensor_health_color="OK"; } elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="PROBLEM"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="WARNING"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } else { $sensor_health_color="UNKNOWN"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } $healthHardwareString .= "".$_->name."".$sensor_health_color."\n"; } } } if($local_host->runtime->healthSystemRuntime->systemHealthInfo) { my $sensors = $local_host->runtime->healthSystemRuntime->systemHealthInfo->numericSensorInfo; $healthSoftwareString .= "".$host_name."\n"; my $sensor_health_color = ""; foreach(sort {$a->name cmp $b->name} @$sensors) { my $sensor_health = $_->healthState->key; if ($sensor_health =~ m/green/) { $sensor_health_color="OK"; } elsif ($sensor_health_color =~ m/red/) { $sensor_health_color="PROBLEM"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } elsif ($sensor_health_color =~ m/yellow/) { $sensor_health_color="WARNING"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } else { $sensor_health_color="UNKNOWN"; #MWPRESTON - added following 2 lines $HOSTISSUES="yes"; $emailMessage .= $_->name."\n"; } my $reading; if(defined($_->rateUnits)) { $reading = &restrict_num_decimal_digits(($_->currentReading * (10 ** $_->unitModifier)),3) . " " . $_->baseUnits . "/" . $_->rateUnits; } else { $reading = &restrict_num_decimal_digits(($_->currentReading * (10 ** $_->unitModifier)),3) . " " . $_->baseUnits; } $healthSoftwareString .= "".$_->name."".$reading."".$sensor_health_color."\n"; } } } } ###################### # PERFORMANCE ###################### if($HOST_PERFORMANCE eq "yes" || $hostperformance eq "yes") { my $hostperf = &getCpuAndMemPerf($local_host); $hostPerfString .= $hostperf; } ###################### # NIC ###################### if($HOST_NIC eq "yes") { my $nics = $local_host->config->network->pnic; foreach my $nic (@$nics) { $nicString .= "".$host_name.""; $nicString .= "".$nic->device."".$nic->pci."".$nic->driver.""; if($nic->linkSpeed) { $nicString .= "".(($nic->linkSpeed->duplex) ? "FULL DUPLEX" : "HALF-DUPLEX")."".$nic->linkSpeed->speedMb." MB"; } else { $nicString .= "UNKNOWNUNKNOWN"; } $nicString .= "".(($nic->wakeOnLanSupported) ? "YES" : "NO").""; if($demo eq "no") { $nicString .= "".$nic->mac."\n"; } else { $nicString .= "demo_mode\n"; } } } ###################### # HBA ###################### if($HOST_HBA eq "yes") { my $hbas; eval { $hbas = $local_host->config->storageDevice->hostBusAdapter; }; if(!$@) { foreach my $hba (@$hbas) { $hbaString .= "".$host_name.""; if($hba->isa("HostFibreChannelHba")) { my $hbaType = "FC"; my ($fcfMac,$vnportMac) = ("",""); if($aversion eq "5.0.0") { if($hba->isa("HostFibreChannelOverEthernetHba")) { $hbaType = "FCoE"; $fcfMac = $hba->linkInfo->fcfMac; $vnportMac = $hba->linkInfo->vnportMac; } } my $nwwn = (Math::BigInt->new($hba->nodeWorldWideName))->as_hex(); my $pwwn = (Math::BigInt->new($hba->portWorldWideName))->as_hex(); $nwwn =~ s/^..//; $pwwn =~ s/^..//; $nwwn = join(':', unpack('A2' x 8, $nwwn)); $pwwn = join(':', unpack('A2' x 8, $pwwn)); if($demo eq "yes") { $nwwn = "XX:XX:XX:XX:XX:XX:XX:XX"; $pwwn = "XX:XX:XX:XX:XX:XX:XX:XX"; $fcfMac = "XX:XX:XX:XX:XX:XX"; $vnportMac = "XX:XX:XX:XX:XX:XX"; } $hbaString .= "".$hbaType."".$hba->device."".$hba->pci."".$hba->model."".$hba->driver."".$hba->status."NWWN ".$nwwn."PWWN ".$pwwn.""; if($aversion eq "5.0.0" && $hbaType eq "FCoE") { $hbaString .= " ".$fcfMac."VNPORTMAC ".$vnportMac.""; } $hbaString .= "PORT TYPE ".$hba->portType->val."SPEED ".$hba->speed.""; } elsif($hba->isa("HostInternetScsiHba")) { $hbaString .= "iSCSI".$hba->device."".$hba->pci."".$hba->model."".$hba->driver."".$hba->status."".(($hba->authenticationProperties->chapAuthEnabled) ? "CHAP ENABLED" : "CHAP DISABLED").""; } elsif($hba->isa("HostParallelScsiHba")) { $hbaString .= "SCSI".$hba->device."".$hba->pci."".$hba->model."".$hba->driver."".$hba->status.""; } elsif($hba->isa("HostBlockHba")) { $hbaString .= "BLOCK".$hba->device."".$hba->pci."".$hba->model."".$hba->driver."".$hba->status.""; } $hbaString .= "\n"; } } } ###################### # iSCSI ###################### if($HOST_ISCSI eq "yes" && $aversion eq "5.0.0") { my $hbas; eval { $hbas = $local_host->config->storageDevice->hostBusAdapter; }; if(!$@) { my @iSCSIHBAs = (); foreach my $hba (@$hbas) { if($hba->isa("HostInternetScsiHba")) { push @iSCSIHBAs, $hba->device; } } my $iscsiMgr; eval { $iscsiMgr = Vim::get_view(mo_ref => $local_host->configManager->iscsiManager); }; if(!$@) { foreach my $iscsiHBA (@iSCSIHBAs) { my $iscsiPortInfo = $iscsiMgr->QueryBoundVnics(iScsiHbaName => $iscsiHBA); if(defined($iscsiPortInfo)) { foreach my $iscsiPort (@$iscsiPortInfo) { $iscsiString .= ""; $iscsiString .= "".$host_name.""; $iscsiString .= "".(defined($iscsiPort->vnicDevice) ? $iscsiPort->vnicDevice : "N/A").""; if($iscsiPort->vnic->spec->ip->ipAddress) { $iscsiString .= "".$iscsiPort->vnic->spec->ip->ipAddress.""; } else { $iscsiString .= "N/A"; } if($iscsiPort->vnic->spec->ip->subnetMask) { $iscsiString .= "".$iscsiPort->vnic->spec->ip->subnetMask.""; } else { $iscsiString .= "N/A"; } if($iscsiPort->vnic->spec->mac) { $iscsiString .= "".$iscsiPort->vnic->spec->mac.""; } else { $iscsiString .= "N/A"; } if($iscsiPort->vnic->spec->mtu) { $iscsiString .= "".$iscsiPort->vnic->spec->mtu.""; } else { $iscsiString .= "N/A"; } if(defined($iscsiPort->vnic->spec->tsoEnabled)) { $iscsiString .= "".($iscsiPort->vnic->spec->tsoEnabled ? "YES" : "NO").""; } else { $iscsiString .= "N/A"; } if($iscsiPort->pnic->linkSpeed) { $iscsiString .= "".$iscsiPort->pnic->linkSpeed->speedMb . " (" . ($iscsiPort->pnic->linkSpeed->duplex ? "FULL-DUPLEX" : "HALF-DUPLEX") . ")".""; } else { $iscsiString .= "N/A"; } $iscsiString .= "".(defined($iscsiPort->pnicDevice) ? $iscsiPort->pnicDevice : "N/A").""; $iscsiString .= "".(defined($iscsiPort->portgroupName) ? $iscsiPort->portgroupName : "N/A").""; $iscsiString .= "".(defined($iscsiPort->switchName) ? $iscsiPort->switchName : "N/A").""; $iscsiString .= "".(defined($iscsiPort->switchUuid) ? $iscsiPort->switchUuid : "N/A").""; $iscsiString .= "".(defined($iscsiPort->pathStatus) ? $iscsiPort->pathStatus : "N/A").""; $iscsiString .= ""; } } } } } } ###################### # CAPABILITY ###################### if($HOST_CAPABILITY eq "yes") { if($local_host->capability) { $capString .= ""; $capString .= "".$host_name.""; if($aversion eq "5.0.0") { ## MAX VMS ## if($local_host->capability->maxHostRunningVms) { $capString .= "".$local_host->capability->maxHostRunningVms.""; } else { $capString .= "N/A"; } ## MAX VCPU ## if($local_host->capability->maxHostSupportedVcpus) { $capString .= "".$local_host->capability->maxHostSupportedVcpus.""; } else { $capString .= "N/A"; } ## VMFS VERSION ## if($local_host->capability->supportedVmfsMajorVersion) { $capString .= "".join(",",@{$local_host->capability->supportedVmfsMajorVersion}).""; } else { $capString .= "N/A"; } } ## FT ## $capString .= "".($local_host->capability->ftSupported ? "YES" : "NO").""; ## IPMI ## if($local_host->capability->ipmiSupported) { $capString .= "".($local_host->capability->ipmiSupported ? "YES" : "NO").""; } else { $capString .= "N/A"; } ## TPM ## $capString .= "".($local_host->capability->tpmSupported ? "YES" : "NO").""; ## HV ## $capString .= "".($local_host->capability->virtualExecUsageSupported ? "YES" : "NO").""; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { if($hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") { ## STORAGE IORM ## $capString .= "".($local_host->capability->storageIORMSupported ? "YES" : "NO").""; ## DPG 2 ## $capString .= "".($local_host->capability->vmDirectPathGen2Supported ? "YES" : "NO").""; ## vStorage ## $capString .= "".($local_host->capability->vStorageCapable ? "YES" : "NO").""; } else { $capString .= "N/A"; $capString .= "N/A"; $capString .= "N/A"; } } ## SSL THUMBPRINT ## if($local_host->capability->loginBySSLThumbprintSupported) { $capString .= "".($local_host->capability->loginBySSLThumbprintSupported ? "YES" : "NO").""; } else { $capString .= "N/A"; } $capString .= "\n"; } } ###################### # CONFIGURATIONS ###################### if($HOST_CONFIGURATION eq "yes") { my $netMgr = Vim::get_view(mo_ref => $local_host->configManager->networkSystem); $configString .= "\n\n\n"; ############# ## VMOTION ## ############# if($HOST_VMOTION eq "yes") { if($local_host->summary->config->vmotionEnabled) { $configString .= "\n"; if($demo eq "no") { $configString .= "\n"; $configString .= "\n"; } else { $configString .= "\n"; $configString .= "\n"; } } } ############# ## GATEWAY ## ############# if($HOST_GATEWAY eq "yes") { if($demo eq "no") { if($netMgr->consoleIpRouteConfig) { if($netMgr->consoleIpRouteConfig->defaultGateway) { $configString .= "\n"; } else { $configString .= "\n"; } if($netMgr->consoleIpRouteConfig->ipV6DefaultGateway) { $configString .= "\n"; } else { $configString .= "\n"; } } else { $configString .= "\n"; $configString .= "\n"; } if($netMgr->ipRouteConfig->defaultGateway) { $configString .= "\n"; } else { $configString .= "\n"; } if($netMgr->ipRouteConfig->ipV6DefaultGateway) { $configString .= "\n"; } else { $configString .= "\n"; } } else { $configString .= "\n"; } } ##################### ## SOFTWARE iSCSI ## ##################### if($HOST_ISCSI eq "yes") { $configString .= "\n"; } ############# ## IPV6 ## ############# if($HOST_IPV6 eq "yes") { $configString .= "\n"; } ############# # FT ## ############# if($HOST_FT eq "yes") { $configString .= "\n"; } ############# # SSL ## ############# if($HOST_SSL eq "yes") { $configString .= "\n"; } ############# ## DNS ## ############# if($HOST_DNS eq "yes") { my $searchDomains = $local_host->config->network->dnsConfig->searchDomain; my $searchString = ""; foreach(@$searchDomains) { $searchString .= "search ".$_."
"; } my $dnsAddress = $local_host->config->network->dnsConfig->address; my $dnsString = ""; foreach(@$dnsAddress) { $dnsString .= "nameserver ".$_."
"; } if($demo eq "no") { $configString .= "\n"; } else { $configString .= "\n"; } } ############# ## UPTIME ## ############# if($HOST_UPTIME eq "yes") { my ($host_date,$host_time) = split('T',$local_host->runtime->bootTime); my $todays_date = giveMeDate('YMD'); chomp($todays_date); $configString .= "\n"; } ################# ## DIAGONISTIC ## ################# if($HOST_DIAGONISTIC eq "yes") { if($local_host->config->activeDiagnosticPartition) { my $diag_string .= ""; $configString .= "\n"; } } ################### ## AUTH SERVICES ## ################### if($HOST_AUTH_SERVICE eq "yes" && $hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") { my $authMgr = Vim::get_view(mo_ref => $local_host->configManager->authenticationManager); if($authMgr->info) { my $authConfigs = $authMgr->info->authConfig; my $authString = ""; foreach(@$authConfigs) { my ($authType,$authEnabled,$authStatus,$authDomain,$trustedDomains) = ("","","","",""); if($_->isa('HostLocalAuthenticationInfo')) { $authType = "LOCAL"; $authEnabled = ($_->enabled ? "YES" : "NO"); $authStatus = "N/A"; $authDomain = "N/A"; $trustedDomains = "N/A"; } elsif($_->isa('HostActiveDirectoryInfo')) { $authType = "ACTIVE DIRECTORY"; $authEnabled = ($_->enabled ? "YES" : "NO"); $authStatus = ($_->domainMembershipStatus ? $_->domainMembershipStatus : "N/A"); $authDomain = ($_->joinedDomain ? $_->joinedDomain : "N/A"); if($_->trustedDomain) { my $domains = $_->trustedDomain; foreach(@$domains) { $trustedDomains .= $_ . "
"; } } else { $trustedDomains = "N/A"; } } $authString .= ""; } $configString .= "\n"; } } ############### ## SERVICES ## ############### if($HOST_SERVICE eq "yes") { my $services = $local_host->config->service->service; if($services) { my $serviceString = ""; foreach(@$services) { $serviceString .= ""; if($aversion eq "5.0.0") { if($_->sourcePackage) { $serviceString .= ""; } else { $serviceString .= ""; } } $serviceString .= ""; } if($aversion eq "5.0.0") { $configString .= "\n"; } else { $configString .= "\n"; } } } ############# ## NTP ## ############# if($HOST_NTP eq "yes") { if($local_host->config->dateTimeInfo) { my $ntps; eval { $ntps = $local_host->config->dateTimeInfo->ntpConfig->server; }; if(!$@) { my $ntpString = ""; if($ntps) { foreach (@$ntps) { $ntpString .= "$_
"; } } else { $ntpString = "NONE CONFIGURED"; } $ntpString = ""; $ntpString .= ""; $configString .= "\n"; } } } ########### ## VSWIF ## ########### if($HOST_VSWIF eq "yes") { if($local_host->config->network->consoleVnic) { my $vswifString = ""; my $console_vnics = $local_host->config->network->consoleVnic; foreach(@$console_vnics) { if($demo eq "no") { $vswifString .= ""; } else { $vswifString .= ""; } } $configString .= "\n"; } } ############## ## VMKERNEL ## ############## if($HOST_VMKERNEL eq "yes") { if($local_host->config->network->vnic) { my $vmkString = ""; my $vmks = $local_host->config->network->vnic; foreach(@$vmks) { if($demo eq "no") { $vmkString .= ""; } else { $vmkString .= ""; } } $configString .= "\n"; } } ############# ## VSWITCH ## ############# if($HOST_VSWITCH eq "yes") { my %vmmac_to_portgroup_mapping = (); my %cdp_enabled = (); my $vswitches = $local_host->config->network->vswitch; my $vswitchString = ""; foreach my $vSwitch(@$vswitches) { my ($pNicName,$mtu,$cdp_vswitch,$pNicKey) = ("","","",""); my $vswitch_name = $vSwitch->name; my $pNics = $vSwitch->pnic; foreach (@$pNics) { $pNicKey = $_; if ($pNicKey ne "") { $pNics = $netMgr->networkInfo->pnic; foreach my $pNic (@$pNics) { if ($pNic->key eq $pNicKey) { $pNicName = $pNicName ? ("$pNicName," . $pNic->device) : $pNic->device; if($cdp_enabled{$pNic->device}) { $cdp_vswitch = $cdp_enabled{$pNic->device}; } else { $cdp_vswitch = "N/A"; } } } } } $mtu = $vSwitch->{mtu} if defined($vSwitch->{mtu}); $vswitchString .= "\n"; $vswitchString .= "\n"; my $portGroups = $vSwitch->portgroup; foreach my $portgroup(@$portGroups) { my $pg = FindPortGroupbyKey ($netMgr, $vSwitch->key, $portgroup); next unless (defined $pg); my $usedPorts = (defined $pg->port) ? $#{$pg->port} + 1 : 0; if($demo eq "no") { $vswitchString .= "\n"; } else { $vswitchString .= "\n"; } $vswitch_portgroup_mappping{$pg->spec->name} = $vswitch_name; } } $configString .= "\n"; my $networks = Vim::get_views(mo_ref_array => $local_host->network); foreach my $portgroup(@$networks) { my $vms_device = Vim::get_views(mo_ref_array => $portgroup->vm, properties => ["config.name","config.hardware.device"]); foreach(@$vms_device) { my $vmname = $_->{'config.name'}; my $devices = $_->{'config.hardware.device'}; foreach(@$devices) { if($_->isa("VirtualEthernetCard")) { $vmmac_to_portgroup_mapping{$vmname} = $portgroup->name; } } } } } ########## ## SNMP ## ########## if($HOST_SNMP eq "yes") { my $snmp_system; eval { $snmp_system = Vim::get_view (mo_ref => $local_host->configManager->snmpSystem); }; if(!$@) { if($snmp_system->configuration->enabled) { my $snmpString = ""; $snmpString .= ""; $configString .= "\n"; } } } ############## ## FIREWALL ## ############## if($HOST_FIREWALL eq "yes") { if($local_host->config->firewall) { my $fw_sys = $local_host->config->firewall; my $fw_rules = $fw_sys->ruleset; my $fw_known_string = ""; my $fw_rule_string = ""; foreach my $rule ( sort{$a->label cmp $b->label}@$fw_rules) { if($rule->enabled) { my ($allowedIPs) = (""); if($aversion eq "5.0.0") { if($rule->allowedHosts->allIp) { $allowedIPs = "all"; } else { my $ipNetworks = $rule->allowedHosts->ipNetwork; foreach(@$ipNetworks) { $allowedIPs .= $_->network . "/" . $_->prefixLength . ", "; } } } my $firewallRules = $rule->rule; my ($fwDirection,$fwPort,$fwPortType,$fwProto) = ("N/A","N/A","N/A","N/A"); foreach(@$firewallRules) { $fwDirection = $_->direction->val; $fwPort = $_->port; if($_->endPort) { $fwPort .= "-" . $_->endPort; } if($aversion eq "5.0.0") { $fwPortType = $_->portType ? uc($_->portType->val) : "N/A"; } $fwProto = $_->protocol; $fw_known_string .= "\n"; } } } $configString .= "\n"; my $defaultPolicy = "\n"; $configString .= "\n"; } } ########### ## POWER ## ########### if($HOST_POWER eq "yes") { if($local_host->hardware->cpuPowerManagementInfo) { my $cpu_power_info = ""; $cpu_power_info .= ""; $configString .= "\n"; } } ###################### # FEATURE VERSION ###################### if($HOST_FEATURE_VERSION eq "yes" && $hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") { if($local_host->summary->config->featureVersion) { my $featurever = $local_host->summary->config->featureVersion; my $featureString = ""; foreach(@$featurever) { $featureString .= "\n"; } $configString .= "\n"; } } $configString .= "
".$host_name."
VMOTION ENABLED YES
IP ADDRESS ".$local_host->config->vmotion->ipConfig->ipAddress." => ".$local_host->summary->config->name."
NETMASK ".$local_host->config->vmotion->ipConfig->subnetMask."
IP ADDRESS X.X.X.X
NETMASK X.X.X.X
GATEWAY ".$netMgr->consoleIpRouteConfig->defaultGateway."
GATEWAY 0.0.0.0
IPv6 GATEWAY ".$netMgr->consoleIpRouteConfig->ipV6DefaultGateway."
IPv6 GATEWAY 0.0.0.0
GATEWAY N/A
IPv6 GATEWAY N/A
VMKERNEL GATEWAY ".$netMgr->ipRouteConfig->defaultGateway."
VMKERNEL GATEWAY 0.0.0.0
VMKERNEL IPv6 GATEWAY ".$netMgr->ipRouteConfig->ipV6DefaultGateway."
VMKERNEL IPv6 GATEWAY 0.0.0.0
GATEWAY X.X.X.X
SOFTWAE iSCSI ENABLED".($local_host->config->storageDevice->softwareInternetScsiEnabled ? "YES" : "NO")."
IPv6 ENABLED".($local_host->config->network->ipV6Enabled ? "YES" : "NO")."
FT ENABLED".($local_host->summary->config->faultToleranceEnabled ? "YES" : "NO")."
SSL THUMBPRINT".($local_host->summary->config->sslThumbprint ? $local_host->summary->config->sslThumbprint : "N/A")."
DNS"."domain ".($local_host->config->network->dnsConfig->domainName ? $local_host->config->network->dnsConfig->domainName : "N/A")."
".$searchString.$dnsString."
DNSdomain demo_mode
search demo_mode
nameserver demo_mode
UPTIME".&days_between($host_date, $todays_date)." Days - ".$local_host->runtime->bootTime."
".$local_host->config->activeDiagnosticPartition->diagnosticType."".$local_host->config->activeDiagnosticPartition->id->diskName.$local_host->config->activeDiagnosticPartition->id->partition."".$local_host->config->activeDiagnosticPartition->storageType."
DIAGNOSTIC PARTITION".$diag_string."
TYPEPARITIONSTORAGE TYPE
".$authType."".$authEnabled."".$authStatus."".$authDomain."".$trustedDomains."
AUTHENTICATION SERVICE(s)".$authString."
AUTH TYPEENABLEDSTATUSDOMAINTRUSTED DOMAIN
".$_->label."".$_->sourcePackage->sourcePackageName."N/A".$_->policy."".(($_->running) ? "YES" : "NO")."
SERVICE(s)".$serviceString."
NAMESOURCE PACKAGEPOLICY TYPERUNNING
SERVICE(s)".$serviceString."
NAMEPOLICY TYPERUNNING
".$ntpString."".$local_host->config->dateTimeInfo->timeZone->description."".$local_host->config->dateTimeInfo->timeZone->gmtOffset."".$local_host->config->dateTimeInfo->timeZone->name."
NTP".$ntpString."
NTP SERVERSTIME ZONEGMT OFFSETLOCATION
".$_->device."".$_->portgroup."".$_->spec->ip->ipAddress."".$_->spec->ip->subnetMask."".$_->spec->mac."".(($_->spec->ip->dhcp) ? "YES" : "NO")."
".$_->device."demo_modeX.X.X.XX.X.X.Xdemo_mode".(($_->spec->ip->dhcp) ? "YES" : "NO")."
VSWIF(s)".$vswifString."
NAMEPORTGROUPIP ADDRESSNETMASKMACDHCP
".$_->device."".$_->portgroup."".$_->spec->ip->ipAddress."".$_->spec->ip->subnetMask."".$_->spec->mac."".(($_->spec->ip->dhcp) ? "YES" : "NO")."
".$_->device."demo_modeX.X.X.XX.X.X.XX.X.X.X".(($_->spec->ip->dhcp) ? "YES" : "NO")."
VMKERNEL(s)".$vmkString."
INTERFACEPORTGROUPIP ADDRESSNETMASKMACDHCP
VSWITCH NAMENUM OF PORTSUSED PORTSMTUUPLINKSCDP ENABLED
".$vSwitch->name."".$vSwitch->numPorts."".($vSwitch->numPorts - $vSwitch->numPortsAvailable)."".$mtu."".$pNicName."".$cdp_vswitch."
PORTGROUP NAMEVLAN IDUSED PORTSUPLINKS
".$pg->spec->name."".$pg->spec->vlanId."".$usedPorts."".$pNicName."
demo_modedemo_mode".$usedPorts."".$pNicName."
VSWITCH(s)".$vswitchString."
".$snmp_system->configuration->port.""; my $ro_community = $snmp_system->configuration->readOnlyCommunities; foreach(@$ro_community) { $snmpString .= $_ . ", "; } $snmpString .= ""; my $trap_targets = $snmp_system->configuration->trapTargets; foreach(@$trap_targets) { $snmpString .= "Community: " . $_->community . " Hostname: " . $_->hostName . " Port: " . $_->port . "
\n"; } $snmpString .= "
SNMP".$snmpString."
SNMP PORTRO COMMUNITIESTRAP TARGETS
".$rule->label."".$fwDirection."".$fwPortType."".$fwPort."".$fwProto."".$allowedIPs."
FIREWALL
KNOWN SERVICES ENABLED
".$fw_known_string."
LABELDIRECTIONPORT TYPEPORTPROTOCOLALLOWED IPS
".($fw_sys->defaultPolicy->incomingBlocked ? "YES" : "NO")."".($fw_sys->defaultPolicy->outgoingBlocked ? "YES" : "NO")."
FIREWALL POLICY".$defaultPolicy."
INCOMING ENABLEDOUTGOING ENABLED
".($local_host->hardware->cpuPowerManagementInfo->currentPolicy)."".($local_host->hardware->cpuPowerManagementInfo->hardwareSupport)."
CPU POWER MGMT INFO".$cpu_power_info."
CURRENT POLICYHARDWARE SUPPORT
".$_->key."".$_->value."
FEATURE VERSION".$featureString."
FEATUREVERSION
\n"; } ###################### # ADVANCED OPTIONS ###################### if($HOST_ADVOPT eq "yes") { my $advopts = Vim::get_view(mo_ref => $local_host->configManager->advancedOption); my $advSettings = $advopts->setting; my ($diskUDR,$diskULR,$diskSNRO,$scsiCR,$nfsMV,$SBS,$RBS,$netTHS,$nfsHF,$nfsHT,$nfsHMF,$vmkernelBSM,$vmfs3HAL,$dataMHAM,$dataMHAI) = ("N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A"); foreach(@$advSettings) { my $key = $_->key; my $value = $_->value; if($key eq "Disk.UseDeviceReset") { $diskUDR = $value; } if($key eq "Disk.UseLunReset") { $diskULR = $value; } if($key eq "Disk.SchedNumReqOutstanding") { $diskSNRO = $value; } if($key eq "Scsi.ConflictRetries") { $scsiCR = $value; } if($key eq "NFS.MaxVolumes") { $nfsMV = $value; } if($key eq "SendBufferSize") { $SBS = $value; } if($key eq "ReceiveBufferSize") { $RBS = $value; } if($key eq "Net.TcpipHeapSize") { $netTHS = $value; } if($key eq "NFS.HeartbeatFrequency") { $nfsHF = $value; } if($key eq "NFS.HeartbeatTimeout") { $nfsHT = $value; } if($key eq "NFS.HeartbeatMaxFailures") { $nfsHMF = $value; } if($key eq "VMkernel.Boot.techSupportMode") { $vmkernelBSM = $value; } if($key eq "VMFS3.HardwareAcceleratedLocking") { $vmfs3HAL = $value; } if($key eq "DataMover.HardwareAcceleratedMove") { $dataMHAM = $value; } if($key eq "DataMover.HardwareAcceleratedInit") { $dataMHAI = $value; } } $advString .= ""; $advString .= "".$host_name.""; $advString .= "".$diskUDR.""; $advString .= "".$diskULR.""; $advString .= "".$diskSNRO.""; $advString .= "".$scsiCR.""; $advString .= "".$nfsMV.""; $advString .= "".$SBS.""; $advString .= "".$RBS.""; $advString .= "".$netTHS.""; $advString .= "".$nfsHF.""; $advString .= "".$nfsHT.""; $advString .= "".$nfsHMF.""; $advString .= "".$vmkernelBSM.""; $advString .= "".$vmfs3HAL.""; $advString .= "".$dataMHAM.""; $advString .= "".$dataMHAI.""; $advString .= "\n"; } ###################### # HOST AGENT SETTING ###################### if($HOST_AGENT eq "yes" && $atype eq "VirtualCenter" && $hostAPIVersion eq "5.0.0") { if(defined($local_host->configManager->esxAgentHostManager)) { my $hostAgentMgr = Vim::get_view(mo_ref => $local_host->configManager->esxAgentHostManager); my ($agentDSName,$agentNetName) = ("N/A","N/A"); if($hostAgentMgr->configInfo->agentVmDatastore) { my $agentDSNameTmp = Vim::get_view(mo_ref => $hostAgentMgr->configInfo->agentVmDatastore, properties => ['name']); $agentDSName = $agentDSNameTmp->{'name'}; } if($hostAgentMgr->configInfo->agentVmNetwork) { my $agentNetNameTmp = Vim::get_view(mo_ref => $hostAgentMgr->configInfo->agentVmNetwork, properties => ['name']); $agentNetName = $agentNetNameTmp->{'name'}; } if($agentDSName ne "N/A" && $agentNetName ne "N/A") { $agentString .= ""; $agentString .= "".$host_name.""; $agentString .= "".$agentDSName.""; $agentString .= "".$agentNetName.""; $agentString .= "\n"; } } } ###################### # NUMA ###################### if($HOST_NUMA eq "yes") { if($local_host->hardware->numaInfo) { my $numaInfo = $local_host->hardware->numaInfo; if($numaInfo->numNodes == 0) { $numaString .= "".$host_name."NUMA-incapable".$numaInfo->type."N/A"; } else { $numaString .= "".$host_name."".$numaInfo->numNodes."".$numaInfo->type.""; if($numaInfo->numaNode) { my $nodes = $numaInfo->numaNode; $numaString .= ""; foreach(@$nodes) { my $cpuID = $_->cpuID; my $idString = ""; foreach(@$cpuID) { $idString = $_ . " " . $idString; } $numaString .= ""; } $numaString .= "
NODE IDCPU IDMEM RANGE BEGINMEM RANGE LENGTH
".$_->typeId." [".$idString."] ".&prettyPrintData($_->memoryRangeBegin,'B')."".&prettyPrintData($_->memoryRangeLength,'B')."
"; } else { $numaString .= "N/A" } $numaString .= "\n"; } } } ###################### # CDP ###################### if($HOST_CDP eq "yes") { my $netMgr = Vim::get_view(mo_ref => $local_host->configManager->networkSystem); my ($device,$port,$address,$cdp_ver,$devid,$duplex,$platform,$prefix,$location,$mgmt_addr,$cdpMtu,$samples,$sys_ver,$sys_name,$sys_oid,$timeout,$ttl,$vlan); my @physicalNicHintInfo = $netMgr->QueryNetworkHint(); foreach (@physicalNicHintInfo){ foreach ( @{$_} ){ if($_->connectedSwitchPort) { if($demo eq "no") { $device = $_->device; $port = $_->connectedSwitchPort->portId; $address = ($_->connectedSwitchPort->address ? $_->connectedSwitchPort->address : "N/A"); $cdp_ver = ($_->connectedSwitchPort->cdpVersion ? $_->connectedSwitchPort->cdpVersion : "N/A"); $devid = ($_->connectedSwitchPort->devId ? $_->connectedSwitchPort->devId : "N/A"); $duplex = ($_->connectedSwitchPort->fullDuplex ? ($_->connectedSwitchPort->fullDuplex ? "YES" : "NO") : "N/A"); $platform = ($_->connectedSwitchPort->hardwarePlatform ? $_->connectedSwitchPort->hardwarePlatform : "N/A"); $prefix = ($_->connectedSwitchPort->ipPrefix ? $_->connectedSwitchPort->ipPrefix : "N/A"); $location = ($_->connectedSwitchPort->location ? $_->connectedSwitchPort->location : "N/A"); $mgmt_addr = ($_->connectedSwitchPort->mgmtAddr ? $_->connectedSwitchPort->mgmtAddr : "N/A"); $cdpMtu = ($_->connectedSwitchPort->mtu ? $_->connectedSwitchPort->mtu : "N/A"); $samples = ($_->connectedSwitchPort->samples ? $_->connectedSwitchPort->samples : "N/A"); $sys_ver = ($_->connectedSwitchPort->softwareVersion ? $_->connectedSwitchPort->softwareVersion : "N/A"); $sys_name = ($_->connectedSwitchPort->systemName ? $_->connectedSwitchPort->systemName : "N/A"); $sys_oid = ($_->connectedSwitchPort->systemOID ? $_->connectedSwitchPort->systemOID : "N/A"); $timeout = ($_->connectedSwitchPort->timeout ? $_->connectedSwitchPort->timeout : "N/A"); $ttl = ($_->connectedSwitchPort->ttl ? $_->connectedSwitchPort->ttl : "N/A"); $vlan = ($_->connectedSwitchPort->vlan ? $_->connectedSwitchPort->vlan : "N/A"); } else { ($device,$address,$cdp_ver,$devid,$duplex,$platform,$prefix,$location,$mgmt_addr,$cdpMtu,$samples,$sys_ver,$sys_name,$sys_oid,$timeout,$ttl,$vlan) = ("demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode"); } $cdpString .= "".$host_name."".$device."".$mgmt_addr."".$address."".$prefix."".$location."".$sys_name."".$sys_ver."".$sys_oid."".$platform."".$devid."".$cdp_ver."".$duplex."".$cdpMtu."".$timeout."".$ttl."".$vlan."".$samples."\n"; } } } } ###################### # DVS ###################### if($HOST_DVS eq "yes") { if($atype eq 'VirtualCenter') { my ($dvsMgr,$dvs,$dvpg,$dvs_string); eval { $dvsMgr = Vim::get_view(mo_ref => $sc->dvSwitchManager); }; if(!$@) { my $dvs_target = $dvsMgr->QueryDvsConfigTarget(host => $local_host); if($dvs_target) { $dvs = $dvs_target->distributedVirtualSwitch; $dvpg = $dvs_target->distributedVirtualPortgroup; } if($dvpg) { foreach(@$dvpg) { $vswitch_portgroup_mappping{$_->portgroupName} = $_->switchName; } } if($dvs) { foreach(@$dvs) { my $sName = defined $_->switchName ? $_->switchName : "N/A"; if(!$seen_dvs{$sName}) { my $sUuid = ($_->switchUuid ? $_->switchUuid : "N/A"); my $dv_switch = Vim::get_view(mo_ref => $_->distributedVirtualSwitch); my $desc = ($dv_switch->summary->description ? $dv_switch->summary->description : "N/A"); my $contact_name = ($dv_switch->summary->contact->name ? $dv_switch->summary->contact->name : "N/A"); my $contact_con = ($dv_switch->summary->contact->contact ? $dv_switch->summary->contact->contact : ""); my $contact_info = $contact_name . " " . $contact_con; my $build = ($dv_switch->summary->productInfo->build ? $dv_switch->summary->productInfo->build : "N/A"); my $bid = ($dv_switch->summary->productInfo->bundleId ? $dv_switch->summary->productInfo->bundleId : "N/A"); my $burl = ($dv_switch->summary->productInfo->bundleUrl ? $dv_switch->summary->productInfo->bundleUrl: "N/A"); my $fclass = ($dv_switch->summary->productInfo->forwardingClass ? $dv_switch->summary->productInfo->forwardingClass : "N/A"); my $vendor = ($dv_switch->summary->productInfo->vendor ? $dv_switch->summary->productInfo->vendor : "N/A"); my $version = ($dv_switch->summary->productInfo->version ? $dv_switch->summary->productInfo->version : "N/A"); my $ports = ($dv_switch->summary->numPorts ? $dv_switch->summary->numPorts : "N/A"); $dvs_string = "".$sName."".$desc."".$contact_info."".$vendor."".$version."".$sUuid."".$build."".$bid."".$build."".$burl."".$fclass."".$ports."\n"; push @dvs, $dvs_string; } $seen_dvs{$sName} = 1; } } } } } ###################### # LUN ###################### if($HOST_LUN eq "yes") { my $ss = Vim::get_view(mo_ref => $local_host->configManager->storageSystem); my $fsmount = $ss->fileSystemVolumeInfo->mountInfo; my $luns = $ss->storageDeviceInfo->scsiLun; my ($volume,$extents,$diskName,$partition,$deviceName,$lunname,$volumename,$vendor,$model,$queuedepth,$vStorageSupport,$states) = ('','','','','','','','','','','',''); foreach my $fsm (@$fsmount) { $volume = $fsm->volume; if ($volume->type eq 'VMFS') { $extents = $volume->extent; my $i = 0; foreach my $extent (@$extents) { $diskName = $extent->diskName; my $lun_row = ""; foreach my $lun (sort {$a->canonicalName cmp $b->canonicalName} @$luns) { if ($diskName eq $lun->canonicalName) { $deviceName = $lun->deviceName; $volumename = $volume->name; $lunname = $lun->canonicalName; $vendor = $lun->vendor; $model = $lun->model; $queuedepth = $lun->queueDepth; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { if($hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") { $vStorageSupport = ($lun->vStorageSupport ? $lun->vStorageSupport : "N/A"); } else { $vStorageSupport = "N/A" } } $states = $lun->operationalState; last; } } $partition = $extent->partition; $luns{$volume->uuid} .= $host_name . "_" . $lunname . ","; $lun_row .= "".$volumename.""; $lun_row .= ""."$diskName:$partition".""; $lun_row .= ""."$deviceName:$partition".""; if($queuedepth) { $lun_row .= "".$queuedepth.""; } else { $lun_row .= "N/A"; } } $lun_row .= "".$state_string."".$vendor."".$model.""; $lun_row_info{$volume->uuid} = $lun_row; } } } } ###################### # DATASTORE ###################### if($HOST_DATASTORE eq "yes") { my $ds_views = Vim::get_views (mo_ref_array => $local_host->datastore); my $ctr = 0; foreach my $ds (sort {$a->info->name cmp $b->info->name} @$ds_views) { my $ds_row = ""; if($ds->summary->accessible) { #capture unique datastores seen in cluster if (!grep {$_ eq $ds->info->name} @datastores_seen) { push @datastores_seen,$ds->info->name; my ($perc_free,$perc_string,$ds_used,$ds_free,$ds_cap,$ds_block,$ds_ver) = ("","","","","","N/A","N/A"); if ( ($ds->summary->freeSpace gt 0) || ($ds->summary->capacity gt 0) ) { $ds_cap = &restrict_num_decimal_digits($ds->summary->capacity/1024/1000,2); $ds_used = prettyPrintData(($ds->summary->capacity - $ds->summary->freeSpace),'B'); $ds_free = &restrict_num_decimal_digits(($ds->summary->freeSpace/1024/1000),2); $perc_free = &restrict_num_decimal_digits(( 100 * $ds_free / $ds_cap),2); $perc_string = getColor($perc_free); if($ds->summary->type eq 'VMFS') { $ds_block = $ds->info->vmfs->blockSizeMb; $ds_ver = $ds->info->vmfs->version; } } else { ($perc_free,$ds_used,$ds_free) = ("UNKNOWN","UNKNOWN","UNKNOWN"); } my $vmsInDS = Vim::get_views(mo_ref_array => $ds->vm,properties => ['name']); if($aversion eq "4.1.0" || $aversion eq "5.0.0") { my ($iormEnable,$iormThres,$dsMaintMode,$iormAggDisable,$iormStatsCollEnable) = ("N/A","N/A","N/A","N/A","N/A"); if(($hostAPIVersion eq "4.1.0" || $hostAPIVersion eq "5.0.0") && $ds->summary->type eq 'VMFS') { $iormEnable = ($ds->iormConfiguration->enabled ? "YES" : "NO"); $iormThres = ($ds->iormConfiguration->congestionThreshold ? $ds->iormConfiguration->congestionThreshold . " ms" : "N/A"); if($hostAPIVersion eq "5.0.0") { $dsMaintMode = ($ds->summary->maintenanceMode ? "YES" : "NO"); $iormAggDisable = ($ds->iormConfiguration->statsAggregationDisabled ? "YES" : "NO"); $iormStatsCollEnable = ($ds->iormConfiguration->statsCollectionEnabled ? "YES" : "NO"); } } $ds_row = "".@$vmsInDS."".(prettyPrintData($ds->summary->capacity,'B'))."".$ds_used."".prettyPrintData($ds->summary->freeSpace,'B')."$perc_string$ds_block".$ds_ver."".$ds->summary->type."".$dsMaintMode."".$iormEnable."".$iormThres."".$iormAggDisable."".$iormStatsCollEnable.""; } else { $ds_row = "".@$vmsInDS."".(prettyPrintData($ds->summary->capacity,'B'))."".$ds_used."".prettyPrintData($ds->summary->freeSpace,'B')."$perc_string$ds_block".$ds_ver."".$ds->summary->type.""; } $datastore_row_info{$ds->info->name} = $ds_row; } $datastores{$ds->info->name} .= $host_name. "_" . $ctr++ .","; } } } ###################### # PORTGROUP ###################### if($HOST_PORTGROUP eq "yes") { my $portgroup_views = Vim::get_views (mo_ref_array => $local_host->network); foreach my $portgroup (sort {$a->summary->name cmp $b->summary->name} @$portgroup_views) { my $pg_row = ""; if($portgroup->summary->accessible) { push @hosts_in_portgroups,$host_name; #logic to figure out which hosts can not see this portgroup my @intersection = (); my @difference = (); my %count = (); foreach my $element (@hosts_in_portgroups, @hosts_seen) { $count{$element}++ } foreach my $element (keys %count) { push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element; } if(@difference) { my $hosts_not_accessible = ""; foreach (@difference) { $hosts_not_accessible .= $_." "; } if($demo eq "no") { $pg_row .= "$hosts_not_accessible"; } else { $pg_row .= "demo_mode"; } } else { $pg_row .= "Accessible by all hosts in this cluster"; } $portgroup_row_info{$portgroup->name} = $pg_row; } } } ###################### # CACHE ###################### if($HOST_CACHE eq "yes" && $aversion eq "5.0.0") { my $cacheMgr; eval { $cacheMgr = Vim::get_view (mo_ref => $local_host->configManager->cacheConfigurationManager); }; if(!$@) { if($cacheMgr->cacheConfigurationInfo) { my $cacheConfig = $cacheMgr->cacheConfigurationInfo; my $cacheConcatString = ""; foreach(@$cacheConfig) { my $cacheDS = Vim::get_view(mo_ref => $_->key, properties => ['name']); my $cacheSwap = &prettyPrintData($_->swapSize,'M'); $cacheConcatString .= "".$host_name."".$cacheDS->{'name'}."".$cacheSwap . "\n"; } $cacheString .= $cacheConcatString; } } } ###################### # MULTIPATH ###################### if($HOST_MULTIPATH eq "yes") { my $storageSys; eval { $storageSys = Vim::get_view (mo_ref => $local_host->configManager->storageSystem); }; if(!$@) { my $luns = $storageSys->storageDeviceInfo->scsiLun; my $hbas = $storageSys->storageDeviceInfo->hostBusAdapter; my $mpLuns = $storageSys->storageDeviceInfo->multipathInfo->lun; $multipathString .= "\n"; my $verbose; foreach my $mpLun (@$mpLuns) { my $paths = $mpLun->path; my $numPaths = scalar(@$paths); my $lun = find_by_key($luns, $mpLun->lun); my $pol = $mpLun->policy; my $polPrefer; if (defined($pol) && defined($pol->{prefer})) { $polPrefer = $pol->prefer; } my $cap = $lun->{capacity}; my $deviceUuidPath = defined($lun->{uuid}) ? ("vml." . $lun->uuid) : ""; $multipathString .= "
".$local_host->name."
\n"; $multipathString .= "\n"; foreach my $path (@$paths) { my $hba = find_by_key($hbas, $path->adapter); my $isFC = $hba->isa("HostFibreChannelHba"); my $state = ($path->{pathState} ? (($path->pathState eq "active") ? "On active" : $path->pathState) : ""); my $pciString = get_pci_string($hba); my $pathStateColor; if($path->{pathState} eq "dead") { $pathStateColor = $light_red; } elsif($path->{pathState} eq "disabled" || $path->{pathState} eq "standby") { $pathStateColor = $yellow; } else { $pathStateColor = $white; } if($demo eq "no") { $multipathString .= "\n"; } else { $multipathString .= "\n"; } } $multipathString .= "
".(defined($lun->{lunType}) ? $lun->lunType : "")." ".(defined($lun->{canonicalName}) ? $lun->canonicalName : "").($verbose ? " $deviceUuidPath" : "")." ".(defined($cap) ? " ( " . int($cap->block * $cap->blockSize / (1024*1024)) . " MB )" : " ( 0 MB )")." == # of Paths: ".$numPaths." Policy: ".((defined($pol) && defined($pol->{policy})) ? $pol->policy : "")."
".($isFC ? "FC" : "Local")." ".$pciString." ".($isFC ? $hba->nodeWorldWideName . "<->" . $hba->portWorldWideName : "")." ".$path->name." ".$state." ".((defined($polPrefer) && ($path->name eq $polPrefer)) ? "preferred" : "")."
".($isFC ? "FC" : "Local")." ".$pciString." "."demo_mode <-> demo_mode "." ".$path->name." ".$state." ".((defined($polPrefer) && ($path->name eq $polPrefer)) ? "preferred" : "")."

\n"; } } } ###################### # LOG ###################### if($HOST_LOG eq "yes") { my $logKey = "hostd"; my ($diagMgr,$logData); eval { $diagMgr = Vim::get_view(mo_ref => $sc->diagnosticManager); }; if($atype eq 'VirtualCenter') { $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, host => $local_host, start => "999999999"); } else { $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, start => "999999999"); } my $lineEnd = $logData->lineEnd; my $start = $lineEnd - $logcount; if($atype eq 'VirtualCenter') { $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, host => $local_host, start => $start,lines => $logcount); } else { $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, start => $start,lines => $logcount); } $logString .= "".$host_name."\n"; if ($logData->lineStart != 0) { my $logConcat = ""; foreach my $line (@{$logData->lineText}) { if($demo eq "no") { $logConcat .= $line."
"; } else { $logConcat = "demo_mode"; } } $logString .= "".$logConcat."\n"; } } ## END OF HOSTS ## } ############################################### ## HACK TO PRINT DVS,LUN,DATASTORE and PORTGRUP ## ############################################### if($HOST_DVS eq "yes") { foreach(@dvs) { $dvsString .= $_; } @dvs = (); } if($HOST_LUN eq "yes") { #logic to check which hosts can see all luns while ( my ($uuid, $value) = each(%luns) ) { my @pairs = split(',',$value); my $pair_count = @pairs; my @hosts_to_luns = (); for (my $x=0;$x < $pair_count;$x++) { (my $hostname,my $vmhba) = split('_',$pairs[$x],2); push @hosts_to_luns, $hostname; } #logic to figure out which hosts can not see this lun my @intersection = (); my @difference = (); my %count = (); foreach my $element (@hosts_to_luns, @hosts_seen) { $count{$element}++ } foreach my $element (keys %count) { push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element; } my $print_string = ""; if(@difference) { foreach (@difference) { $print_string .= $_." "; } } if($print_string eq '') { $print_string = "Accessible by all hosts in this cluster"; } else { $print_string = "".$print_string.""; } $lun_row_info{$uuid} .= $print_string; @hosts_to_luns = (); } foreach my $lun ( sort keys %lun_row_info ) { my $value = $lun_row_info{$lun}; $lunString .= "".$lun."".$value."\n"; } (%luns,%lun_row_info) = (); } if($HOST_DATASTORE eq "yes") { #logic to check which hosts can see all datastores while ( my ($ds, $value) = each(%datastores) ) { my @pairs = split(',',$value); my $pair_count = @pairs; my @hosts_to_datastores = (); for (my $x=0;$x < $pair_count;$x++) { (my $hostname,my $count) = split('_',$pairs[$x],2); push @hosts_to_datastores, $hostname; } #logic to figure out which hosts can not see this datastore my @intersection = (); my @difference = (); my %count = (); foreach my $element (@hosts_to_datastores, @hosts_seen) { $count{$element}++ } foreach my $element (keys %count) { push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element; } my $print_string = ""; if(@difference) { foreach (@difference) { $print_string .= $_." "; } } if($print_string eq '') { $print_string = "Accessible by all hosts in this cluster"; } else { $print_string = "".$print_string.""; } $datastore_row_info{$ds} .= $print_string; @hosts_to_datastores = (); } for my $datastore ( sort keys %datastore_row_info ) { my $value = $datastore_row_info{$datastore}; $datastoreString .= "".$datastore."".$value."\n"; } (%datastores,%datastore_row_info) = (); } if($HOST_PORTGROUP eq "yes") { for my $portgroup ( sort keys %portgroup_row_info ) { my $value = $portgroup_row_info{$portgroup}; if($demo eq "no") { $portgroupString .= "".$portgroup."".$value."\n"; } else { $portgroupString .= "demo_mode".$value."\n"; } } (%portgroup_row_info) = (); } ## Executed outside of the hosts ## ###################### # TASK ###################### if($HOST_TASK eq "yes") { my $taskMgr; eval { $taskMgr = Vim::get_view(mo_ref => $sc->taskManager); }; if(!$@) { my $tasks = Vim::get_views(mo_ref_array => $taskMgr->recentTask); foreach(@$tasks) { my $progress = $_->info->progress; if(!defined($progress)) { $progress = "COMPLETED"; } $taskString .= "".$_->info->descriptionId."".$_->info->queueTime."".($_->info->startTime ? $_->info->startTime : "N/A")."".($_->info->completeTime ? $_->info->completeTime : "N/A")."".$progress."".$_->info->state->val."\n"; } } } @hosts_seen = (); @datastores_seen = (); @hosts_in_portgroups = (); &buildHostReport($cluster_name,$cluster_count,$type,$atype,$aversion); } } sub buildHostReport { my ($cluster_name,$cluster_count,$type,$atype,$aversion) = @_; my ($hostTag,$hostTagShort,$table_host_conf) = ("","",""); if($HOST_STATE eq "yes" && $stateString ne "") { $hostTag = "ESX/ESXi State-$cluster_count"; $hostTagShort = "ESX/ESXi State"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $table_host_conf .= "\n"; } else { $table_host_conf .= "\n"; } $table_host_conf .= $stateString; $table_host_conf .= "
HOSTNAMEOVERALL STATUSPOWER STATEBOOT TIMEUPTIMEHA STATECONNECTION STATEMAINTENANCE MODESTANDBY MODEVMOTION ENABLEDVERSION
HOSTNAMEOVERALL STATUSPOWER STATEBOOT TIMECONNECTION STATEMAINTENANCE MODEVMOTION ENABLEDVERSION
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$stateString) = ("",""); } if($HOST_MGMT eq "yes" && $mgmtString ne "") { $hostTag = "ESX/ESXi Management Info-$cluster_count"; $hostTagShort = "ESX/ESXi Management Info"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $table_host_conf .= "\n"; } else { $table_host_conf .= "\n"; } $table_host_conf .= $mgmtString; $table_host_conf .= "
HOSTNAMEvCenterLOCKDOWN MODE ENABLEDCOS VMDKUUIDSERVICE CONSOLE MEM
HOSTNAMEvCenterLOCKDOWN MODE ENABLEDUUIDSERVICE CONSOLE MEM
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$mgmtString) = ("",""); } if($HOST_HARDWARE_CONFIGURATION eq "yes" && $hardwareConfigurationString ne "") { $hostTag = "ESX/ESXi Hardware Configuration-$cluster_count"; $hostTagShort = "ESX/ESXi Hardware Configuration"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; if($aversion eq "5.0.0") { $table_host_conf .= "\n"; } else { $table_host_conf .= "\n"; } $table_host_conf .= $hardwareConfigurationString; $table_host_conf .= "
HOSTNAMEVENDORADDITIONAL VENDOR INFOMODELCPU INFOSMC PRESENTHT AVAILABLECPU SPEEDCPU USAGEPROCESSOR SOCKETSCORES PER SOCKETLOGICAL CORESMEMORYMEMORY USAGENIC(s)HBA(s)
HOSTNAMEVENDORADDITIONAL VENDOR INFOMODELCPU INFOHT AVAILABLECPU SPEEDCPU USAGEPROCESSOR SOCKETSCORES PER SOCKETLOGICAL CORESMEMORYMEMORY USAGENIC(s)HBA(s)
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$hardwareConfigurationString) = ("",""); } if($HOST_HEALTH eq "yes" && $healthHardwareString ne "") { $hostTag = "ESX/ESXi Health Hardware Status-$cluster_count"; $hostTagShort = "ESX/ESXi Health Hardware Status"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $healthHardwareString; $table_host_conf .= "
COMPONENTSTATUS
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$healthHardwareString) = ("",""); } if($HOST_HEALTH eq "yes" && $healthSoftwareString ne "") { $hostTag = "ESX/ESXi Health Software Status-$cluster_count"; $hostTagShort = "ESX/ESXi Health Software Status"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "Click here for more detail info\n"; $table_host_conf .= "
\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $healthSoftwareString; $table_host_conf .= "
SENSOR NAMEREADINGSTATUS
\n"; $table_host_conf .= "
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$healthSoftwareString) = ("",""); } if($HOST_PERFORMANCE eq "yes" || $hostperformance eq "yes" && $hostPerfString ne "") { $hostTag = "ESX/ESXi Performance-$cluster_count"; $hostTagShort = "ESX/ESXi Performance"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $hostPerfString; $table_host_conf .= "
HOSTcpu.usagemhz.averagecpu.usage.averagemem.active.averagemem.usage.average
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$hostPerfString) = ("",""); } if($HOST_NIC eq "yes" && $nicString ne "") { $hostTag = "ESX/ESXi NIC(s)-$cluster_count"; $hostTagShort = "ESX/ESXi NIC(s)"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $nicString; $table_host_conf .= "
HOSTDEVICEPCIDRIVERDUPLEXSPEEDWOL ENABLEDMAC
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$nicString) = ("",""); } if($HOST_HBA eq "yes" && $hbaString ne "") { $hostTag = "ESX/ESXi HBA(s)-$cluster_count"; $hostTagShort = "ESX/ESXi HBA(s)"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $hbaString; $table_host_conf .= "
HOSTHBA TYPEDEVICEPCIMODELDRIVERSTATUSADDITIONAL INFO
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$hbaString) = ("",""); } if($HOST_ISCSI eq "yes" && $iscsiString ne "" && $aversion eq "5.0.0") { $hostTag = "ESX/ESXi iSCSI-$cluster_count"; $hostTagShort = "ESX/ESXi iSCSI"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $iscsiString; $table_host_conf .= "
HOSTVNICIP ADDRESSNETMASKMAC ADDRESSMTUTSO ENABLEDSPEEDPNICPORTGROUPVSWITCHSWITCH UUIDPATH STATUS
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$iscsiString) = ("",""); } if($HOST_CAPABILITY eq "yes" && $capString ne "") { $hostTag = "ESX/ESXi Capabilitie(s)-$cluster_count"; $hostTagShort = "ESX/ESXi Capabilitie(s)"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; if($aversion eq "5.0.0") { $table_host_conf .= "\n"; } elsif($aversion eq "4.1.0") { $table_host_conf .= "\n"; } else { $table_host_conf .= "\n"; } $table_host_conf .= $capString; $table_host_conf .= "
HOSTMAX RUNNING VMS SUPPORTMAX VCPUS SUPPORTVMFS VERSIONS SUPPORTFT SUPPORTIPMI SUPPORTTPM SUPPORTHV SUPPORTIORM SUPPORTDIRECTPATH G2 SUPPORTSTORAGE HW ACCELERATION SUPPORTSSL THUMBPRINT AUTH SUPPORT
HOSTFT SUPPORTIPMI SUPPORTTPM SUPPORTHV SUPPORTIORM SUPPORTDIRECTPATH G2 SUPPORTSTORAGE HW ACCELERATION SUPPORTSSL THUMBPRINT AUTH SUPPORT
HOSTFT SUPPORTIPMI SUPPORTTPM SUPPORTHV SUPPORTSSL THUMBPRINT AUTH SUPPORT
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$capString) = ("",""); } if($HOST_CONFIGURATION eq "yes" && $configString ne "") { $hostTag = "ESX/ESXi Configuration(s)-$cluster_count"; $hostTagShort = "ESX/ESXi Configuration(s)"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= $configString; #$table_host_conf .= "\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$configString) = ("",""); } if($HOST_ADVOPT eq "yes" && $advString ne "") { $hostTag = "ESX/ESXi Advanced Options-$cluster_count"; $hostTagShort = "ESX/ESXi Advanced Options"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0" ) { $table_host_conf .= "\n"; } else { $table_host_conf .= "\n"; } $table_host_conf .= $advString; $table_host_conf .= "
HOSTDisk.UseDeviceResetDisk.UseLunResetDisk.SchedNumReqOutstandingSc si.ConflictRetriesNFS.MaxVolumesSendBufferSizeReceiveBufferSizeNet.TcpipHeapSizeNFS.HeartbeatFrequencyN FS.HeartbeatTimeoutNFS.HeartbeatMaxFailuresVMkernel.Boot.techSupportModeVMFS3.HardwareAcceleratedLockingDataMover.Hardwar eAcceleratedMoveDataMover.HardwareAcceleratedInit
HOSTDisk.UseDeviceResetDisk.UseLunResetDisk.SchedNumReqOutstandingSc si.ConflictRetriesNFS.MaxVolumesSendBufferSizeReceiveBufferSizeNet.TcpipHeapSizeNFS.HeartbeatFrequencyN FS.HeartbeatTimeoutNFS.HeartbeatMaxFailuresVMkernel.Boot.techSupportMode
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$advString) = ("",""); } if($HOST_ADVOPT eq "yes" && $agentString ne "" && $atype eq "VirtualCenter" && $aversion eq "5.0.0") { $hostTag = "ESX/ESXi Host Agent Settings-$cluster_count"; $hostTagShort = "ESX/ESXi Host Agent Settings"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $agentString; $table_host_conf .= "
HOSTAGENT VM DATASTOREAGENT VM NETWORK
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$agentString) = ("",""); } if($HOST_NUMA eq "yes" && $numaString ne "") { $hostTag = "ESX/ESXi NUMA-$cluster_count"; $hostTagShort = "ESX/ESXi NUMA"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $numaString; $table_host_conf .= "
HOST# NODESTYPENUMA NODE INFO
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$numaString) = ("",""); } if($HOST_CDP eq "yes" && $cdpString ne "") { $hostTag = "ESX/ESXi CDP-$cluster_count"; $hostTagShort = "ESX/ESXi CDP"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $cdpString; $table_host_conf .= "
HOSTDEVICEMGMT ADDRESSDEVICE ADDRESSIP PREFIXLOCATIONSYSTEM NAMESYSTEM VERSIONSYSTEM OIDPLATFORMDEVICE IDCDP VERFULL DUPLEXMTUTIMEOUTTTLVLAN IDSAMPLES
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$cdpString) = ("",""); } if($HOST_DVS eq "yes" && $atype eq "VirtualCenter" && $dvsString ne "") { $hostTag = "ESX/ESXi Distributed vSwitch-$cluster_count"; $hostTagShort = "ESX/ESXi Distributed vSwitch"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $dvsString; $table_host_conf .= "
NAMEDESCRIPTIONCONTACT INFOVENDORVERSIONUUIDBUILD BUNDLE IDBUNDLE BUILDBUNDLE URLFORWARDING CLASSPORTS
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$numaString) = ("",""); } if($HOST_LUN eq "yes" && $lunString) { $hostTag = "ESX/ESXi LUN(s)-$cluster_count"; $hostTagShort = "ESX/ESXi LUN(s)"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $table_host_conf .= "\n"; } else { $table_host_conf .= "\n"; } $table_host_conf .= $lunString; $table_host_conf .= "
VOLUME UUIDDATASTOREDISK_NAMEDEVICE_NAMEQUEUE DEPTHvSTORAGE SUPPORTSTATUSVENDORMODELHOST(s) NOT ACCESSIBLE TO LUN
VOLUME UUIDDATASTOREDISK_NAMEDEVICE_NAMEQUEUE DEPTHSTATUSVENDORMODELHOST(s) NOT ACCESSIBLE TO LUN
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$lunString) = ("",""); } if($HOST_DATASTORE eq "yes" && $datastoreString ne "") { $hostTag = "ESX/ESXi Datastore(s)-$cluster_count"; $hostTagShort = "ESX/ESXi Datastore(s)"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "
COLOR LEGENDYELLOW < $YELLOW_WARN %ORANGE < $ORANGE_WARN %RED < $RED_WARN %
\n"; $table_host_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $table_host_conf .= "\n"; } else { $table_host_conf .= "\n"; } $table_host_conf .= $datastoreString; $table_host_conf .= "
DATASTORE# OF VMSCAPACITYCONSUMEDFREE% FREEBLOCK SIZEVERSIONDS TYPEMAINTENANCE MODEIORM ENABLEDCONGESTION THRESHOLDSTATS AGGREGATION DIABLEDSTATS COLLECTION ENABLEDHOST(s) NOT ACCESSIBLE TO DATASTORE
DATASTORE# OF VMSCAPACITYCONSUMEDFREE% FREEBLOCK SIZEVERSIONDS TYPEHOST(s) NOT ACCESSIBLE TO DATASTORE
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$datastoreString) = ("",""); } if($HOST_CACHE eq "yes" && $aversion eq "5.0.0") { $hostTag = "ESX/ESXi Cache Configuration-$cluster_count"; $hostTagShort = "ESX/ESXi Cache Configuration"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $cacheString; $table_host_conf .= "
HOSTCACHE DATASTORESWAPSIZE
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$cacheString) = ("",""); } if($HOST_PORTGROUP eq "yes" && $portgroupString ne "") { $hostTag = "ESX/ESXi Portgroup(s)-$cluster_count"; $hostTagShort = "ESX/ESXi Portgroup(s)"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $portgroupString; $table_host_conf .= "
PORTGROUPHOST(s) NOT ACCESSIBLE TO PORTGROUP
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$portgroupString) = ("",""); } if($HOST_MULTIPATH eq "yes" && $multipathString ne "") { $hostTag = "ESX/ESXi Multipathing-$cluster_count"; $hostTagShort = "ESX/ESXi Multipathing"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; ###DEBUG #$table_host_conf .= "\n"; $table_host_conf .= $multipathString; $table_host_conf .= "
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$multipathString) = ("",""); } if($HOST_LOG eq "yes" && $logString ne "") { $hostTag = "ESX/ESXi Hostd Logs-$cluster_count - Last $logcount lines"; $hostTagShort = "ESX/ESXi Hostd Logs - Last $logcount lines"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= $logString; $table_host_conf .= "
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$logString) = ("",""); } if($HOST_TASK eq "yes" && $taskString ne "") { $hostTag = "ESX/ESXi Recent Tasks-$cluster_count"; $hostTagShort = "ESX/ESXi Recent Tasks"; push @host_jump_tags,"            $hostTagShort
\n"; $table_host_conf .= "\n"; $table_host_conf .= "

$hostTagShort:

\n"; $table_host_conf .= "\n"; $table_host_conf .= "\n"; $table_host_conf .= $taskString; $table_host_conf .= "
DESCRIPTIONQUEUE TIMESTART TIMECOMPLETION TIMEPROGRESSSTATE
\n"; $hostString .= "
".$table_host_conf; ($table_host_conf,$numaString) = ("",""); } print REPORT_OUTPUT $hostString; $hostString = ""; } sub buildVMReport { my ($cluster_name,$cluster_count,$type,$atype,$aversion) = @_; my ($hostTag,$hostTagShort,$table_vm_conf) = ("","",""); if($VM_STATE eq "yes" && $vmstateString ne "") { $hostTag = "VM State-$cluster_count"; $hostTagShort = "VM State"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $table_vm_conf .= "\n"; } else { $table_vm_conf .= "\n"; } $table_vm_conf .= $vmstateString; $table_vm_conf .= "
HOSTVMBOOTTIMEUPTIMEOVERALL STATUSHA PROTECTEDAPP HEARTBEATCONNECTION STATEPOWER STATECONSOLIDATION NEEDED
HOSTVMBOOTTIMEOVERALL STATUSCONNECTION STATEPOWER STATE
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmstateString) = ("",""); } if($VM_CONFIG eq "yes" && $vmconfigString ne "") { $hostTag = "VM Configuration-$cluster_count"; $hostTagShort = "VM Configuration"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $table_vm_conf .= "\n"; } else { $table_vm_conf .= "\n"; } $table_vm_conf .= $vmconfigString; $table_vm_conf .= "
HOSTVMvHWHOSTNAMEUUIDFIRMWAREOS# of vCPUvMEM# of vDISKvDISK# of vNICCPU RESERVMEM RESERVIS TEMPLATE
HOSTVMvHWHOSTNAMEUUIDOS# of vCPUvMEM# of vDISKvDISK# of vNICCPU RESERVMEM RESERVIS TEMPLATE
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmconfigString) = ("",""); } if($VM_STATS eq "yes" && $vmstatString ne "") { $hostTag = "VM Statistics-$cluster_count"; $hostTagShort = "VM Statistics"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $table_vm_conf .= "\n"; } else { $table_vm_conf .= "\n"; } $table_vm_conf .= $vmstatString; $table_vm_conf .= "
HOSTVMCPU USAGEMEM USAGEMAX CPU USAGEMAX MEM USAGEACTIVE MEMHOST CONSUMED MEMINITIAL MEM RESV OVERHEADINITIAL MEM SWAP RESV OVERHEADMEM OVERHEADMEM BALLONCOMPRESSED MEM
HOSTVMCPU USAGEMEM USAGEMAX CPU USAGEMAX MEM USAGEACTIVE MEMHOST CONSUMED MEMMEM OVERHEADMEM BALLON
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmstatString) = ("",""); } if($VM_RESOURCE_ALLOCATION eq "yes" && $vmrscString ne "") { $hostTag = "VM Resource Allocation-$cluster_count"; $hostTagShort = "VM Resource Allocation"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmrscString; $table_vm_conf .= "
HOSTVMLAST MODIFIEDCPU RESERVATIONCPU LIMITSCPU SHARECPU SHARE LEVELCPU EXPANDABLE RESERVATIONCPU OVERHEAD LIMITMEM RESERVATIONMEM LIMITSMEM SHAREMEM SHARE LEVELMEM EXPANDABLE RESERVATIONMEM OVERHEAD LIMIT
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmrscString) = ("",""); } if($VM_PERFORMANCE eq "yes" || $vmperformance eq "yes" && $vmPerfString ne "") { $hostTag = "VM Performance-$cluster_count"; $hostTagShort = "VM Performance"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "
VMcpu.usagemhz.averagecpu.usage.averagecpu.ready.summationmem.active.averagemem.usage.averagecpu.vmmemctl.average\n"; $table_vm_conf .= $vmPerfString; $table_vm_conf .= "
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmPerfString) = ("",""); } if($VM_FT eq "yes" && $vmftString ne "") { $hostTag = "VM Fault Tolerance-$cluster_count"; $hostTagShort = "VM Fault Tolerance"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmftString; $table_vm_conf .= "
HOSTVMFT STATEROLEINSTANCE UUIDSFT SECONDARY LATENCYFT BANDWIDTH
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmftString) = ("",""); } if($VM_EZT eq "yes" && $vmeztString ne "" && $aversion eq "5.0.0") { $hostTag = "VM Eagerzeroed Thick (EZT) Provisioned-$cluster_count"; $hostTagShort = "VM Eagerzeroed Thick (EZT) Provisioned"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmeztString; $table_vm_conf .= "
HOSTVMLABELEZT VMDK(s)CAPACITY
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmeztString) = ("",""); } if($VM_THIN eq "yes" && $vmthinString ne "") { $hostTag = "VM Thin Provisioned-$cluster_count"; $hostTagShort = "VM Thin Provisioned"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmthinString; $table_vm_conf .= "
HOSTVMLABELTHIN VMDK(s)CAPACITY
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmthinString) = ("",""); } if($VM_DEVICE eq "yes" && $vmdeviceString ne "") { $hostTag = "VM Device(s)-$cluster_count"; $hostTagShort = "VM Device(s)"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmdeviceString; $table_vm_conf .= "
HOSTVMOSCDROMCONTROLLERDISKETHERNET CARDFLOPPYKEYBOARDVIDEO CARDVMCIVMIROMPARALLEL PORTPCI PASSTHROUGHPOINTING DEVICESCSI PASSTHROUGHSERIAL PORTSOUND CARDUSB
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmdeviceString) = ("",""); } if($VM_STORAGE eq "yes" && $vmstorageString ne "") { $hostTag = "VM Storage-$cluster_count"; $hostTagShort = "VM Storage"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "
COLOR LEGENDYELLOW < $YELLOW_WARN %ORANGE < $ORANGE_WARN %RED < $RED_WARN %
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmstorageString; $table_vm_conf .= "
HOSTVM
DISK INFOFREE SPACECAPACITY% FREE
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmstorageString) = ("",""); } if($VM_NETWORK eq "yes" && $vmnetworkString ne "") { $hostTag = "VM Network-$cluster_count"; $hostTagShort = "VM Network"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmnetworkString; $table_vm_conf .= "
HOSTVMIP ADDRESS(s)MAC ADDRESS(s)PORTGROUP(s)CONNECTED
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmnetworkString) = ("",""); } if($VM_SNAPSHOT eq "yes" && $vmsnapString ne "") { $hostTag = "VM Snapshots-$cluster_count"; $hostTagShort = "VM Snapshots"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmsnapString; $table_vm_conf .= "
HOSTVMSNAPSHOT NAMESNAPSHOT DESCCREATEDSTATEQUIESCED
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmsnapString) = ("",""); } if($VM_DELTA eq "yes" && $vmdeltaString ne "") { $hostTag = "VM Deltas-$cluster_count"; $hostTagShort = "VM Deltas"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "
COLOR LEGENDYELLOW > $SNAPSHOT_YELLOW_WARN daysORANGE > $SNAPSHOT_ORANGE_WARN daysRED > $SNAPSHOT_RED_WARN days
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmdeltaString; $table_vm_conf .= "
DATASTOREVM DELTAAGESIZECREATED
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmdeltaString) = ("",""); } if($VM_CDROM eq "yes" && $vmcdString ne "") { $hostTag = "VM Mounted CD-ROM-$cluster_count"; $hostTagShort = "VM Mounted CD-ROM"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmcdString; $table_vm_conf .= "
HOSTVMISO
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmcdString) = ("",""); } if($VM_FLOPPY eq "yes" && $vmflpString ne "") { $hostTag = "VM Mounted Floppy-$cluster_count"; $hostTagShort = "VM Mounted Floppy"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmflpString; $table_vm_conf .= "
HOSTVMIMG
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmflpString) = ("",""); } if($VM_TOOL eq "yes" && $vmtoolString) { $hostTag = "VM VMware Tools-$cluster_count"; $hostTagShort = "VM VMware Tools"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmtoolString; $table_vm_conf .= "
HOSTVMVERSIONRUNNING STATUSVERSION STATUSUPGRADE POLICYSYNC TIME W/HOST
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmtoolString) = ("",""); } if($VM_RDM eq "yes" && $vmrdmString ne "") { $hostTag = "VM RDMs-$cluster_count"; $hostTagShort = "VM RDMs"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmrdmString; $table_vm_conf .= "
HOSTVMCOMPAT MODEDEVICEDISK MODELUN UUIDVIRTUAL DISK UUID
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmrdmString) = ("",""); } if($VM_NPIV eq "yes" && $vmnpivString ne "") { $hostTag = "VM NPIV-$cluster_count"; $hostTagShort = "VM NPIV"; push @vm_jump_tags,"            $hostTagShort
\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "

$hostTagShort:

\n"; $table_vm_conf .= "\n"; $table_vm_conf .= "\n"; $table_vm_conf .= $vmnpivString; $table_vm_conf .= "
HOSTVMNODE WWNPORT WWNGENERATED FROMDESIRED NODE WWNDESIRED PORT WWN
\n"; $vmString .= "
".$table_vm_conf; ($table_vm_conf,$vmnpivString) = ("",""); } print REPORT_OUTPUT $vmString; $vmString = ""; } sub printClusterSummary { my ($local_cluster,$cluster_count,$atype,$aversion) = @_; my $cluster_name = $local_cluster->name; my $cluster_health = $local_cluster->overallStatus->val; my $cluster_host_cnt = $local_cluster->summary->numHosts; my $cluster_avail_host = $local_cluster->summary->numEffectiveHosts; my $cluster_cpu_cnt = prettyPrintData($local_cluster->summary->totalCpu,'MHZ'); my $cluster_mem_cnt = prettyPrintData($local_cluster->summary->totalMemory,'B'); my $cluster_avail_cpu = prettyPrintData($local_cluster->summary->effectiveCpu,'MHZ'); my $cluster_avail_mem = prettyPrintData($local_cluster->summary->effectiveMemory,'M'); my $cluster_drs = $local_cluster->configuration->drsConfig->enabled; my $cluster_ha = $local_cluster->configuration->dasConfig->enabled; my $cluster_dpm = $local_cluster->configurationEx->dpmConfigInfo->enabled; my $cluster_vm_mon = $local_cluster->configuration->dasConfig->vmMonitoring; my $cluster_host_mon = $local_cluster->configuration->dasConfig->hostMonitoring; my $vmotions = $local_cluster->summary->numVmotions; my ($mem_perc_string,$cpu_perc_string,$evc,$spbm,$hbDSPolicy) = ("","","DISABLED","N/A","N/A"); my $curr_bal = ($local_cluster->summary->currentBalance ? ($local_cluster->summary->currentBalance/1000) : "N/A"); my $tar_bal = ($local_cluster->summary->targetBalance ? ($local_cluster->summary->targetBalance/1000) : "N/A"); if($local_cluster->summary->currentEVCModeKey) { $evc = $local_cluster->summary->currentEVCModeKey; } if($aversion eq "5.0.0") { if(defined($local_cluster->configurationEx->spbmEnabled)) { $spbm = $local_cluster->configurationEx->spbmEnabled ? "YES" : "NO"; } if(defined($local_cluster->configurationEx->dasConfig->hBDatastoreCandidatePolicy)) { $hbDSPolicy = $local_cluster->configurationEx->dasConfig->hBDatastoreCandidatePolicy; } } ########################### # CLUSTER SUMMARY ########################### push @cluster_jump_tags,"CLCluster: $cluster_name
\n"; my $cluster_start .= "\n"; $cluster_start .= "

Cluster: $cluster_name

\n"; my ($hostTag,$hostTagShort) = ("",""); ########################### # SUMMARY ########################### if($CLUSTER_SUMMARY eq "yes") { $hostTag = "Cluster Summary-$cluster_name"; $hostTagShort = "Cluster Summary"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

Cluster Summary:

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; my $rp = Vim::get_view(mo_ref => $local_cluster->resourcePool, properties => ['vm']); my $vms = Vim::get_views(mo_ref_array => $rp->{'vm'}, properties => ['name']); my $num_of_vms = 0; if(@$vms ne 0) { $num_of_vms = @$vms; } my $vm_host_ratio = "N/A"; if($cluster_avail_host eq 1 && ($num_of_vms ne 0 || $num_of_vms eq 1)) { $vm_host_ratio = $num_of_vms } elsif($num_of_vms eq 1) { $vm_host_ratio = $num_of_vms } elsif($num_of_vms ne 0 && $cluster_avail_host ne 0) { $vm_host_ratio = int($num_of_vms/$cluster_avail_host); } else { $vm_host_ratio = $num_of_vms; } $cluster_start .= ""; if($cluster_health eq 'gray' ) { $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= "\n
CLUSTER HEALTHAVAILABLE HOST(s)# OF VMSVM-TO-HOST RATIOCURRENT BALANCETARGET BALANCEAVAILABLE CPUAVAILABLE MEMDRS ENABLEDHA ENABLEDDPM ENABLEDEVC ENABLEDSPBM ENABLED# OF vMOTIONS
UNKNOWN"; } if($cluster_health eq 'green' ) { $cluster_start .= "CLUSTER OK"; } if($cluster_health eq 'red' ) { $cluster_start .= "CLUSTER HAS PROBLEM"; } if($cluster_health eq 'yellow' ) { $cluster_start .= "CLUSTER MIGHT HAVE PROBLEM"; } $cluster_start .= "".$cluster_avail_host."/".$cluster_host_cnt."".$num_of_vms."".$vm_host_ratio."".$curr_bal."".$tar_bal."".$cluster_avail_cpu."".$cluster_avail_mem."".(($cluster_drs) ? "YES" : "NO")."".(($cluster_ha) ? "YES" : "NO")."".(($cluster_dpm) ? "YES" : "NO")."".$evc."".$spbm."".$vmotions."
\n"; } ########################### # CLUSTER PERFORMANCE ########################### if($CLUSTER_PERFORMANCE eq "yes" || $clusterperformance eq "yes") { my $clusterPerfString = &getCpuAndMemPerf($local_cluster); $cluster_start .= $clusterPerfString; } ########################### # PRINT HA INFO ########################### if($cluster_ha && $CLUSTER_HA eq "yes") { $hostTag = "HA Configurations-$cluster_name"; $hostTagShort = "HA Configurations"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

HA Configurations

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; if(defined($local_cluster->configuration->dasConfig->admissionControlPolicy)) { my $admissionControlPolicy = $local_cluster->configuration->dasConfig->admissionControlPolicy; if($admissionControlPolicy->isa('ClusterFailoverHostAdmissionControlPolicy')) { if($admissionControlPolicy->failoverHosts) { my $failoverHosts = $admissionControlPolicy->failoverHosts; my $failoverHostString = ""; foreach(@$failoverHosts) { my $fhost = Vim::get_view(mo_ref => $_, properties => ['name']); $failoverHostString .= $fhost->{'name'} . "
"; } $cluster_start .= ""; } else { $cluster_start .= ""; } }elsif($admissionControlPolicy->isa('ClusterFailoverLevelAdmissionControlPolicy')) { $cluster_start .= ""; }elsif($admissionControlPolicy->isa('ClusterFailoverResourcesAdmissionControlPolicy')) { $cluster_start .= ""; } else { $cluster_start .= ""; } } else { $cluster_start .= ""; } $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= "
FAILOVER LEVELADMISSION CONTROL ENABLEDISOLATION RESPONSERESTART PRIORITYVM MONITORINGHOST MONITORINGHB DATASTORE POLICY
".$failoverHostString."N/A".$admissionControlPolicy->failoverLevel."".$admissionControlPolicy->cpuFailoverResourcesPercent."% CPU -- ".$admissionControlPolicy->memoryFailoverResourcesPercent." %MEM "."N/AN/A".(($local_cluster->configuration->dasConfig->admissionControlEnabled) ? "YES" : "NO")."".$local_cluster->configuration->dasConfig->defaultVmSettings->isolationResponse."".$local_cluster->configuration->dasConfig->defaultVmSettings->restartPriority."".$cluster_vm_mon."".$cluster_host_mon."".$hbDSPolicy."
\n"; my $haAdvInfo; eval { $haAdvInfo = $local_cluster->RetrieveDasAdvancedRuntimeInfo(); }; if(!$@) { if($haAdvInfo) { my @configIssues = (); ## HA ADV INFO ## $cluster_start .= "

HA Advanced Runtime Info

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; if($haAdvInfo->isa('ClusterDasFailoverLevelAdvancedRuntimeInfo')) { $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; } else { $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= ""; } $cluster_start .= "
SLOT SIZETOTAL SLOTS IN CLUSTERUSED SLOTSAVAILABLE SLOTSTOTAL POWERED ON VMSTOTAL HOSTSTOTAL GOOD HOSTS
".($haAdvInfo->slotInfo->cpuMHz ? $haAdvInfo->slotInfo->cpuMHz : "N/A"). " MHz -- ".($haAdvInfo->slotInfo->numVcpus ? $haAdvInfo->slotInfo->numVcpus : "N/A"). " vCPUs -- ".($haAdvInfo->slotInfo->memoryMB ? $haAdvInfo->slotInfo->memoryMB : "N/A")." MB".$haAdvInfo->totalSlots."".$haAdvInfo->usedSlots."".$haAdvInfo->unreservedSlots."".$haAdvInfo->totalVms."".$haAdvInfo->totalHosts."".$haAdvInfo->totalGoodHosts."N/AN/AN/AN/AN/AN/AN/A
\n"; ## HA HEARTBEAT DATASTORE ## if($aversion eq "5.0.0" && $haAdvInfo->heartbeatDatastoreInfo) { my $hahbInfo = $haAdvInfo->heartbeatDatastoreInfo; $hostTag = "Heartbeat Datastores-$cluster_name"; $hostTagShort = "Heartbeat Datastores"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

Heartbeat Datastores

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; foreach(@$hahbInfo) { my $hbDSName = Vim::get_view(mo_ref => $_->datastore, properties => ['name']); my $hbHostMount = Vim::get_views(mo_ref_array=> $_->hosts, properties => ['name']); $cluster_start .= ""; } $cluster_start .= "
DATASTOREHOSTS MOUNTED
".$hbDSName->{'name'}."".@$hbHostMount."
\n"; } ## HA HOSTS INFO ## if($haAdvInfo->dasHostInfo && $haAdvInfo->dasHostInfo->hostDasState) { $cluster_start .= "

HA Host Info

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; my ($nodeStates,$primHosts,$secondHosts,$dasstring) = ("","","",""); my %primary = (); $cluster_start .= ""; if($haAdvInfo->dasHostInfo->primaryHosts) { my $dashosts = $haAdvInfo->dasHostInfo->primaryHosts; foreach my $dasHost (@$dashosts) { if($demo eq "yes") { $dasHost = $host_name; } $primHosts .= $dasHost."
"; $primary{$dasHost} = "yes"; } $cluster_start .= ""; } if($haAdvInfo->dasHostInfo->hostDasState) { $dasstring .= ""; } $cluster_start .= ""; $cluster_start .= "
HA PRIMARY HOSTSHA SECONDARY HOSTSNODE STATES
".$primHosts.""; my $dasstates = $haAdvInfo->dasHostInfo->hostDasState; foreach(@$dasstates) { my $dasHost; if($demo eq "yes") { $dasHost = $host_name; } else { $dasHost = $_->name; } $dasstring .= "\n"; if(!$primary{$dasHost}) { $secondHosts .= $dasHost."
"; } my $tmpHostMoRef = Vim::get_view(mo_ref => $_->host); if($tmpHostMoRef->configIssue) { my $hostConfigIssues = $tmpHostMoRef->configIssue; foreach(@$hostConfigIssues) { my $issue = $tmpHostMoRef->name . ";" . ($_->fullFormattedMessage ? $_->fullFormattedMessage : "N/A"); push @configIssues, $issue; } } } $cluster_start .= ""; $cluster_start .= $dasstring; $cluster_start .= "
NODECONFIG STATERUN STATE
".$dasHost."".$_->configState."".$_->runtimeState."
".$secondHosts."
\n"; %primary = (); } if($local_cluster->configIssue) { my $clusterConfigIssues = $local_cluster->configIssue; foreach(@$clusterConfigIssues) { my $issue = $local_cluster->name . ";" . ($_->fullFormattedMessage ? $_->fullFormattedMessage : "N/A"); push @configIssues, $issue; } } ## HA CONFIGURATION ISSUE## if(@configIssues) { $cluster_start .= "

HA Configuration Issues

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; foreach(@configIssues) { my ($configIssueEntity,$configIssueMsg) = split(';',$_); $cluster_start .= "\n"; } $cluster_start .= "
ENTITYHA ISSUE
".$configIssueEntity."".$configIssueMsg."
"; } ## HA ADV OPTIONS ## if($local_cluster->configurationEx->dasConfig->option) { $cluster_start .= "

HA Advanced Configurations

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; my $haadv_string = ""; my $advHAOptions = $local_cluster->configurationEx->dasConfig->option; foreach(@$advHAOptions) { $haadv_string .= "\n"; } $cluster_start .= $haadv_string; $cluster_start .= "
ATTRIBUTEVALUE
".$_->key."".$_->value."
\n"; } } } } ########################### # PRINT DRS INFO ########################### if($cluster_drs && $CLUSTER_DRS eq "yes") { $hostTag = "DRS Configurations-$cluster_name"; $hostTagShort = "DRS Configurations"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

DRS Configurations

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; $cluster_start .= ""; $cluster_start .= ""; $cluster_start .= "
DRS BEHAVIORVMOTION RATE
".$local_cluster->configuration->drsConfig->defaultVmBehavior->val."".$local_cluster->configuration->drsConfig->vmotionRate."
\n"; ## DRS ADV OPTIONS ## if($local_cluster->configurationEx->drsConfig->option) { $cluster_start .= "

DRS Advanced Configurations

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; my $drsadv_string = ""; my $advHAOptions = $local_cluster->configurationEx->drsConfig->option; foreach(@$advHAOptions) { $drsadv_string .= "\n"; } $cluster_start .= $drsadv_string; $cluster_start .= "
ATTRIBUTEVALUE
".$_->key."".$_->value."
\n"; } } ########################### # PRINT DPM INFO ########################### if($cluster_dpm && $CLUSTER_DPM eq "yes") { $hostTag = "DPM Configurations-$cluster_name"; $hostTagShort = "DPM Configurations"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

DPM Configurations

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; $cluster_start .= ""; $cluster_start .= "
DPM BEHAVIOR
".$local_cluster->configurationEx->dpmConfigInfo->defaultDpmBehavior->val."
\n"; } ########################### # AFFINITY RULES ########################### if($CLUSTER_AFFINITY eq "yes") { if($local_cluster->configurationEx->rule) { my $rules = $local_cluster->configurationEx->rule; $hostTag = "Affinity Rules-$cluster_name"; $hostTagShort = "Affinity Rules"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

Affinity Rules:

\n"; $cluster_start .= "\n"; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $cluster_start .= "\n"; } else { $cluster_start .= "\n"; } foreach(sort {$a->name cmp $b->name} @$rules) { my $rule = $_; my $is_enabled = $rule->enabled; my $rule_name = $rule->name; my $rule_type = "CLUSTER-RULE"; my $compliant; if($aversion eq "4.1.0" || $aversion eq "5.0.0") { if($rule->inCompliance) { $compliant = ""; } else { $compliant = ""; } } if(ref($rule) eq 'ClusterAffinityRuleSpec') { $rule_type = "AFFINITY"; } elsif (ref($rule) eq 'ClusterAntiAffinityRuleSpec') { $rule_type = "ANTI-AFFINITY"; } my $listOfVMs = Vim::get_views(mo_ref_array => $_->{'vm'}, properties => ['name']); my $listOfVmsString = ""; foreach(@$listOfVMs) { $listOfVmsString .= $_->{'name'}."
"; } if($aversion eq "4.1.0" || $aversion eq "5.0.0") { $cluster_start .= "".$compliant."\n"; } else { $cluster_start .= "\n"; } } $cluster_start .= "
RULE NAMERULE TYPEENABLEDVM(s)COMPLIANTMANDATORYUSER CREATED
RULE NAMERULE TYPEENABLEDVM(s)
YESNO
".$rule_name."".$rule_type."".(($is_enabled) ? "YES" : "NO")."".$listOfVmsString."".($rule->mandatory ? "YES" : "NO")."".($rule->userCreated ? "YES" : "NO")."
".$rule_name."".$rule_type."".(($is_enabled) ? "YES" : "NO")."".$listOfVmsString."
\n"; } } ########################### # AFFINITY GROUP RULES ########################### if($CLUSTER_GROUP eq "yes" && $aversion eq "4.1.0" || $aversion eq "5.0.0") { if($local_cluster->configurationEx->group) { my $groups = $local_cluster->configurationEx->group; $hostTag = "Affinity Group Rules-$cluster_name"; $hostTagShort = "Affinity Group Rules"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

Affinity Group Rules:

\n"; my ($drsHostsGroupString,$drsVMGroupString) = ("",""); foreach(sort {$a->name cmp $b->name} @$groups) { if($_->isa('ClusterHostGroup')) { my $listOfHosts = Vim::get_views(mo_ref_array => $_->host, properties => ['name']); my $listOfHostsString = ""; foreach(@$listOfHosts) { $listOfHostsString .= $_->{'name'}."
"; } $drsHostsGroupString .= "".$_->name."".$listOfHostsString."\n"; }elsif($_->isa('ClusterVmGroup')) { my $listOfVms = Vim::get_views(mo_ref_array => $_->vm, properties => ['name']); my $listOfVmsString = ""; foreach(@$listOfVms) { $listOfVmsString .= $_->{'name'}."
"; } $drsVMGroupString .= "".$_->name."".$listOfVmsString."\n"; } } #HOST GROUP if($drsHostsGroupString ne "") { $cluster_start .= "\n"; $cluster_start .= "\n"; $cluster_start .= $drsHostsGroupString; $cluster_start .= "
RULE NAMEHOST(s)

\n"; } #VM GROUP if($drsVMGroupString ne "") { $cluster_start .= "\n"; $cluster_start .= "\n"; $cluster_start .= $drsVMGroupString; $cluster_start .= "
RULE NAMEVM(s)

\n"; } } } ########################### # RESOURCE POOLS ########################### my ($resource_pool_string,$vapp_string) = ("",""); if($CLUSTER_VAPP eq "yes" || $CLUSTER_RP eq "yes") { my $root_rp = Vim::get_view (mo_ref => $local_cluster->resourcePool); my $resourcePools = $root_rp->resourcePool; foreach(@$resourcePools) { my $rp = Vim::get_view(mo_ref => $_); if($rp->isa('VirtualApp')) { my $vapp_name = $rp->name; my $anno = ($rp->vAppConfig->annotation ? $rp->vAppConfig->annotation : "N/A"); my $ec = $rp->vAppConfig->entityConfig; my $vm_vapp_string = ""; foreach(@$ec) { my $order = $_->startOrder; my $tag = $_->tag; $vm_vapp_string .= "".$tag."".$order."\n"; } $vapp_string .= "".$vapp_name."\n"; $vapp_string .= "VMSTART ORDER\n"; $vapp_string .= $vm_vapp_string."\n"; } else { my $rp_name = $rp->name; my $rp_status = $rp->summary->runtime->overallStatus->val; if($rp_status eq 'gray') { $rp_status = "UNKNOWN"; } elsif($rp_status eq 'green') { $rp_status = "GREEN"; } elsif($rp_status eq 'red') { $rp_status = "RED"; } elsif($rp_status eq 'yellow') { $rp_status = "YELLOW"; } my $rp_cpu_use = prettyPrintData($rp->summary->runtime->cpu->overallUsage,'MHZ'); my $rp_cpu_max = prettyPrintData($rp->summary->runtime->cpu->maxUsage,'MHZ'); my $rp_cpu_lim = prettyPrintData($rp->summary->config->cpuAllocation->limit,'MHZ'); my $rp_cpu_rsv = prettyPrintData($rp->summary->config->cpuAllocation->reservation,'MHZ'); my $rp_mem_use = prettyPrintData($rp->summary->runtime->memory->overallUsage,'B'); my $rp_mem_max = prettyPrintData($rp->summary->runtime->memory->maxUsage,'B'); my $rp_mem_lim = prettyPrintData($rp->summary->config->cpuAllocation->limit,'M'); my $rp_mem_rsv = prettyPrintData($rp->summary->config->cpuAllocation->reservation,'M'); my ($rp_cpu_shares,$rp_mem_shares) = ("N/A","N/A"); if($rp->summary->config->cpuAllocation) { $rp_cpu_shares = ($rp->summary->config->cpuAllocation->shares->shares ? $rp->summary->config->cpuAllocation->shares->shares : "N/A"); } if($rp->summary->config->memoryAllocation) { $rp_mem_shares = ($rp->summary->config->memoryAllocation->shares->shares ? $rp->summary->config->memoryAllocation->shares->shares : "N/A"); } my $vmInRp = 0; if($rp->vm) { my $vmsInRp = Vim::get_views(mo_ref_array => $rp->vm, properties => ['name']); $vmInRp = scalar(@$vmsInRp); } my ($cpuUnitsPerVM,$memUnitsPerVM) = ("N/A","N/A"); if($vmInRp != 0 && $rp_cpu_shares ne "N/A") { $cpuUnitsPerVM = floor($rp_cpu_shares/$vmInRp); } if($vmInRp != 0 && $rp_mem_shares ne "N/A") { $memUnitsPerVM = floor($rp_mem_shares/$vmInRp); } $resource_pool_string .= "".$rp_name.""; $resource_pool_string .= $rp_status; $resource_pool_string .= "".$vmInRp.""; $resource_pool_string .= "".$rp_cpu_shares.""; $resource_pool_string .= "".$cpuUnitsPerVM.""; $resource_pool_string .= "".$rp_mem_shares.""; $resource_pool_string .= "".$memUnitsPerVM.""; $resource_pool_string .= "".$rp_cpu_lim.""; $resource_pool_string .= "".$rp_cpu_rsv.""; $resource_pool_string .= "".$rp_mem_lim.""; $resource_pool_string .= "".$rp_mem_rsv.""; $resource_pool_string .= "".$rp_cpu_use.""; $resource_pool_string .= "".$rp_cpu_max.""; $resource_pool_string .= "".$rp_mem_use.""; $resource_pool_string .= "".$rp_mem_max."\n"; } } } if($CLUSTER_RP eq "yes") { if($resource_pool_string ne "") { $hostTag = "Resource Pool(s)-$cluster_name"; $hostTagShort = "Resource Pool(s)"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

Resource Pool(s):

\n"; $cluster_start .= "\n"; $cluster_start .= "\n"; $cluster_start .= $resource_pool_string; $cluster_start .= "
POOL NAMESTATUS# of VM(s)CPU SHARESCPU UNITS PER/VMMEM SHARESMEM UNITS PER/VMCPU LIMITCPU RESERVATIONMEM LIMITMEM RESERVATIONCPU USAGECPU MAXMEM USAGEMEM MAX
\n"; } } ########################### # VAPPS ########################### if($CLUSTER_VAPP eq "yes") { if($vapp_string ne "") { $hostTag = "vApp(s)-$cluster_name"; $hostTagShort = "vApp(s)"; push @cluster_jump_tags,"            $hostTagShort
\n"; $cluster_start .= "\n"; $cluster_start .= "

vApp(s):

\n"; $cluster_start .= "\n"; $cluster_start .= $vapp_string; $cluster_start .= "
\n"; } } #search datastore for delta files if($VM_DELTA eq "yes") { my $datastores = Vim::get_views(mo_ref_array => $local_cluster->datastore); foreach my $datastore (@$datastores) { my $dsbrowser = Vim::get_view(mo_ref => $datastore->browser); my $ds_path = "[" . $datastore->info->name . "]"; my $file_query = FileQueryFlags->new(fileOwner => 0, fileSize => 1,fileType => 0,modification => 1); my $searchSpec = HostDatastoreBrowserSearchSpec->new(details => $file_query,matchPattern => ["*.vmsn", "*-delta.vmdk"]); my $search_res = $dsbrowser->SearchDatastoreSubFolders(datastorePath => $ds_path,searchSpec => $searchSpec); if ($search_res) { foreach my $result (@$search_res) { my $files = $result->file; if($files) { foreach my $file (@$files) { if($file->path =~ /-delta.vmdk/ ) { my ($vm_snapshot_date,$vm_snapshot_time) = split('T',$file->modification); my $todays_date = giveMeDate('YMD'); chomp($todays_date); my $diff = days_between($vm_snapshot_date, $todays_date); my $snap_time = $vm_snapshot_date." ".$vm_snapshot_time; my $size = &prettyPrintData($file->fileSize,'B'); my $snap_color_string = ""; $snap_color_string = "".$result->folderPath."".$file->path.""; if($diff > $SNAPSHOT_YELLOW_WARN) { if($diff > $SNAPSHOT_RED_WARN) { $snap_color_string .= "".$diff." days old"; }elsif($diff > $SNAPSHOT_ORANGE_WARN) { $snap_color_string .= "".$diff." days old"; }elsif($diff > $SNAPSHOT_YELLOW_WARN) { $snap_color_string .= "".$diff." days old"; } $snap_color_string .= "".$size."".$snap_time.""; push @vmdeltas,$snap_color_string; } } } } } } } } print REPORT_OUTPUT "
".$cluster_start; } sub printDatacenterSummary { my ($local_datacenter,$dc_count,$atype,$aversion) = @_; my $datacenter_name = $local_datacenter->name; push @datastore_cluster_jump_tags,"CLDatacenter: $datacenter_name
\n"; my $datacenter_start .= "\n"; $datacenter_start .= "

Datacenter: $datacenter_name

\n"; my ($hostTag,$hostTagShort) = ("",""); my ($storagePods,$dvs); if($DATASTORE_CLUSTER_SUMMARY eq "yes" || $DATASTORE_CLUSTER_POD_CONFIG eq "yes" || $DATASTORE_CLUSTER_POD_ADV_CONFIG eq "yes" || $DATASTORE_CLUSTER_POD_STORAGE eq "yes") { $storagePods = Vim::find_entity_views(view_type => 'StoragePod', begin_entity => $local_datacenter); } if($DVS_SUMMARY eq "yes" || $DVS_CAPABILITY eq "yes" || $DVS_CONFIG eq "yes") { $dvs = Vim::find_entity_views(view_type => 'DistributedVirtualSwitch', begin_entity => $local_datacenter); } ############### # POD SUMMARY ############### if($DATASTORE_CLUSTER_SUMMARY eq "yes" && @$storagePods gt 0) { $hostTag = "Datastore Cluster Summary-$datacenter_name"; $hostTagShort = "Datastore Cluster Summary"; push @datastore_cluster_jump_tags,"            $hostTagShort
\n"; $datacenter_start .= "\n"; $datacenter_start .= "

Datastore Cluster Summary:

\n"; $datacenter_start .= "\n"; $datacenter_start .= "\n"; foreach my $pod (@$storagePods) { if(defined($pod->summary)) { my @podDatastores = (); my ($podDSCount,$podVMCount) = (0,0); foreach my $ds ( @{$pod->childEntity} ) { my $child_view = Vim::get_view(mo_ref => $ds); if($child_view->isa("Datastore")) { push @podDatastores, $child_view; my $vmsperds = Vim::get_views(mo_ref_array => $child_view->vm, properties => ['name']); $podVMCount += @$vmsperds; $podDSCount++; } } # find the largest datastore my $largestDatastoreSize = 0; my $largestDatastoreName = ""; foreach(@podDatastores) { if($_->summary->freeSpace gt $largestDatastoreSize) { $largestDatastoreSize = $_->summary->freeSpace; $largestDatastoreName = $_->name; } } $datacenter_start .= "\n"; } } $datacenter_start .= "
STORAGE POD NAMENUMBER OF DATASTORESNUMBER OF VMSCAPACITYFREE SPACELARGEST DATASTORE FREE SPACE
" . $pod->name . "" . $podDSCount . "" . $podVMCount . "" . &prettyPrintData($pod->summary->capacity,'B') . "" . &prettyPrintData($pod->summary->freeSpace,'B') . "" . &prettyPrintData($largestDatastoreSize,'B') . " (" . $largestDatastoreName . ")
\n"; } ############### # POD CONFIG ############### if($DATASTORE_CLUSTER_POD_CONFIG eq "yes" && @$storagePods gt 0) { $hostTag = "Datastore Cluster Pod Config-$datacenter_name"; $hostTagShort = "Datastore Cluster Pod Config"; push @datastore_cluster_jump_tags,"            $hostTagShort
\n"; $datacenter_start .= "\n"; $datacenter_start .= "

Datastore Cluster Pod Config:

\n"; $datacenter_start .= "\n"; $datacenter_start .= "\n"; foreach my $pod (@$storagePods) { if(defined($pod->podStorageDrsEntry)) { my ($ioLatThres,$ioLBThres,$ioLBInt,$minSpaceUtiDiff,$spaceUtilDiff,$defIntraVMAff) = ("N/A","N/A","N/A","N/A","N/A","N/A"); my $podConfig = $pod->podStorageDrsEntry->storageDrsConfig->podConfig; if(defined($podConfig->ioLoadBalanceConfig)) { if($podConfig->ioLoadBalanceConfig->ioLatencyThreshold) { $ioLatThres = $podConfig->ioLoadBalanceConfig->ioLatencyThreshold; } if($podConfig->ioLoadBalanceConfig->ioLoadImbalanceThreshold) { $ioLBThres = $podConfig->ioLoadBalanceConfig->ioLoadImbalanceThreshold; } } if($podConfig->loadBalanceInterval) { my $ioLBIntInMin = $podConfig->loadBalanceInterval; $ioLBInt = ($ioLBIntInMin / 60); } if(defined($podConfig->spaceLoadBalanceConfig)) { if($podConfig->spaceLoadBalanceConfig->minSpaceUtilizationDifference) { $minSpaceUtiDiff = $podConfig->spaceLoadBalanceConfig->minSpaceUtilizationDifference; } if($podConfig->spaceLoadBalanceConfig->spaceUtilizationThreshold) { $spaceUtilDiff = $podConfig->spaceLoadBalanceConfig->spaceUtilizationThreshold; } } if($podConfig->defaultIntraVmAffinity) { $defIntraVMAff = (($podConfig->defaultIntraVmAffinity) ? "YES" : "NO"); } $datacenter_start .= ""; } } $datacenter_start .= "
STORAGE POD NAMESDRS ENABLEDIO BALANCE ENABLEDIO BALANCE LATENCY THRESHOLDIO LOAD BALANCE THRESHOLDIO BALANCE INTERVALLOAD BALANCE SPACE UTILIZATION DIFFERENCESPACE UTILIZATION THRESHOLDENABLE INTRA-VM AFFINITYDEFAULT VM BEHAVIOR
".$pod->name."".(($podConfig->enabled) ? "YES" : "NO")."".(($podConfig->ioLoadBalanceEnabled) ? "YES" : "NO")."".$ioLatThres."ms".$ioLBThres."".$ioLBInt."hr".$minSpaceUtiDiff."%".$spaceUtilDiff."%".$defIntraVMAff."".$podConfig->defaultVmBehavior."
\n"; } ################## # POD ADV OPTIONS ################## if($DATASTORE_CLUSTER_POD_ADV_CONFIG eq "yes" && @$storagePods gt 0) { $hostTag = "Datastore Cluster Pod Advanced Configurations-$datacenter_name"; $hostTagShort = "Datastore Cluster Pod Advanced Configurations"; push @datastore_cluster_jump_tags,"            $hostTagShort
\n"; $datacenter_start .= "\n"; $datacenter_start .= "

Datastore Cluster Pod Advanced Configurations:

\n"; $datacenter_start .= "\n"; $datacenter_start .= "\n"; foreach my $pod (@$storagePods) { if(defined($pod->podStorageDrsEntry)) { my $podConfig = $pod->podStorageDrsEntry->storageDrsConfig->podConfig; if($podConfig->option) { my $podrules_string = ""; my $podRules = $podConfig->option; foreach(@$podRules) { my $podkey = defined($_->key) ? $_->key : "N/A"; my $podval = defined($_->value) ? $_->value : "N/A"; $podrules_string .= $podkey . " = " . $podval . "
"; } $datacenter_start .= "\n"; } } } $datacenter_start .= "
STORAGE POD NAMEADVANCED CONFIGURATIONS
" . $pod->name . "" . $podrules_string . "
\n"; } ################## # POD STORAGE ################## if($DATASTORE_CLUSTER_POD_STORAGE eq "yes" && @$storagePods gt 0) { $hostTag = "Datastore Cluster Pod Storage-$datacenter_name"; $hostTagShort = "Datastore Cluster Pod Storage"; push @datastore_cluster_jump_tags,"            $hostTagShort
\n"; $datacenter_start .= "\n"; $datacenter_start .= "

Datastore Cluster Pod Storage:

\n"; $datacenter_start .= "\n"; $datacenter_start .= "\n"; foreach my $pod (@$storagePods) { if(defined($pod->summary)) { my @podDatastores = (); my $podDSCount = 0; foreach my $ds ( @{$pod->childEntity} ) { my $child_view = Vim::get_view(mo_ref => $ds, properties => ['name','summary.maintenanceMode']); if($child_view->isa("Datastore")) { push @podDatastores, $child_view; } } my ($podDSString,$podDSMMString) = ("",""); foreach(@podDatastores) { $podDSString .= $_->{'name'} . "
"; $podDSMMString .= $_->{'summary.maintenanceMode'} . "
"; } $datacenter_start .= "\n"; } } $datacenter_start .= "
STORAGE POD NAMEDATASTORESMAINTENANCE MODE
" . $pod->name . "" . $podDSString . "" . $podDSMMString . "
\n"; } ############## # DVS SUMMARY ############## if($DVS_SUMMARY eq "yes" && @$dvs gt 0) { $hostTag = "DVS Summary-$datacenter_name"; $hostTagShort = "DVS Summary"; push @datastore_cluster_jump_tags,"            $hostTagShort
\n"; $datacenter_start .= "\n"; $datacenter_start .= "

DVS Summary:

\n"; $datacenter_start .= "\n"; $datacenter_start .= "\n"; foreach my $dvSwitch (@$dvs) { $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= "\n"; } $datacenter_start .= "
DVS NAME# OF PORTSVENDORVERSIONBUILDUUID
".$dvSwitch->summary->name."".$dvSwitch->summary->numPorts."".($dvSwitch->summary->productInfo->vendor ? $dvSwitch->summary->productInfo->vendor : "N/A")."".($dvSwitch->summary->productInfo->version ? $dvSwitch->summary->productInfo->version : "N/A")."".($dvSwitch->summary->productInfo->build ? $dvSwitch->summary->productInfo->build : "N/A")."".$dvSwitch->summary->uuid."
\n"; } ################# # DVS CAPABILITY ################# if($DVS_CAPABILITY && @$dvs gt 0) { $hostTag = "DVS Capability-$datacenter_name"; $hostTagShort = "DVS Capability"; push @datastore_cluster_jump_tags,"            $hostTagShort
\n"; $datacenter_start .= "\n"; $datacenter_start .= "

DVS Capability:

\n"; $datacenter_start .= "\n"; $datacenter_start .= ""; my ($niocSup,$qosSup,$defNetRscPoolSup,$netRscPoolShareVal,$dp2Sup,$nicTeam) = ("N/A","N/A","N/A","N/A","N/A","N/A",); foreach my $dvSwitch (@$dvs) { if($dvSwitch->capability->featuresSupported) { my $dvFeatures = $dvSwitch->capability->featuresSupported; $niocSup = $dvFeatures->networkResourceManagementCapability->networkResourceManagementSupported ? "YES" : "NO"; $qosSup = $dvFeatures->networkResourceManagementCapability->qosSupported ? "YES" : "NO"; $defNetRscPoolSup = $dvFeatures->networkResourceManagementCapability->userDefinedNetworkResourcePoolsSupported ? "YES" : "NO"; $netRscPoolShareVal = $dvFeatures->networkResourceManagementCapability->networkResourcePoolHighShareValue ? $dvFeatures->networkResourceManagementCapability->networkResourcePoolHighShareValue : "N/A"; $dp2Sup = $dvFeatures->vmDirectPathGen2Supported ? "YES" : "NO"; $nicTeam = $dvFeatures->nicTeamingPolicy ? join('
',@{$dvFeatures->nicTeamingPolicy}) : "N/A"; } $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= "\n"; } $datacenter_start .= "
DVS NAMENIOC SUPPORTQOS SUPPORTDIRECT PATH GEN2 SUPPORTDEFINE NETWORK RSC POOLS SUPPORTNETWORK RSC POOL HIGH SHARE VALNIC TEAMING POLICY
".$dvSwitch->summary->name."".$niocSup."".$qosSup."".$dp2Sup."".$defNetRscPoolSup."".$netRscPoolShareVal."".$nicTeam."
\n"; } ############## # DVS CONFIG ############## if($DVS_CONFIG eq "yes" && @$dvs gt 0) { $hostTag = "DVS Config-$datacenter_name"; $hostTagShort = "DVS Config"; push @datastore_cluster_jump_tags,"            $hostTagShort
\n"; $datacenter_start .= "\n"; $datacenter_start .= "

DVS Config:

\n"; $datacenter_start .= "\n"; $datacenter_start .= "\n"; foreach my $dvSwitch (@$dvs) { my ($mtu,$ldpOp,$ldpPro,$activeFlowTimeout,$idleFlowTimeout,$intFlowOnly,$sampleRate) = ("N/A","N/A","N/A","N/A","N/A","N/A"); if($dvSwitch->config->isa('VMwareDVSConfigInfo')) { $mtu = $dvSwitch->config->maxMtu; $ldpOp = $dvSwitch->config->linkDiscoveryProtocolConfig->operation ? $dvSwitch->config->linkDiscoveryProtocolConfig->operation : "N/A"; $ldpPro = $dvSwitch->config->linkDiscoveryProtocolConfig->protocol ? $dvSwitch->config->linkDiscoveryProtocolConfig->protocol : "N/A"; $activeFlowTimeout = $dvSwitch->config->ipfixConfig->activeFlowTimeout ? $dvSwitch->config->ipfixConfig->activeFlowTimeout : "N/A"; $idleFlowTimeout = $dvSwitch->config->ipfixConfig->idleFlowTimeout ? $dvSwitch->config->ipfixConfig->idleFlowTimeout : "N/A"; $intFlowOnly = $dvSwitch->config->ipfixConfig->internalFlowsOnly ? "YES" : "NO"; $sampleRate = $dvSwitch->config->ipfixConfig->samplingRate ? $dvSwitch->config->ipfixConfig->samplingRate : "N/A"; } $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= ""; $datacenter_start .= "\n"; } $datacenter_start .= "
DVS NAMESWITCH ADDRESSMAX PORTSSTANDALONE PORTSMTUNIOC ENABLEDLDP OPERATIONLDP PROTOCOLACTIVE FLOW TIMEOUTIDLE FLOW TIMEOUTINTERNAL FLOW ONLYSAMPLE RATEEXT KEYCONFIG VERSIONDESCRIPTIONCREATE TIME
".$dvSwitch->summary->name."".($dvSwitch->config->switchIpAddress ? $dvSwitch->config->switchIpAddress : "N/A")."".$dvSwitch->config->maxPorts."".$dvSwitch->config->numStandalonePorts."".$mtu."".($dvSwitch->config->networkResourceManagementEnabled ? "YES" : "NO")."".$ldpOp."".$ldpPro."".$activeFlowTimeout." sec".$idleFlowTimeout." sec".$intFlowOnly."".$sampleRate."".($dvSwitch->config->extensionKey ? $dvSwitch->config->extensionKey : "N/A")."".$dvSwitch->config->configVersion."".($dvSwitch->config->description ? $dvSwitch->config->description : "N/A")."".$dvSwitch->config->createTime."
\n"; } print REPORT_OUTPUT "
".$datacenter_start; } sub processOptions { my ($type,$hostType,$conf) = @_; if(defined($conf)) { &processConf($conf); &setConf(); } if($type eq 'host' && $hostType eq 'HostAgent') { $host_view = Vim::find_entity_views(view_type => 'HostSystem'); unless($host_view) { Util::disconnect(); die "ESX/ESXi host was not found\n"; } }elsif($type eq 'cluster' && $hostType eq 'VirtualCenter') { $cluster_view = Vim::find_entity_view(view_type => 'ClusterComputeResource',filter => { name => $clusterInput }); unless($cluster_view) { Util::disconnect(); die "Error: Unable to find Cluster: \"$clusterInput\"!\n"; exit 1; } }elsif($type eq 'datacenter' && $hostType eq 'VirtualCenter') { $datacenter_view = Vim::find_entity_view(view_type => 'Datacenter',filter => { name => $datacenterInput}); unless($datacenter_view) { Util::disconnect(); die "Error: Unable to find Datacenter: \"$datacenterInput\"!\n"; exit 1; } my $CCR = Vim::find_entity_views(view_type => 'ClusterComputeResource', begin_entity => $datacenter_view); my $CR = Vim::find_entity_views(view_type => 'ComputeResource', begin_entity => $datacenter_view); my @list = (@$CCR,@$CR); my %seen = (); my @unique = grep { ! $seen{$_->name} ++ } @list; $cluster_views = \@unique; }elsif($type eq 'vcenter' && $hostType eq 'VirtualCenter') { my $CCR = Vim::find_entity_views(view_type => 'ClusterComputeResource'); my $CR = Vim::find_entity_views(view_type => 'ComputeResource'); my @list = (@$CCR,@$CR); my %seen = (); my @unique = grep { ! $seen{$_->name} ++ } @list; $cluster_views = \@unique; } } sub processConf { my ($conf) = @_; my @goodparams = qw( EMAIL_HOST EMAIL_DOMAIN EMAIL_TO EMAIL_FROM YELLOW_WARN ORANGE_WARN RED_WARN SNAPSHOT_YELLOW_WARN SNAPSHOT_ORANGE_WARN SNAPSHOT_RED_WARN SYSTEM_LICENSE SYSTEM_FEATURE SYSTEM_PERMISSION SYSTEM_SESSION SYSTEM_HOST_PROFILE SYSTEM_PLUGIN DVS_SUMMARY DVS_CAPABILITY DVS_CONFIG DATASTORE_CLUSTER_SUMMARY DATASTORE_CLUSTER_POD_CONFIG CLUSTER_SUMMARY CLUSTER_PERFORMANCE CLUSTER_HA CLUSTER_DRS CLUSTER_DPM CLUSTER_AFFINITY CLUSTER_GROUP CLUSTER_RP CLUSTER_VAPP HOST_HARDWARE_CONFIGURATION HOST_MGMT HOST_STATE HOST_HEALTH HOST_PERFORMANCE HOST_NIC HOST_HBA HOST_CAPABILITY HOST_CONFIGURATION HOST_VMOTION HOST_GATEWAY HOST_ISCSI HOST_IPV6 HOST_FT HOST_SSL HOST_DNS HOST_UPTIME HOST_DIAGONISTIC HOST_AUTH_SERVICE HOST_SERVICE HOST_NTP HOST_VSWIF HOST_VMKERNEL HOST_VSWITCH HOST_SNMP HOST_FIREWALL HOST_POWER HOST_FEATURE_VERSION HOST_ADVOPT HOST_AGENT HOST_NUMA HOST_CDP HOST_LUN HOST_DATASTORE HOST_CACHE HOST_MULTIPATH HOST_PORTGROUP HOST_DVS HOST_LOG HOST_TASK VM_STATE VM_CONFIG VM_STATS VM_RESOURCE_ALLOCATION VM_PERFORMANCE VM_FT VM_EZT VM_THIN VM_DEVICE VM_STORAGE VM_NETWORK VM_SNAPSHOT VM_DELTA VM_CDROM VM_FLOPPY VM_RDM VM_NPIV VM_TOOL VPX_SETTING VMW_APP ); open(CONFIG, "$conf") || die "Error: Couldn't open the $conf!"; while () { chomp; s/#.*//; # Remove comments s/^\s+//; # Remove opening whitespace s/\s+$//; # Remove closing whitespace next unless length; my ($key, $value) = split(/\s*=\s*/, $_, 2); if( grep $key eq $_, @goodparams ) { $value =~ s/"//g; if($key eq "EMAIL_TO") { @EMAIL_TO = (); @EMAIL_TO = split(',',$value); } else { $configurations{$key} = $value; } } } close(CONFIG); } sub processAdditionalConf { if($hostlist) { &processSubFiles($hostlist); } if($vmlist) { &processSubFiles($vmlist); } } sub processSubFiles { my ($config_input) = @_; open(CONFIG, "$config_input") || die "Error: Couldn't open the $config_input!"; while () { chomp; s/#.*//; # Remove comments s/^\s+//; # Remove opening whitespace s/\s+$//; # Remove closing whitespace next unless length; if($hostlist) { $hostlists{$_} = "yes"; } if($vmlist) { $vmlists{$_} = "yes"; } } close(CONFIG); } sub setConf { $EMAIL_HOST=(($configurations{'EMAIL_HOST'}) ? $configurations{'EMAIL_HOST'} : 'emailserver'); $EMAIL_DOMAIN=(($configurations{'EMAIL_DOMAIN'}) ? $configurations{'EMAIL_DOMAIN'} : 'localhost.localdomain'); #@EMAIL_TO=(($configurations{'EMAIL_TO'}) ? $configurations{'EMAIL_TO'} : 'william@primp-industries.com.com'); $EMAIL_FROM=(($configurations{'EMAIL_FROM'}) ? $configurations{'EMAIL_FROM'} : 'vMA@primp-industries.com.com'); $YELLOW_WARN=(($configurations{'YELLOW_WARN'}) ? $configurations{'YELLOW_WARN'} : 30); $ORANGE_WARN=(($configurations{'ORANGE_WARN'}) ? $configurations{'ORANGE_WARN'} : 15); $RED_WARN=(($configurations{'RED_WARN'}) ? $configurations{'RED_WARN'} : 10); $SNAPSHOT_YELLOW_WARN=(($configurations{'SNAPSHOT_YELLOW_WARN'}) ? $configurations{'SNAPSHOT_YELLOW_WARN'} : 15); $SNAPSHOT_ORANGE_WARN=(($configurations{'SNAPSHOT_ORANGE_WARN'}) ? $configurations{'SNAPSHOT_ORANGE_WARN'} : 30); $SNAPSHOT_RED_WARN=(($configurations{'SNAPSHOT_RED_WARN'}) ? $configurations{'SNAPSHOT_RED_WARN'} : 60); $SYSTEM_LICENSE=(($configurations{'SYSTEM_LICENSE'}) ? $configurations{'SYSTEM_LICENSE'} : "yes"); $SYSTEM_FEATURE=(($configurations{'SYSTEM_FEATURE'}) ? $configurations{'SYSTEM_FEATURE'} : "yes"); $SYSTEM_PERMISSION=(($configurations{'SYSTEM_PERMISSION'}) ? $configurations{'SYSTEM_PERMISSION'} : "yes"); $SYSTEM_SESSION=(($configurations{'SYSTEM_SESSION'}) ? $configurations{'SYSTEM_SESSION'} : "yes"); $SYSTEM_HOST_PROFILE=(($configurations{'SYSTEM_HOST_PROFILE'}) ? $configurations{'SYSTEM_HOST_PROFILE'} : "yes"); $SYSTEM_PLUGIN=(($configurations{'SYSTEM_PLUGIN'}) ? $configurations{'SYSTEM_PLUGIN'} : "yes"); $DVS_SUMMARY=(($configurations{'DVS_SUMMARY'}) ? $configurations{'DVS_SUMMARY'} : "yes"); $DVS_CAPABILITY=(($configurations{'DVS_CAPABILITY'}) ? $configurations{'DVS_CAPABILITY'} : "yes"); $DVS_CONFIG=(($configurations{'DVS_CONFIG'}) ? $configurations{'DVS_CONFIG'} : "yes"); $DATASTORE_CLUSTER_SUMMARY=(($configurations{'DATASTORE_CLUSTER_SUMMARY'}) ? $configurations{'DATASTORE_CLUSTER_SUMMARY'} : "yes"); $DATASTORE_CLUSTER_POD_CONFIG=(($configurations{'DATASTORE_CLUSTER_POD_CONFIG'}) ? $configurations{'DATASTORE_CLUSTER_POD_CONFIG'} : "yes"); $DATASTORE_CLUSTER_POD_ADV_CONFIG=(($configurations{'DATASTORE_CLUSTER_POD_ADV_CONFIG'}) ? $configurations{'DATASTORE_CLUSTER_POD_ADV_CONFIG'} : "yes"); $DATASTORE_CLUSTER_POD_STORAGE=(($configurations{'DATASTORE_CLUSTER_POD_STORAGE'}) ? $configurations{'DATASTORE_CLUSTER_POD_STORAGE'} : "yes"); $CLUSTER_SUMMARY=(($configurations{'CLUSTER_SUMMARY'}) ? $configurations{'CLUSTER_SUMMARY'} : "yes"); $CLUSTER_PERFORMANCE=(($configurations{'CLUSTER_PERFORMANCE'}) ? $configurations{'CLUSTER_PERFORMANCE'} : "yes"); $CLUSTER_HA=(($configurations{'CLUSTER_HA'}) ? $configurations{'CLUSTER_HA'} : "yes"); $CLUSTER_DRS=(($configurations{'CLUSTER_DRS'}) ? $configurations{'CLUSTER_DRS'} : "yes"); $CLUSTER_DPM=(($configurations{'CLUSTER_DPM'}) ? $configurations{'CLUSTER_DPM'} : "yes"); $CLUSTER_AFFINITY=(($configurations{'CLUSTER_AFFINITY'}) ? $configurations{'CLUSTER_AFFINITY'} : "yes"); $CLUSTER_GROUP=(($configurations{'CLUSTER_GROUP'}) ? $configurations{'CLUSTER_GROUP'} : "yes"); $CLUSTER_RP=(($configurations{'CLUSTER_RP'}) ? $configurations{'CLUSTER_RP'} : "yes"); $CLUSTER_VAPP=(($configurations{'CLUSTER_VAPP'}) ? $configurations{'CLUSTER_VAPP'} : "yes"); $HOST_HARDWARE_CONFIGURATION=(($configurations{'HOST_HARDWARE_CONFIGURATION'}) ? $configurations{'HOST_HARDWARE_CONFIGURATION'} : "yes"); $HOST_MGMT=(($configurations{'HOST_MGMT'}) ? $configurations{'HOST_MGMT'} : "yes"); $HOST_STATE=(($configurations{'HOST_STATE'}) ? $configurations{'HOST_STATE'} : "yes"); $HOST_HEALTH=(($configurations{'HOST_HEALTH'}) ? $configurations{'HOST_HEALTH'} : "yes"); $HOST_PERFORMANCE=(($configurations{'HOST_PERFORMANCE'}) ? $configurations{'HOST_PERFORMANCE'} : "yes"); $HOST_NIC=(($configurations{'HOST_NIC'}) ? $configurations{'HOST_NIC'} : "yes"); $HOST_HBA=(($configurations{'HOST_HBA'} ? $configurations{'HOST_HBA'} : "yes")); $HOST_CAPABILITY=(($configurations{'HOST_CAPABILITY'} ? $configurations{'HOST_CAPABILITY'} : "yes")); $HOST_CONFIGURATION=(($configurations{'HOST_CONFIGURATION'}) ? $configurations{'HOST_CONFIGURATION'} : "yes"); $HOST_VMOTION=(($configurations{'HOST_VMOTION'}) ? $configurations{'HOST_VMOTION'} : "yes"); $HOST_GATEWAY=(($configurations{'HOST_GATEWAY'}) ? $configurations{'HOST_GATEWAY'} : "yes"); $HOST_ISCSI=(($configurations{'HOST_ISCSI'}) ? $configurations{'HOST_ISCSI'} : "yes"); $HOST_IPV6=(($configurations{'HOST_IPV6'}) ? $configurations{'HOST_IPV6'} : "yes"); $HOST_FT=(($configurations{'HOST_FT'}) ? $configurations{'HOST_FT'} : "yes"); $HOST_SSL=(($configurations{'HOST_SSL'}) ? $configurations{'HOST_SSL'} : "yes"); $HOST_DNS=(($configurations{'HOST_DNS'}) ? $configurations{'HOST_DNS'} : "yes"); $HOST_UPTIME=(($configurations{'HOST_UPTIME'}) ? $configurations{'HOST_UPTIME'} : "yes"); $HOST_DIAGONISTIC=(($configurations{'HOST_DIAGONISTIC'}) ? $configurations{'HOST_DIAGONISTIC'} : "yes"); $HOST_AUTH_SERVICE=(($configurations{'HOST_AUTH_SERVICE'}) ? $configurations{'HOST_AUTH_SERVICE'} : "yes"); $HOST_SERVICE=(($configurations{'HOST_SERVICE'}) ? $configurations{'HOST_SERVICE'} : "yes"); $HOST_NTP=(($configurations{'HOST_NTP'}) ? $configurations{'HOST_NTP'} : "yes"); $HOST_VSWIF=(($configurations{'HOST_VSWIF'}) ? $configurations{'HOST_VSWIF'} : "yes"); $HOST_VMKERNEL=(($configurations{'HOST_VMKERNEL'}) ? $configurations{'HOST_VMKERNEL'} : "yes"); $HOST_VSWITCH=(($configurations{'HOST_VSWITCH'}) ? $configurations{'HOST_VSWITCH'} : "yes"); $HOST_SNMP=(($configurations{'HOST_SNMP'}) ? $configurations{'HOST_SNMP'} : "yes"); $HOST_FIREWALL=(($configurations{'HOST_FIREWALL'}) ? $configurations{'HOST_FIREWALL'} : "yes"); $HOST_POWER=(($configurations{'HOST_POWER'}) ? $configurations{'HOST_POWER'} : "yes"); $HOST_FEATURE_VERSION=(($configurations{'HOST_FEATURE_VERSION'}) ? $configurations{'HOST_FEATURE_VERSION'} : "yes"); $HOST_ADVOPT=(($configurations{'HOST_ADVOPT'}) ? $configurations{'HOST_ADVOPT'} : "yes"); $HOST_AGENT=(($configurations{'HOST_AGENT'}) ? $configurations{'HOST_AGENT'} : "yes"); $HOST_NUMA=(($configurations{'HOST_NUMA'}) ? $configurations{'HOST_NUMA'} : "yes"); $HOST_CDP=(($configurations{'HOST_CDP'}) ? $configurations{'HOST_CDP'} : "yes"); $HOST_LUN=(($configurations{'HOST_LUN'}) ? $configurations{'HOST_LUN'} : "yes"); $HOST_DATASTORE=(($configurations{'HOST_DATASTORE'}) ? $configurations{'HOST_DATASTORE'} : "yes"); $HOST_CACHE=(($configurations{'HOST_CACHE'}) ? $configurations{'HOST_CACHE'} : "yes"); $HOST_MULTIPATH=(($configurations{'HOST_MULTIPATH'}) ? $configurations{'HOST_MULTIPATH'} : "yes"); $HOST_PORTGROUP=(($configurations{'HOST_PORTGROUP'}) ? $configurations{'HOST_PORTGROUP'} : "yes"); $HOST_DVS=(($configurations{'HOST_DVS'}) ? $configurations{'HOST_DVS'} : "yes"); $HOST_LOG=(($configurations{'HOST_LOG'}) ? $configurations{'HOST_LOG'} : "yes"); $HOST_TASK=(($configurations{'HOST_TASK'}) ? $configurations{'HOST_TASK'} : "yes"); $VM_STATE=(($configurations{'VM_STATE'}) ? $configurations{'VM_STATE'} : "yes"); $VM_CONFIG=(($configurations{'VM_CONFIG'}) ? $configurations{'VM_CONFIG'} : "yes"); $VM_STATS=(($configurations{'VM_STATS'}) ? $configurations{'VM_STATS'} : "yes"); $VM_RESOURCE_ALLOCATION=(($configurations{'VM_RESOURCE_ALLOCATION'}) ? $configurations{'VM_RESOURCE_ALLOCATION'} : "yes"); $VM_PERFORMANCE=(($configurations{'VM_PERFORMANCE'}) ? $configurations{'VM_PERFORMANCE'} : "yes"); $VM_FT=(($configurations{'VM_FT'}) ? $configurations{'VM_FT'} : "yes"); $VM_EZT=(($configurations{'VM_EZT'}) ? $configurations{'VM_EZT'} : "yes"); $VM_THIN=(($configurations{'VM_THIN'}) ? $configurations{'VM_THIN'} : "yes"); $VM_DEVICE=(($configurations{'VM_DEVICE'}) ? $configurations{'VM_DEVICE'} : "yes"); $VM_STORAGE=(($configurations{'VM_STORAGE'}) ? $configurations{'VM_STORAGE'} : "yes"); $VM_NETWORK=(($configurations{'VM_NETWORK'}) ? $configurations{'VM_NETWORK'} : "yes"); $VM_SNAPSHOT=(($configurations{'VM_SNAPSHOT'}) ? $configurations{'VM_SNAPSHOT'} : "yes"); $VM_DELTA=(($configurations{'VM_DELTA'}) ? $configurations{'VM_DELTA'} : "yes"); $VM_CDROM=(($configurations{'VM_CDROM'}) ? $configurations{'VM_CDROM'} : "yes"); $VM_FLOPPY=(($configurations{'VM_FLOPPY'}) ? $configurations{'VM_FLOPPY'} : "yes"); $VM_RDM=(($configurations{'VM_RDM'}) ? $configurations{'VM_RDM'} : "yes"); $VM_NPIV=(($configurations{'VM_NPIV'}) ? $configurations{'VM_NPIV'} : "yes"); $VM_TOOL=(($configurations{'VM_TOOL'}) ? $configurations{'VM_TOOL'} : "yes"); $VMW_APP=(($configurations{'VMW_APP'}) ? $configurations{'VMW_APP'} : "yes"); $VPX_SETTING=(($configurations{'VPX_SETTING'}) ? $configurations{'VPX_SETTING'} : "yes"); } sub getCpuAndMemPerf { my ($entity_view) = @_; my $returnString = ""; my @metrics; my %metricResults = (); if($entity_view->isa('ClusterComputeResource')) { @metrics = qw(cpu.usage.average cpu.usagemhz.average mem.consumed.average mem.active.average); }elsif($entity_view->isa('HostSystem')) { @metrics = qw(cpu.usage.average cpu.usagemhz.average mem.usage.average mem.active.average); }elsif($entity_view->isa('VirtualMachine')) { @metrics = qw(cpu.usage.average cpu.usagemhz.average mem.usage.average mem.active.average cpu.ready.summation cpu.vmmemctl.average); } my $entity_name = $entity_view->name; #get performance manager my $perfMgr = Vim::get_view(mo_ref => $service_content->perfManager); #get performance counters my $perfCounterInfo = $perfMgr->perfCounter; #grab all counter defs my %allCounterDefintions = (); foreach(@$perfCounterInfo) { $allCounterDefintions{$_->key} = $_; } my @metricIDs = (); #get available metrics from entity my $availmetricid = $perfMgr->QueryAvailablePerfMetric(entity => $entity_view); foreach(sort {$a->counterId cmp $b->counterId} @$availmetricid) { if($allCounterDefintions{$_->counterId}) { my $metric = $allCounterDefintions{$_->counterId}; my $groupInfo = $metric->groupInfo->key; my $nameInfo = $metric->nameInfo->key; my $instance = $_->instance; my $key = $metric->key; my $rolluptype = $metric->rollupType->val; my $statstype = $metric->statsType->val; my $unitInfo = $metric->unitInfo->key; #e.g. cpu.usage.average my $vmwInternalName = $groupInfo . "." . $nameInfo . "." . $rolluptype; foreach(@metrics) { if($_ eq $vmwInternalName) { #print $groupInfo . "\t" . $nameInfo . "\t" . $rolluptype . "\t" . $statstype . "\t" . $unitInfo . "\n"; my $metricId = PerfMetricId->new(counterId => $key, instance => '*'); if(! grep(/^$key/,@metricIDs)) { push @metricIDs,$metricId; } } } } } my $intervalIds = &get_available_intervals(perfmgr_view => $perfMgr, entity => $entity_view); my $perfQuerySpec = PerfQuerySpec->new(entity => $entity_view, maxSample => 10, intervalId => shift(@$intervalIds), metricId => \@metricIDs); my $metrics; eval { $metrics = $perfMgr->QueryPerf(querySpec => [$perfQuerySpec]); }; if(!$@) { my %uniqueInstances = (); foreach(@$metrics) { my $perfValues = $_->value; foreach(@$perfValues) { my $object = $_->id->instance ? $_->id->instance : "TOTAL"; #if($object eq "TOTAL") { my ($numOfCounters,$sumOfCounters,$res) = (0,0,0); my $values = $_->value; my $metricRef = $allCounterDefintions{$_->id->counterId}; my $unitString = $metricRef->unitInfo->label; my $unitInfo = $metricRef->unitInfo->key; my $groupInfo = $metricRef->groupInfo->key; my $nameInfo = $metricRef->nameInfo->key; my $rollupType = $metricRef->rollupType->val; my $factor = 1; if($unitInfo eq 'percent') { $factor = 100; } foreach(@$values) { #if($rollupType eq 'average') { $res = &average($_)/$factor; $res = &restrict_num_decimal_digits($res,3); #} } my $internalID = $groupInfo . "." . $nameInfo . "." . $rollupType; $metricResults{$internalID} = $res . "\t" . $unitString . "\n"; #} } } } my ($cpuAvg,$cpuAvgPer,$memAvg,$memAvgPer,$ballonAvg,$readyAvg) = (0,0,0,0,0,0); for my $key ( sort keys %metricResults ) { if($key eq 'cpu.usage.average') { $cpuAvgPer = $metricResults{$key}; }elsif($key eq 'cpu.usagemhz.average') { $cpuAvg = $metricResults{$key}; }elsif($key eq 'mem.usage.average' || $key eq 'mem.consumed.average') { if($entity_view->isa('ClusterComputeResource') && $key eq 'mem.consumed.average') { $memAvgPer = $metricResults{$key}; }elsif(!$entity_view->isa('ClusterComputeResource') && $key eq 'mem.usage.average'){ $memAvgPer = $metricResults{$key}; } }elsif($key eq 'mem.active.average') { $memAvg = $metricResults{$key}; }elsif($key eq 'cpu.ready.summation') { $readyAvg = $metricResults{$key}; }elsif($key eq 'cpu.vmmemctl.average') { $ballonAvg = $metricResults{$key}; } } my ($perfString,$hostTag,$hostTagShort) = ("","",""); if($entity_view->isa('ClusterComputeResource')) { $perfString .= "

Cluster Performance

\n"; $perfString .= "\n"; $perfString .= "\n"; $perfString .= "\n"; $perfString .= "\n"; $perfString .= "\n"; $perfString .= "\n"; $perfString .= "
cpu.usagemhz.averagecpu.usage.averagemem.active.averagemem.consumed.average
" . $cpuAvg . "" . $cpuAvgPer . "" . $memAvg . "" . $memAvgPer . "
\n"; } elsif($entity_view->isa('HostSystem')) { my $hostsystem_name = $entity_view->name; if($demo eq "yes") { $hostsystem_name = $host_name; } $perfString .= "" . $hostsystem_name . "" . $cpuAvg . "" . $cpuAvgPer . "" . $memAvg . "" . $memAvgPer . "\n"; } else { $perfString .= "" . $entity_view->name . "" . $cpuAvg . "" . $cpuAvgPer . "" . $readyAvg . "" . $memAvg . "" . $memAvgPer . "" . $ballonAvg . "\n"; } return $perfString; } #VMware's viperformance.pl function sub get_available_intervals { my %args = @_; my $perfmgr_view = $args{perfmgr_view}; my $entity = $args{entity}; my $historical_intervals = $perfmgr_view->historicalInterval; my $provider_summary = $perfmgr_view->QueryPerfProviderSummary(entity => $entity); my @intervals; if ($provider_summary->refreshRate) { if($provider_summary->refreshRate != -1) { push @intervals, $provider_summary->refreshRate; } } foreach (@$historical_intervals) { if($_->samplingPeriod != -1) { push @intervals, $_->samplingPeriod; } } return \@intervals; } sub average { my @arr = @_; my $n = 0; my $avg = 0; foreach(@arr) { $avg += $_; $n += 1; } return $avg ? $avg/$n : 0; } sub FindPortGroupbyKey { my ($network, $vSwitch, $key) = @_; my $portGroups = $network->networkInfo->portgroup; foreach my $pg (@$portGroups) { return $pg if (($pg->vswitch eq $vSwitch) && ($key eq $pg->key)); } return undef; } sub find_by_key { my ($list, $key) = @_; foreach my $item (@$list) { if ($key eq $item->key) { return $item; } } return undef; } sub get_pci_string { my $hba = shift; my $pciString = defined($hba) ? $hba->pci : ""; # defect 173631 if ($pciString =~ /([a-fA-F0-9]+):([a-fA-F0-9]+)\.([a-fA-F0-9]+)$/) { $pciString = hexstr_to_int($1) . ":" . hexstr_to_int($2) . "." . hexstr_to_int($3); } return $pciString } sub hexstr_to_int { my ($hexstr) = @_; die "Invalid hex string: $hexstr" if $hexstr !~ /^[0-9A-Fa-f]{1,8}$/; my $num = hex($hexstr); return $num >> 31 ? $num - 2 ** 32 : $num; } sub getSnapshotTree { my ($host,$vm,$ref,$tree) = @_; my $head = " "; foreach my $node (@$tree) { $head = ($ref->value eq $node->snapshot->value) ? " " : " " if (defined $ref); my $quiesced = ($node->quiesced) ? "YES" : "NO"; my $desc = $node->description; if($desc eq "" ) { $desc = "NO DESCRIPTION"; } push @vmsnapshots,"".$host."".$vm."".$node->name."".$desc."".$node->createTime."".$node->state->val."".$quiesced.""; &getSnapshotTree($host, $vm, $ref, $node->childSnapshotList); } return; } sub startReport { print "Generating VMware vSphere Health Report v$version \"$report\" ...\n\n"; print "This can take a few minutes depending on the size of your environment. \nGet a cup of coffee/tea/beer and check out http://www.virtuallyghetto.com\n\n"; if($demo eq "yes") { $host_name = "DEMO-HOST.primp-industries.com"; } $start_time = time(); open(REPORT_OUTPUT, ">$report"); $my_time = "Date: ".giveMeDate('MDYHMS'); my $html_start = < VMware vSphere Health Check Report v$version - $my_time ($system_name) HTML_START print REPORT_OUTPUT $html_start; } sub endReport { my $html_end = <William Lam

http://www.virtuallyghetto.com
Generated using: vmwarevSphereHealthCheck.pl
Support us by donating here
Primp Industries™ HTML_END print REPORT_OUTPUT $html_end; close(REPORT_OUTPUT); my @lines; my ($datastore_cluster_jump_string,$cluster_jump_string,$host_jump_string,$vm_jump_string) = ("","","",""); tie @lines, 'Tie::File', $report or die; for(@lines) { if (//) { foreach (@cluster_jump_tags) { if( ($_ =~ /^CL/) ) { my $tmp_cluster_string = substr($_,2); $cluster_jump_string .= $tmp_cluster_string; } else { $cluster_jump_string .= $_; } } $_ = "\n$cluster_jump_string"; last; } } for(@lines) { if (//) { foreach (@datastore_cluster_jump_tags) { if( ($_ =~ /^CL/) ) { my $tmp_datastore_cluster_string = substr($_,2); $datastore_cluster_jump_string .= $tmp_datastore_cluster_string; } else { $datastore_cluster_jump_string .= $_; } } $_ = "\n$datastore_cluster_jump_string"; last; } } for(@lines) { if (//) { foreach (@host_jump_tags) { if( ($_ =~ /^CL/) ) { my $tmp_host_string = substr($_,2); $host_jump_string .= $tmp_host_string; } else { $host_jump_string .= $_; } } $_ = "\n$host_jump_string"; last; } } for(@lines) { if (//) { foreach (@vm_jump_tags) { if( ($_ =~ /^CL/) ) { my $tmp_host_string = substr($_,2); $vm_jump_string .= $tmp_host_string; } else { $vm_jump_string .= $_; } } $_ = "\n$vm_jump_string"; last; } } untie @lines; my $end_time = time(); my $run_time = $end_time - $start_time; print "\nStart Time: ",&formatTime(str => scalar localtime($start_time)),"\n"; print "End Time: ",&formatTime(str => scalar localtime($end_time)),"\n"; if ($run_time < 60) { print "Duration : ",$run_time," Seconds\n\n"; } else { print "Duration : ",&restrict_num_decimal_digits($run_time/60,2)," Minutes\n\n"; } } sub startBody { my ($type,$aversion) = @_; my $body_start = <

VMware vSphere Health Check Report v$version

BODY_START print REPORT_OUTPUT $body_start; } sub endBody { my $body_end = <
BODY_END print REPORT_OUTPUT $body_end; } sub validateSystem { my ($ver) = @_; if(!grep(/$ver/,@supportedVersion)) { Util::disconnect(); print "Error: This script only supports vSphere \"@supportedVersion\" or greater!\n\n"; exit 1; } } # restrict the number of digits after the decimal point #http://guymal.com/mycode/perl_restrict_digits.shtml sub restrict_num_decimal_digits { my $num=shift;#the number to work on my $digs_to_cut=shift;# the number of digits after if ($num=~/\d+\.(\d){$digs_to_cut,}/) { $num=sprintf("%.".($digs_to_cut-1)."f", $num); } return $num; } #http://www.infocopter.com/perl/format-time.html sub formatTime(%) { my %args = @_; $args{'str'} ||= ''; # e.g. Mon Jul 3 12:59:28 2006 my @elems = (); foreach (split / /, $args{'str'}) { next unless $_; push(@elems, $_); } my ($weekday, $month, $mday, $time, $yyyy) = split / /, join(' ', @elems); my %months = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5, Jun => 6, Jul => 7, Aug => 8, Sep => 9, Oct => 10, Nov => 11, Dec => 12 ); my $s = substr($time, 6,2); my $m = substr($time, 3,2); my $h = substr($time, 0, 2); my $dd = sprintf('%02d', $mday); my $mm_num = sprintf('%02d', $months{$month}); my $formatted = "$mm_num\-$dd\-$yyyy $h:$m:$s"; #my $formatted = "$yyyy$mm_num$dd$h$m$s"; $formatted; } #http://www.bryantmcgill.com/Shazam_Perl_Module/Subroutines/utils_convert_bytes_to_optimal_unit.html sub prettyPrintData{ my($bytes,$type) = @_; return '' if ($bytes eq '' || $type eq ''); return 0 if ($bytes <= 0); my($size); if($type eq 'B') { $size = $bytes . ' Bytes' if ($bytes < 1024); $size = sprintf("%.2f", ($bytes/1024)) . ' KB' if ($bytes >= 1024 && $bytes < 1048576); $size = sprintf("%.2f", ($bytes/1048576)) . ' MB' if ($bytes >= 1048576 && $bytes < 1073741824); $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776); $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776); } elsif($type eq 'K') { $bytes = $bytes * (1024); $size = sprintf("%.2f", ($bytes/1048576)) . ' MB' if ($bytes >= 1048576 && $bytes < 1073741824); $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776); $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776); } elsif($type eq 'M') { $bytes = $bytes * (1048576); $size = sprintf("%.2f", ($bytes/1048576)) . ' MB' if ($bytes >= 1048576 && $bytes < 1073741824); $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776); $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776); } elsif($type eq 'G') { $bytes = $bytes * (1073741824); $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776); $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776); } elsif($type eq 'MHZ') { $size = sprintf("%.2f", ($bytes/1e-06)) . ' MHz' if ($bytes >= 1e-06 && $bytes < 0.001); $size = sprintf("%.2f", ($bytes*0.001)) . ' GHz' if ($bytes >= 0.001); } return $size; } sub getColor { my ($val) = @_; my $color_string = ""; if($val < $RED_WARN) { $color_string = "".$val." %"; } elsif($val < $ORANGE_WARN) { $color_string = "".$val." %"; } elsif($val < $YELLOW_WARN) { $color_string = "".$val." %"; } else { $color_string = "".$val." %"; } return $color_string; } # http://andrewcantino.com/class/l2.html sub power { my ($i,$t); my ($n, $p) = @_; $t = $n; for(my $i = 1; $i < $p; $i++) { $t = $t * $n; } return $t; } #http://www.perlmonks.org/?node_id=17057 sub days_between { my ($start, $end) = @_; my ($y1, $m1, $d1) = split ("-", $start); my ($y2, $m2, $d2) = split ("-", $end); my $diff = mktime(0,0,0, $d2-1, $m2-1, $y2 - 1900) - mktime(0,0,0, $d1-1, $m1-1, $y1 - 1900); return $diff / (60*60*24); } sub getUptime { my ($uptime) = @_; my @parts = gmtime($uptime); return $parts[7] . " days " . $parts[2] . " hours " . $parts[1] . " mins " . $parts[0] . " secs "; } sub giveMeDate { my ($date_format) = @_; my %dttime = (); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); ### begin_: initialize DateTime number formats $dttime{year } = sprintf "%04d",($year + 1900); ## four digits to specify the year $dttime{mon } = sprintf "%02d",($mon + 1); ## zeropad months $dttime{mday } = sprintf "%02d",$mday; ## zeropad day of the month $dttime{wday } = sprintf "%02d",$wday + 1; ## zeropad day of week; sunday = 1; $dttime{yday } = sprintf "%02d",$yday; ## zeropad nth day of the year $dttime{hour } = sprintf "%02d",$hour; ## zeropad hour $dttime{min } = sprintf "%02d",$min; ## zeropad minutes $dttime{sec } = sprintf "%02d",$sec; ## zeropad seconds $dttime{isdst} = $isdst; if($date_format eq 'MDYHMS') { $my_time = "$dttime{mon}-$dttime{mday}-$dttime{year} $dttime{hour}:$dttime{min}:$dttime{sec}"; } elsif ($date_format eq 'YMD') { $my_time = "$dttime{year}-$dttime{mon}-$dttime{mday}"; } return $my_time; }