Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 5801 lines (5132 sloc) 236 KB
#!/usr/bin/perl -w
# Author: William Lam
# Website: www.virtuallyghetto.com
use 5.10.0;
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 = "6.5.0";
$Util::script_version = $version;
my @supportedVersion = qw(4.0.0 4.1.0 5.0.0 5.1.0 5.5.0 6.0.0 6.5.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 troubleshoot [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) = ();
###############
# PROPERTY filters
###############
my $datacenter_properties = [ 'name' ];
###############
# 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 = 'emailserver';
my $EMAIL_DOMAIN = 'localhost.localdomain';
my @EMAIL_TO = 'william@primp-industries.com.com,tuan@primp-industries.com';
my $EMAIL_FROM = 'vMA@primp-industries.com';
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="yes";
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";
############################
# 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 {
if($email eq "yes") {
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 = <DATA>;
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");
$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 = "<div id=\"tab1\" class=\"content\">\n";
###########################
# SYSTEM BUILD INFO
###########################
if($atype eq 'VirtualCenter') {
$summary_start .= "<h2>VMware vCenter System Summary</h2>"
} else {
if($htype eq 'esx') {
$summary_start .= "<h2>VMware ESX System Summary</h2>"
}elsif($htype eq 'embeddedEsx') {
$summary_start .= "<h2>VMware ESXi System Summary</h2>"
}
}
$summary_start .= "\n<table border=\"1\">\n";
$summary_start .= "<tr><th>FULL NAME</th><th>VCENTER SERVER</th><th>INSTANCE UUID</th></tr>\n";
$summary_start .= "<tr><td>".$sc->about->fullName."</td><td>$system_name</td><td>".$sc->about->instanceUuid."</td></tr>\n";
$summary_start .= "</table>\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 .= "<h3>Licenses:</h3>\n";
$summary_start .= "<table border=\"1\">\n";
$summary_start .= "<tr><th>NAME</th><th>EDITION</th><th>LICENSE</th><th>COST UNIT</th><th>TOTAL</th><th>CONSUMED</th><th>AVAILABLE</th></tr>\n";
my $licenses = $licenseMgr->licenses;
foreach(@$licenses) {
if($demo eq "no") {
my $licenseName = $_->name;
my $licenseEdition = $_->editionKey;
my $licenseKey = $_->licenseKey;
my $licenseCost = $_->costUnit;
my $licenseUsed = int(($_->used ? $_->used : 0));
my $licenseTotal = $_->total;
my $licenseConsumed = ($licenseTotal - $licenseUsed);
$summary_start .= "<tr><td>".$licenseName."</td><td>".$licenseEdition."</td><td>".$licenseKey."</td><td>".$licenseCost."</td><td>".$licenseTotal."</td><td>".$licenseUsed."</td><td>".$licenseConsumed."</td></tr>\n";
my $licenseProperties = $_->properties;
if($licenseProperties) {
$feature_info_string .= "<tr><th>EDITION w/FEATURES</th><th>EXPIRATION (HOURS)</th><th>EXPIRATION (MINS)</th><th>EXPIRATION DATE</th></tr>\n";
$feature_info_string .= "<tr><td><b>".$licenseEdition."</b></td>\n";
}
foreach(@$licenseProperties) {
if($_->key ne 'feature') {
if($_->key eq 'expirationHours' ) { $feature_info_string .= "<td>".$_->value."</td>"; }
if($_->key eq 'expirationMinutes' ) { $feature_info_string .= "<td>".$_->value."</td>"; }
if($_->key eq 'expirationDate' ) { $feature_info_string .= "<td>".$_->value."</td></tr>\n"; }
} else {
my $feature = $_->value;
$features .= "<tr><td>".$feature->value."</td></tr>\n";
}
}
} else {
$summary_start .= "<tr><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td></tr>\n";
}
$feature_string .= $feature_info_string . $features;
($features,$feature_info_string) = ("","");
}
$summary_start .= "</table>\n";
}
###########################
# FEATURES
###########################
if($SYSTEM_FEATURE eq "yes" && $SYSTEM_LICENSE eq "yes") {
$summary_start .= "<h3>Features:</h3>\n";
$summary_start .= "<table border=\"1\">\n";
if($demo eq "no") {
$summary_start .= $feature_string;
} else {
$summary_start .= "<tr><td>DEMO_MODE</td></tr>\n";
}
$summary_start .= "</table>\n";
}
###########################
# PERMISSIONS
###########################
if($SYSTEM_PERMISSION eq "yes") {
$summary_start .= "<h3>Permissions:</h3>\n";
$summary_start .= "<table border=\"1\">\n";
$summary_start .= "<tr><th>USER/GROUP</th><th>ROLE</th><th>DEFINED IN</th><th>PROPAGATE</th><th>IS GROUP</th></tr>\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 .= "<tr><td>" . $_->principal . "</td><td>" . $rolemapping{$_->roleId} . "</td><td>" . $ent->{'name'} . "</td><td>" . (($_->propagate) ? "YES" : "NO") . "</td><td>" . (($_->group) ? "YES" : "NO") . "</td></tr>\n";
}
};
if($@) { print "ERROR: Unable to query for permissions: " . $@ . "\n"; }
} else {
$summary_start .= "<tr><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td></tr>\n";
}
$summary_start .= "</table>\n";
}
###########################
# SESSIONS
###########################
if($SYSTEM_SESSION eq "yes") {
$summary_start .= "<h3>Active Session(s):</h3>\n";
$summary_start .= "<table border=\"1\">\n";
$summary_start .= "<tr><th>USERNAME</th><th>FULL NAME</th><th>LOGON TIME</th><th>LAST ACTIVE</th></tr>\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 .= "<tr><td>".$_->userName."</td><td>".$_->fullName."</td><td>".$_->loginTime."</td><td>".$_->lastActiveTime."</td></tr>\n";
}
} else {
$summary_start .= "<tr><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td></tr>\n";
}
$summary_start .= "</table>\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 .= "<tr><td>".$_->name."</td><td>".$profileDescription."</td><td>".$_->createdTime."</td><td>".$_->modifiedTime."</td><td>".(($_->config->enabled) ? "YES" : "NO")."</td><td>".$_->complianceStatus."</td></tr>\n";
}
if($hasProfile eq 1) {
$summary_start .= "<h3>Host Profile(s):</h3>\n";
$summary_start .= "<table border=\"1\">\n";
$summary_start .= "<tr><th>PROFILE NAME</th><th>DESCRIPTION</th><th>CREATION TIME</th><th>LAST MODIFIED</th><th>ENABLED</th><th>COMPLIANCE STATUS</th></tr>\n";
$summary_start .= $profile_string;
}
}
$summary_start .= "</table>\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 .= "<tr>";
$ext_string .= "<td>".$_->description->label."</td>";
$ext_string .= "<td>".($_->version ? $_->version : "N/A")."</td>";
$ext_string .= "<td>".($_->company ? $_->company : "N/A")."</td>";
$ext_string .= "</tr>\n";
}
$summary_start .= "<h3>Plugin(s):</h3>\n";
$summary_start .= "<table border=\"1\">\n";
$summary_start .= "<tr><th>PLUGIN NAME</th><th>VERSION</th><th>COMPANY</th></tr>\n";
$summary_start .= $ext_string;
$summary_start .= "</table>\n";
}
}
$summary_start .= "\n</div>";
print REPORT_OUTPUT $summary_start;
}
sub getCluster {
my ($type,$atype,$aversion) = @_;
my $cluster_count = 0;
if($type eq 'cluster') {
print REPORT_OUTPUT "<div id=\"tab2\" class=\"content\">";
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert cluster jump -->/\n";
$cluster_count++;
&printClusterSummary($cluster_view,$cluster_count,$atype,$aversion);
print REPORT_OUTPUT "</div>\n";
}elsif($type eq 'datacenter') {
$cluster_views = Vim::find_entity_views(view_type => 'ClusterComputeResource',begin_entity => $datacenter_view);
if($cluster_views) {
print REPORT_OUTPUT "<div id=\"tab2\" class=\"content\">";
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert cluster jump -->/\n";
foreach(sort {$a->name cmp $b->name} @$cluster_views) {
$cluster_count++;
if($_->isa("ClusterComputeResource")) {
&printClusterSummary($_,$cluster_count,$atype,$aversion);
}
}
print REPORT_OUTPUT "</div>\n";
}
}elsif($type eq 'vcenter') {
if($cluster_views) {
print REPORT_OUTPUT "<div id=\"tab2\" class=\"content\">";
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert cluster jump -->/\n";
foreach(sort {$a->name cmp $b->name} @$cluster_views) {
$cluster_count++;
if($_->isa("ClusterComputeResource")) {
&printClusterSummary($_,$cluster_count,$atype,$aversion);
}
}
}
print REPORT_OUTPUT "</div>\n";
}
}
sub getDatastoreCluster {
my ($type,$atype,$aversion) = @_;
my $datastore_cluster_count = 0;
if($type eq 'cluster' && ($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0')) {
print REPORT_OUTPUT "<div id=\"tab7\" class=\"content\">";
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert datastore cluster jump -->/\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 "</div>\n";
} elsif($type eq 'datacenter' && ($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0')) {
print REPORT_OUTPUT "<div id=\"tab7\" class=\"content\">";
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert datastore cluster jump -->/\n";
$datastore_cluster_count++;
&printDatacenterSummary($datacenter_view,$datastore_cluster_count,$atype,$aversion);
print REPORT_OUTPUT "</div>\n";
} elsif($type eq 'vcenter' && ($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0')) {
print REPORT_OUTPUT "<div id=\"tab7\" class=\"content\">";
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert datastore cluster jump -->/\n";
$datacenter_views = Vim::find_entity_views(view_type => 'Datacenter'
, properties => $datacenter_properties );
foreach(sort {$a->name cmp $b->name} @$datacenter_views) {
$datastore_cluster_count++;
&printDatacenterSummary($_,$datastore_cluster_count,$atype,$aversion);
}
print REPORT_OUTPUT "</div>\n";
}
}
sub getHost {
my ($type,$atype,$aversion,$sc) = @_;
print REPORT_OUTPUT "<div id=\"tab3\" class=\"content\">\n";
my $cluster_count = 0;
if($type eq 'host') {
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert host jump -->/\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/<!-- insert host jump -->/\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,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\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/<!-- insert host jump -->/\n";
my $clusterTag = "host-".$cluster_view->name."-$cluster_count";
my $clusterShortTag = $cluster_view->name;
push @host_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\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/<!-- insert host jump -->/\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,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
my $hosts = Vim::get_views (mo_ref_array => $cluster->host);
&printHostSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc);
}
}
print REPORT_OUTPUT "</div>\n";
}
sub getVM {
my ($type,$atype,$aversion,$sc) = @_;
print REPORT_OUTPUT "<div id=\"tab4\" class=\"content\">\n";
my $cluster_count = 0;
if($type eq 'host') {
#please do not touch this, else the jump tags will break
print REPORT_OUTPUT "\n/<!-- insert vm jump -->/\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/<!-- insert vm jump -->/\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,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\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/<!-- insert vm jump -->/\n";
my $clusterTag = "vm-".$cluster_view->name."-$cluster_count";
my $clusterShortTag = $cluster_view->name;
push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\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/<!-- insert vm jump -->/\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,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
my $hosts = Vim::get_views (mo_ref_array => $cluster->host);
&printVMSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc);
}
}
print REPORT_OUTPUT "</div>\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 "<div id=\"tab5\" class=\"content\">\n";
print REPORT_OUTPUT "<h2>vCenter VPX Configurations</h2>\n";
print REPORT_OUTPUT "<table border=\"1\">\n";
print REPORT_OUTPUT "<tr><th>KEY</th><th>VALUE</th></tr>\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 .= "<tr><td>".$key."</td><td>".$value."</tr>\n";
}
print REPORT_OUTPUT $vpxString;
print REPORT_OUTPUT "</table>\n";
print REPORT_OUTPUT "</div>\n";
}
}
}
sub getVMwareApps {
my ($vmwcheck,$atype,$sc) = @_;
if($vmwcheck eq "yes" && $atype eq "VirtualCenter") {
my $vmwAppString = "";
if(@vmw_apps) {
print REPORT_OUTPUT "<div id=\"tab6\" class=\"content\">\n";
print REPORT_OUTPUT "<h2>VMware and 3rd Party Applications in a VM</h2>\n";
print REPORT_OUTPUT "<table border=\"1\">\n";
print REPORT_OUTPUT "<tr><th>CLUSTER</th><th>VM NAME</th><th>VMWARE/3RD PARTY APPLICATION</th></tr>\n";
foreach(@vmw_apps) {
$vmwAppString .= $_;
}
print REPORT_OUTPUT $vmwAppString;
print REPORT_OUTPUT "</table>\n";
print REPORT_OUTPUT "</div>\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 = "<tr><td>".$cluster_name."</td><td>".$vm->name."</td><td>".$_->key."</td></tr>\n";
push @vmw_apps, $tagString;
}
}
######################
# VM STATE
######################
if($VM_STATE eq "yes") {
$vmstateString .= "<tr>";
## ESX/ESXi host ##
$vmstateString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmstateString .= "<td>".$vm->name."</td>";
## BOOT TIME ##
$vmstateString .= "<td>".($vm->runtime->bootTime ? $vm->runtime->bootTime : "N/A")."</td>";
if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
## UPTIME ##
$vmstateString .= "<td>".($vm->summary->quickStats->uptimeSeconds ? &getUptime($vm->summary->quickStats->uptimeSeconds) : "N/A")."</td>";
}
## ANNOTATION ##
$vmstateString .= "<td>" . ($vm->config->annotation ? $vm->config->annotation : "N/A") . "</td>";
## OVERALL STATUS ##
my $vm_health = $vm->summary->overallStatus->val;
if ($vm_health eq 'green') { $vmstateString .= "<td bgcolor=\"$green\">VM is OK</td>"; }
elsif ($vm_health eq 'red') { $vmstateString .= "<td bgcolor=\"$red\">VM has a problem</td>"; }
elsif ($vm_health eq 'yellow') { $vmstateString .= "<td bgcolor=\"$yellow\">VM<might have a problem</td>"; }
else { $vmstateString .="<td bgcolor=\"gray\">UNKNOWN</td>"; }
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
## HA PROTECTION ##
if($vm->runtime->dasVmProtection) {
$vmstateString .= "<td>".($vm->runtime->dasVmProtection->dasProtected ? "YES" : "NO")."</td>";
} else { $vmstateString .= "<td>N/A</td>"; }
} else { $vmstateString .= "<td>N/A</td>"; }
if($aversion eq '4.1.0' || $aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
## APP HEARTBEAT ##
$vmstateString .= "<td>".($vm->guest->appHeartbeatStatus ? $vm->guest->appHeartbeatStatus : "N/A")."</td>";
}
## CONNECTION STATE ##
$vmstateString .= "<td>".$vm->runtime->connectionState->val."</td>";
## POWER STATE ##
$vmstateString .= "<td>".$vm->runtime->powerState->val."</td>";
## CONSOLIDATION ##
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
$vmstateString .= "<td>".($vm->runtime->consolidationNeeded ? "YES" : "NO")."</td>";
} else { $vmstateString .= "<td>N/A</td>"; }
$vmstateString .= "</tr>";
}
######################
# VM CONFIG
######################
if($VM_CONFIG eq "yes") {
$vmconfigString .= "<tr>";
## ESX/ESXi host ##
$vmconfigString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmconfigString .= "<td>".$vm->name."</td>";
## VIRTUAL HARDWARE VER ##
$vmconfigString .= "<td>".$vm->config->version."</td>";
## GUEST HOSTNAME ##
$vmconfigString .= "<td>".($vm->guest->hostName ? $vm->guest->hostName : "N/A")."</td>";
## UUID ##
$vmconfigString .= "<td>".($vm->summary->config->uuid ? $vm->summary->config->uuid : "N/A")."</td>";
## FIRMWARE ##
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
$vmconfigString .= "<td>".($vm->config->firmware ? $vm->config->firmware : "N/A")."</td>";
} else { $vmconfigString .= "<td>N/A</td>"; }
## OS ##
$vmconfigString .= "<td>".($vm->config->guestFullName ? $vm->config->guestFullName : "N/A")."</td>";
## vCPU ##
$vmconfigString .= "<td>".($vm->summary->config->numCpu ? $vm->summary->config->numCpu : "N/A")."</td>";
## vMEM ##
$vmconfigString .= "<td>".($vm->summary->config->memorySizeMB ? &prettyPrintData($vm->summary->config->memorySizeMB,'M') : "N/A")."</td>";
## vDISK ##
$vmconfigString .= "<td>".($vm->summary->config->numVirtualDisks ? $vm->summary->config->numVirtualDisks : "N/A")."</td>";
## 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 .= "<td>".&prettyPrintData(($commit + $uncommit),'B')."</td>";
} else {
$vmconfigString .= "<td>N/A</td>";
}
## vNIC ##
$vmconfigString .= "<td>".($vm->summary->config->numEthernetCards ? $vm->summary->config->numEthernetCards : "N/A")."</td>";
if(!$vm->config->template) {
## CPU RESERV ##
$vmconfigString .= "<td>".($vm->summary->config->cpuReservation ? &prettyPrintData($vm->summary->config->cpuReservation,'MHZ') : "N/A")."</td>";
## MEM RESERV ##
$vmconfigString .= "<td>".($vm->summary->config->memoryReservation ? &prettyPrintData($vm->summary->config->memoryReservation,'M') : "N/A")."</td>";
} else {
$vmconfigString .= "<td>N/A</td>";
$vmconfigString .= "<td>N/A</td>";
}
## TEMPLATE ##
$vmconfigString .= "<td>".($vm->config->template ? "YES" : "NO")."</td>";
$vmconfigString .= "</tr>\n";
}
######################
# STATISTICS
######################
if($VM_STATS eq "yes") {
if(!$vm->config->template) {
$vmstatString .= "<tr>";
## ESX/ESXi host ##
$vmstatString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmstatString .= "<td>".$vm->name."</td>";
## CPU USAGE ##
$vmstatString .= "<td>".($vm->summary->quickStats->overallCpuUsage ? &prettyPrintData($vm->summary->quickStats->overallCpuUsage,'MHZ') : "N/A" )."</td>";
## MEM USAGE ##
$vmstatString .= "<td>".($vm->summary->quickStats->guestMemoryUsage ? &prettyPrintData($vm->summary->quickStats->guestMemoryUsage,'M') : "N/A")."</td>";
## MAX CPU USAGE ##
$vmstatString .= "<td>".($vm->runtime->maxCpuUsage ? &prettyPrintData($vm->runtime->maxCpuUsage,'MHZ') : "N/A")."</td>";
## MAX MEM USAGE ##
$vmstatString .= "<td>".($vm->runtime->maxMemoryUsage ? &prettyPrintData($vm->runtime->maxMemoryUsage,'M') : "N/A")."</td>";
## ACTIVE MEM ##
$vmstatString .= "<td>".($vm->summary->quickStats->guestMemoryUsage ? &prettyPrintData($vm->summary->quickStats->guestMemoryUsage,'M') : "N/A")."</td>";
## CONSUMED MEM ##
$vmstatString .= "<td>".($vm->summary->quickStats->hostMemoryUsage ? &prettyPrintData($vm->summary->quickStats->hostMemoryUsage,'M') : "N/A")."</td>";
## INITIAL MEM RESV OVERHEAD + INITIAL MEM SWAP RESV OVERHEAD ##
if(($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') && $vm->config->initialOverhead) {
$vmstatString .= "<td>".($vm->config->initialOverhead->initialMemoryReservation ? &prettyPrintData($vm->config->initialOverhead->initialMemoryReservation,'B') : "N/A")."</td>";
$vmstatString .= "<td>".($vm->config->initialOverhead->initialSwapReservation ? &prettyPrintData($vm->config->initialOverhead->initialSwapReservation,'B') : "N/A")."</td>";
} else { $vmstatString .= "<td>N/A</td><td>N/A</td>"; }
## MEM OVERHEAD ##
$vmstatString .= "<td>".($vm->summary->quickStats->consumedOverheadMemory ? &prettyPrintData($vm->summary->quickStats->consumedOverheadMemory,'M') : "N/A")."</td>";
## MEM BALLON ##
$vmstatString .= "<td>".($vm->summary->quickStats->balloonedMemory ? &prettyPrintData($vm->summary->quickStats->balloonedMemory,'M') : "N/A")."</td>";
if($aversion eq '4.1.0' || $aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.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 .= "<td>".$compressedMem."</td>";
} else { $vmstatString .= "<td>N/A</td>"; }
}
$vmstatString .= "</tr>\n";
}
}
######################
# VM RESOURCE
######################
if($VM_RESOURCE_ALLOCATION eq "yes") {
if(!$vm->config->template && $vm->resourceConfig) {
$vmrscString .= "<tr>";
## ESX/ESXi host ##
$vmrscString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmrscString .= "<td>".$vm->name."</td>";
## MODIFIED ##
$vmrscString .= "<td>".($vm->resourceConfig->lastModified ? $vm->resourceConfig->lastModified : "N/A")."</td>";
my $cpuAllocation = $vm->resourceConfig->cpuAllocation;
my $memAllocation = $vm->resourceConfig->memoryAllocation;
#cpu
## RESERVATION ##
$vmrscString .= "<td>".($cpuAllocation->reservation ? &prettyPrintData($cpuAllocation->reservation,'MHZ') : "N/A")."</td>";
## LIMIT ##
$vmrscString .= "<td>".($cpuAllocation->limit ? &prettyPrintData($cpuAllocation->limit,'MHZ') : "N/A")."</td>";
## SHARES ##
# SHARES VALUE
$vmrscString .= "<td>".($cpuAllocation->shares->shares ? $cpuAllocation->shares->shares : "N/A")."</td>";
# SHARES LEVEL
$vmrscString .= "<td>".($cpuAllocation->shares->level->val ? $cpuAllocation->shares->level->val : "N/A")."</td>";
## EXPAND RESERVATION ##
$vmrscString .= "<td>".($cpuAllocation->expandableReservation ? "YES" : "NO")."</td>";
## OVERHEAD LIMIT ##
$vmrscString .= "<td>".($cpuAllocation->overheadLimit ? &prettyPrintData($cpuAllocation->overheadLimit,'MHZ') : "N/A")."</td>";
#mem
## RESERVATION ##
$vmrscString .= "<td>".($memAllocation->reservation ? &prettyPrintData($memAllocation->reservation,'M') : "N/A")."</td>";
## LIMIT ##
$vmrscString .= "<td>".($memAllocation->limit ? &prettyPrintData($memAllocation->limit,'M') : "N/A")."</td>";
## SHARES ##
# SHARES VALUE
$vmrscString .= "<td>".($memAllocation->shares->shares ? $memAllocation->shares->shares : "N/A")."</td>";
# SHARES LEVEL
$vmrscString .= "<td>".($memAllocation->shares->level->val ? $memAllocation->shares->level->val : "N/A")."</td>";
## EXPAND RESERVATION ##
$vmrscString .= "<td>".($memAllocation->expandableReservation ? "YES" : "NO")."</td>";
## OVERHEAD LIMIT ##
$vmrscString .= "<td>".($memAllocation->overheadLimit ? &prettyPrintData($memAllocation->overheadLimit,'M') : "N/A")."</td>";
$vmrscString .= "</tr>\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 .= "<tr>";
## ESX/ESXi host ##
$vmftString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmftString .= "<td>".$vm->name."</td>";
## FT STATE ##
$vmftString .= "<td>".$vm->runtime->faultToleranceState->val."</td>";
## FT ROLE ##
my $role = "";
if($vm->summary->config->ftInfo->role eq 1) { $role = "PRIMARY"; } else { $role = "SECONDARY"; }
$vmftString .= "<td>".$role."</td>";
## 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 .= "<td>".$instanceuuids."</td>";
## FT SECONDARY LATENCY ##
$vmftString .= "<td>".($vm->summary->quickStats->ftSecondaryLatency ? $vm->summary->quickStats->ftSecondaryLatency : "N/A")."</td>";
## FT BW ##
$vmftString .= "<td>".($vm->summary->quickStats->ftLogBandwidth ? $vm->summary->quickStats->ftLogBandwidth : "N/A")."</td>";
$vmftString .= "</tr>\n";
}
}
######################
# EZT
######################
if($VM_EZT eq "yes" && ($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.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."<br/>";
$ezt_disk_string .= $diskName."<br/>";
$ezt_size_string .= &prettyPrintData($_->capacityInKB,'K')."<br/>";
}
}
}
}
if($hasEZT eq 1) {
$vmeztString .= "<tr>";
## ESX/ESXi host ##
$vmeztString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmeztString .= "<td>".$vm->name."</td>";
## EZT LABEL ##
$vmeztString .= "<td>".$ezt_label_string."</td>";
## EZT DISKS ##
$vmeztString .= "<td>".$ezt_disk_string."</td>";
## EZT DISKS SIZE ##
$vmeztString .= "<td>".$ezt_size_string."</td>";
$vmeztString .= "</tr>\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."<br/>";
$thin_disk_string .= $diskName."<br/>";
$thin_size_string .= &prettyPrintData($_->capacityInKB,'K')."<br/>";
}
}
}
if($hasThin eq 1) {
$vmthinString .= "<tr>";
## ESX/ESXi host ##
$vmthinString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmthinString .= "<td>".$vm->name."</td>";
## THIN LABEL ##
$vmthinString .= "<td>".$thin_label_string."</td>";
## THIN DISKS ##
$vmthinString .= "<td>".$thin_disk_string."</td>";
## THIN DISKS SIZE ##
$vmthinString .= "<td>".$thin_size_string."</td>";
$vmthinString .= "</tr>\n";
}
}
}
######################
# DEVICE
######################
if($VM_DEVICE eq "yes") {
if(!$vm->config->template) {
$vmdeviceString .= "<tr>";
## ESX/ESXi host ##
$vmdeviceString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmdeviceString .= "<td>".$vm->name."</td>";
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 .= "<td>".($vm->config->guestFullName ? $vm->config->guestFullName : "N/A")."</td>";
## CDROM ##
$vmdeviceString .= "<td>".$cdrom."</td>";
## CONTROLER ##
my $controllerString = "";
if($idecontroller != 0) {
$controllerString .= $idecontroller . " x IDE Controller<br/>";
}
if($pcicontroller != 0) {
$controllerString .= $pcicontroller . " x PCI Controller<br/>";
}
if($ps2controller != 0) {
$controllerString .= $ps2controller . " x PS2 Controller<br/>";
}
if($paracontroller != 0) {
$controllerString .= $paracontroller . " x PARA-VIRT Controller<br/>";
}
if($buscontroller != 0) {
$controllerString .= $buscontroller . " x BUS Controller<br/>";
}
if($lsicontroller != 0) {
$controllerString .= $lsicontroller . " x LSI LOGIC Controller<br/>";
}
if($lsilogiccontroller != 0) {
$controllerString .= $lsilogiccontroller . " x LSI LOGIC SAS Controller<br/>";
}
if($siocontroller != 0) {
$controllerString .= $siocontroller . " x SIO Controller<br/>";
}
if($usbcontroller != 0) {
$controllerString .= $usbcontroller . " x USB Controller<br/>";
}
if($controllerString eq "") { $controllerString = "N/A"; }
$vmdeviceString .= "<td>".$controllerString."</td>";
## DISK ##
$vmdeviceString .= "<td>".$disk."</td>";
## ETHERNET CARD ##
my $ethString = "";
if($e1000ethernet != 0) {
$ethString .= $e1000ethernet . " x e1000<br/>";
}
if($pcnet32ethernet != 0) {
$ethString .= $pcnet32ethernet . " x PCNET32<br/>";
}
if($vmxnet2ethernet != 0) {
$ethString .= $vmxnet2ethernet . " x VMXNET2<br/>";
}
if($vmxnet3ethernet != 0) {
$ethString .= $vmxnet3ethernet . " x VMXNET3<br/>";
}
if($ethString eq "") { $ethString = "N/A"; }
$vmdeviceString .= "<td>".$ethString."</td>";
## FLOPPY ##
$vmdeviceString .= "<td>".$floppy."</td>";
## KEYBOARD ##
$vmdeviceString .= "<td>".$keyboard."</td>";
## VIDEO CARD ##
$vmdeviceString .= "<td>".$videocard."</td>";
## VMCI ##
$vmdeviceString .= "<td>".$vmci."</td>";
## VMIROM ##
$vmdeviceString .= "<td>".$vmi."</td>";
## PARALLEL PORT ##
$vmdeviceString .= "<td>".$parallelport."</td>";
## PCI PASS THROUGH ##
$vmdeviceString .= "<td>".$pcipassthrough."</td>";
## POINTING DEVICE ##
$vmdeviceString .= "<td>".$pointingdevice."</td>";
## SCSI PASS THROUGH ##
$vmdeviceString .= "<td>".$scsipassthrough."</td>";
## SERIAL PORT ##
$vmdeviceString .= "<td>".$serialport."</td>";
## SOUND CARD ##
my $soundString = "";
if($ensoniqsoundcard != 0) {
$soundString .= $ensoniqsoundcard . " x Ensoiq1373 Sound Card<br/>";
}
if($blastersoundcard != 0) {
$soundString .= $blastersoundcard . " x Soundblaster Sound Card<br/>";
}
if($soundString eq "") { $soundString = "N/A"; }
$vmdeviceString .= "<td>".$soundString."</td>";
## USB ##
$vmdeviceString .= "<td>".$usb."</td>";
$vmdeviceString .= "</tr>\n";
}
}
######################
# VM STORAGE
######################
if($VM_STORAGE eq "yes") {
if(!$vm->config->template && $vm->guest->disk) {
$vmstorageString .= "<tr>";
## ESX/ESXi host ##
$vmstorageString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmstorageString .= "<td>".$vm->name."</td>";
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 .= "<td><table border=\"1\" width=100%><tr><td>$vm_disk_path</td><td>$vm_disk_free</td><td>$vm_disk_cap</td>$perc_string</tr></table></td>";
}
$vmstorageString .= $disk_string;
$vmstorageString .= "</tr>\n";
}
}
######################
# VM NETWORK
######################
if($VM_NETWORK eq "yes" && $vm->guest->net) {
if(!$vm->config->template) {
$vmnetworkString .= "<tr>";
## ESX/ESXi host ##
$vmnetworkString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmnetworkString .= "<td>".$vm->name."</td>";
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' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
if($_->ipConfig) {
my $ips = $_->ipConfig->ipAddress;
foreach(@$ips) {
if($demo eq "no") {
$vm_ip_string .= $_->ipAddress."<br/>";
} else {
$vm_ip_string .= "demo_mode<br/>";
}
}
} else { $vm_ip_string .= "N/A<br/>"; }
} else {
if($_->ipAddress) {
my $ips = $_->ipAddress;
foreach(@$ips) {
if($demo eq "no") {
$vm_ip_string .= $_."<br/>";
} else {
$vm_ip_string .= "demo_mode<br/>";
}
}
} else {
$vm_ip_string .= "N/A<br/>";
}
}
## MAC ADDRESS ##
if($_->macAddress) {
if($demo eq "no") {
$vm_mac_string .= $_->macAddress."<br/>";
} else {
$vm_mac_string .= "demo_mode<br/>";
}
} else {
$vm_mac_string .= "N/A<br/>";
}
## PORTGROUP ##
if($_->network) {
if($demo eq "no") {
$vm_pg_string .= $_->network."<br/>";
} else {
$vm_pg_string .= "demo_mode<br/>";
}
} else {
$vm_pg_string .= "N/A<br/>";
}
## CONNECTED ##
$vm_connect_string .= ($_->connected ? "YES<br/>" : "NO<br/>");
}
$vmnetworkString .= "<td>".$vm_ip_string."</td><td>".$vm_mac_string."</td><td>".$vm_pg_string."</td><td>".$vm_connect_string."</td>";
$vmnetworkString .= "</tr>\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 .= "<tr>".$_."</tr>\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."<br/>";
} else {
$cd_string .= "N/A";
}
}
}
if($hasCD eq 1) {
$vmcdString .= "<tr>";
## ESX/ESXi host ##
$vmcdString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmcdString .= "<td>".$vm->name."</td>";
## ISO ##
$vmcdString .= "<td>".$cd_string."</td>";
$vmcdString .= "</tr>\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."<br/>";
} else {
$flp_string .= "N/A";
}
}
}
if($hasFLP eq 1) {
$vmflpString .= "<tr>";
## ESX/ESXi host ##
$vmflpString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmflpString .= "<td>".$vm->name."</td>";
## FLP ##
$vmflpString .= "<td>".$flp_string."</td>";
$vmflpString .= "</tr>\n";
}
}
}
######################
# TOOLS
######################
if($VM_TOOL eq "yes") {
if(!$vm->config->template) {
$vmtoolString .= "<tr>";
## ESX/ESXi host ##
$vmtoolString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmtoolString .= "<td>".$vm->name."</td>";
if($vm->guest) {
## TOOLS VERSION ##
$vmtoolString .= "<td>".($vm->guest->toolsVersion ? $vm->guest->toolsVersion : "N/A")."</td>";
## TOOLS RUNNING STATUS ##
$vmtoolString .= "<td>".($vm->guest->toolsRunningStatus ? $vm->guest->toolsRunningStatus : "N/A")."</td>";
## TOOLS VERSION STATUS ##
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
$vmtoolString .= "<td>".($vm->guest->toolsVersionStatus2 ? $vm->guest->toolsVersionStatus2 : "N/A")."</td>";
} else {
$vmtoolString .= "<td>".($vm->guest->toolsVersionStatus ? $vm->guest->toolsVersionStatus : "N/A")."</td>";
}
} else {
$vmtoolString .= "<td>N/A</td>";
$vmtoolString .= "<td>N/A</td>";
$vmtoolString .= "<td>N/A</td>";
}
if($vm->config->tools) {
## TOOLS UPGRADE POLICY ##
$vmtoolString .= "<td>".($vm->config->tools->toolsUpgradePolicy ? $vm->config->tools->toolsUpgradePolicy : "N/A")."</td>";
## SYNC TIME ##
$vmtoolString .= "<td>".($vm->config->tools->syncTimeWithHost ? "YES" : "NO")."</td>";
} else {
$vmtoolString .= "<td>N/A</td>";
$vmtoolString .= "<td>N/A</td>";
}
$vmtoolString .= "</tr>\n";
}
}
######################
# RDM
######################
if($VM_RDM eq "yes") {
if(!$vm->config->template) {
my $devices = $vm->config->hardware->device;
my $hasRDM = 0;
foreach(@$devices) {
my ($rdm_string) = ("");
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 .= "<td>".$compat_mode."</td><td>".$vmhba."</td><td>".$disk_mode."</td><td>".$lun_uuid."</td><td>".$vm_uuid."</td>";
#}
#if($hasRDM eq 1) {
$vmrdmString .= "<tr>";
## ESX/ESXi host ##
$vmrdmString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmrdmString .= "<td>".$vm->name."</td>";
## RDM ##
$vmrdmString .= $rdm_string;
$vmrdmString .= "</tr>\n";
}}
}
}
######################
# NPIV
######################
if($VM_NPIV eq "yes") {
if(!$vm->config->template) {
if($vm->config->npivNodeWorldWideName && $vm->config->npivPortWorldWideName) {
$vmnpivString .= "<tr>";
## ESX/ESXi host ##
$vmnpivString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmnpivString .= "<td>".$vm->name."</td>";
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 = "<td>";
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<br/>";
} else {
$npiv_string .= "XX:XX:XX:XX:XX:XX:XX:XX<br/>";
}
}
$npiv_string .= "</td><td>";
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<br/>";
} else {
$npiv_string .= "XX:XX:XX:XX:XX:XX:XX:XX<br/>";
}
}
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 .= "</td><td>".$npivtype."</td><td>".$desirednwwn."</td><td>".$desiredpwwn."</td>";
$vmnpivString .= $npiv_string;
$vmnpivString .= "</tr>\n";
}
}
}
if($VM_STATS eq "yesaaaaa") {
if(!$vm->config->template) {
$vmstatString .= "<tr>";
## ESX/ESXi host ##
$vmstatString .= "<td>".$host_name."</td>";
## DISPLAY NAME ##
$vmstatString .= "<td>".$vm->name."</td>";
$vmstatString .= "</tr>\n";
}
}
## STOP ###
}
}
######################
# DLETA
######################
if($VM_DELTA eq "yes") {
foreach(@vmdeltas) {
$vmdeltaString .= "<tr>".$_."</tr>\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 .= "<tr>";
$hardwareConfigurationString .= "<td>".$host_name."</td>";
$hardwareConfigurationString .= "<td>".$local_host->summary->hardware->vendor."</td>";
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 .= "<td>".$additional_vendor_info."</td>";
$hardwareConfigurationString .= "<td>".$local_host->summary->hardware->model."</td>";
$hardwareConfigurationString .= "<td>".$local_host->summary->hardware->cpuModel."</td>";
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
$hardwareConfigurationString .= "<td>".(($local_host->hardware->smcPresent) ? "YES" : "NO")."</td>";
} else { $hardwareConfigurationString .= "<td>N/A</td>"; }
$hardwareConfigurationString .= "<td>".(($local_host->config->hyperThread->available) ? "YES" : "NO")."</td>";
$hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->hardware->numCpuCores*$local_host->summary->hardware->cpuMhz,'MHZ')."</td>";
$hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->quickStats->overallCpuUsage,'MHZ')."</td>";
$hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numCpuPkgs."</td>";
$hardwareConfigurationString .= "<td>".($local_host->summary->hardware->numCpuCores/$local_host->summary->hardware->numCpuPkgs)."</td>";
$hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numCpuThreads."</td>";
$hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->hardware->memorySize,'B')."</td>";
$hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->quickStats->overallMemoryUsage,'M')."</td>";
$hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numNics."</td>";
$hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numHBAs."</td>";
$hardwareConfigurationString .= "</tr>\n";
}
######################
# MGMT
######################
if($HOST_MGMT eq "yes") {
$mgmtString .= "<tr>";
$mgmtString .= "<td>".$host_name."</td>";
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 .= "<td>".$mgmtIp."</td>";
if($atype eq "VirtualCenter") {
if($local_host->summary->config->product) {
$mgmtString .= "<td>".($local_host->config->adminDisabled ? "YES" : "NO")."</td>";
}
} else {
$mgmtString .= "<td>UNKNOWN</td>";
}
if($aversion eq '4.1.0' || $aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0' || $hostAPIVersion eq '5.5.0') {
my $systemFile = "";
if($local_host->config->systemFile) {
my $systemfile = $local_host->config->systemFile;
foreach(@$systemfile) {
$systemFile .= $_ . "<br/>";
}
} else {
$systemFile = "N/A";
}
$mgmtString .= "<td>$systemFile</td>";
} else {
$mgmtString .= "<td>N/A</td>";
}
}
$mgmtString .= "<td>".$local_host->summary->hardware->uuid."</td>";
if($local_host->config->consoleReservation) {
$mgmtString .= "<td>".($local_host->config->consoleReservation->serviceConsoleReserved ? &prettyPrintData($local_host->config->consoleReservation->serviceConsoleReserved,'B') : "N/A")."</td>";
} else {
$mgmtString .= "<td>N/A</td>";
}
$mgmtString .= "</tr>\n";
}
######################
# STATE
######################
if($HOST_STATE eq "yes") {
$stateString .= "<tr>";
$stateString .= "<td>".$host_name."</td>";
my $host_health .= $local_host->overallStatus->val;
if ($host_health eq 'green') { $stateString .= "<td bgcolor=\"$green\">HOST is OK</td>"; }
elsif ($host_health eq 'red') { $stateString .= "<td bgcolor=\"$red\">HOST has a problem</td>"; }
elsif ($host_health eq 'yellow') { $stateString .= "<td bgcolor=\"$yellow\">HOST might have a problem</td>"; }
else { $stateString .= "<td bgcolor=\"gray\">UNKNOWN</td>"; }
$stateString .= "<td>".$local_host->runtime->powerState->val."</td>";
if($local_host->runtime->bootTime) { $stateString .= "<td>".$local_host->runtime->bootTime."</td>"; }
else { $stateString .= "<td>UNKNOWN</td>"; }
if($aversion eq '4.1.0' || $aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0' || $hostAPIVersion eq '5.5.0') {
if($local_host->summary->quickStats->uptime) {
my $uptime = $local_host->summary->quickStats->uptime;
$stateString .= "<td>".&getUptime($uptime)."</td>";
}
else { $stateString .= "<td>UNKNOWN</td>"; }
} else {
$stateString .= "<td>N/A</td>";
}
}
if(($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') && $atype eq "VirtualCenter") {
if($local_host->runtime->dasHostState) {
$stateString .= "<td>".$local_host->runtime->dasHostState->state."</td>";
} else {
$stateString .= "<td>N/A</td>";
}
} else {
$stateString .= "<td>N/A</td>";
}
$stateString .= "<td>".$local_host->runtime->connectionState->val."</td>";
$stateString .= "<td>".(($local_host->summary->runtime->inMaintenanceMode) ? "YES" : "NO")."</td>";
if($aversion eq '4.1.0' || $aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0' || $hostAPIVersion eq '5.5.0') {
$stateString .= "<td>".(($local_host->runtime->standbyMode) ? $local_host->runtime->standbyMode : "N/A")."</td>";
} else {
$stateString .= "<td>N/A</td>";
}
}
$stateString .= "<td>".(($local_host->summary->config->vmotionEnabled) ? "YES" : "NO")."</td>";
$stateString .= "<td>".${$local_host->summary->config->product}{'fullName'}."</td>";
$stateString .= "</tr>\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 .= "<tr><th align=\"left\">".$host_name."</th></tr>\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="<td bgcolor=\"$green\">OK</td>"; }
elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
$healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";
}
}
if($hardwareStatusInfo->memoryStatusInfo) {
$memInfo = $hardwareStatusInfo->memoryStatusInfo;
foreach(@$memInfo) {
$sensor_health = $_->status->key;
if ($sensor_health =~ m/green/i) { $sensor_health_color="<td bgcolor=\"$green\">OK</td>"; }
elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
$healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";
}
}
if($hardwareStatusInfo->storageStatusInfo) {
$storageInfo = $hardwareStatusInfo->storageStatusInfo;
foreach(@$storageInfo) {
$sensor_health = $_->status->key;
if ($sensor_health =~ m/green/i) { $sensor_health_color="<td bgcolor=\"$green\">OK</td>"; }
elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
$healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";
}
}
}
if($local_host->runtime->healthSystemRuntime->systemHealthInfo) {
my $sensors = $local_host->runtime->healthSystemRuntime->systemHealthInfo->numericSensorInfo;
$healthSoftwareString .= "<tr><th align=\"left\">".$host_name."</th></tr>\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="<td bgcolor=\"$green\">OK</td>"; }
elsif ($sensor_health_color =~ m/red/) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
elsif ($sensor_health_color =~ m/yellow/) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
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 .= "<tr><td>".$_->name."</td><td>".$reading."</td>".$sensor_health_color."</tr>\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 .= "<tr><td>".$host_name."</td>";
$nicString .= "<td>".$nic->device."</td><td>".$nic->pci."</td><td>".$nic->driver."</td>";
if($nic->linkSpeed) {
$nicString .= "<td>".(($nic->linkSpeed->duplex) ? "FULL DUPLEX" : "HALF-DUPLEX")."</td><td>".$nic->linkSpeed->speedMb." MB</td>";
} else {
$nicString .= "<td>UNKNOWN</td><td>UNKNOWN</td>";
}
$nicString .= "<td>".(($nic->wakeOnLanSupported) ? "YES" : "NO")."</td>";
if($demo eq "no") {
$nicString .= "<td>".$nic->mac."</td></tr>\n";
} else {
$nicString .= "<td>demo_mode</td></tr>\n";
}
}
}
######################
# HBA
######################
if($HOST_HBA eq "yes") {
my $hbas;
eval { $hbas = $local_host->config->storageDevice->hostBusAdapter; };
if(!$@) {
foreach my $hba (@$hbas) {
$hbaString .= "<tr><td>".$host_name."</td>";
if($hba->isa("HostFibreChannelHba")) {
my $hbaType = "FC";
my ($fcfMac,$vnportMac) = ("","");
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.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 .= "<td>".$hbaType."</td><td>".$hba->device."</td><td>".$hba->pci."</td><td>".$hba->model."</td><td>".$hba->driver."</td><td>".$hba->status."</td><td><b>NWWN</b> ".$nwwn."</td><td><b>PWWN</b> ".$pwwn."</td>";
if(($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') && $hbaType eq "FCoE") {
$hbaString .= "<td><b><FCFMAC</b> ".$fcfMac."</td><td><b>VNPORTMAC</b> ".$vnportMac."</td>";
}
$hbaString .= "<td><b>PORT TYPE</b> ".$hba->portType->val."</td><td><b>SPEED</b> ".$hba->speed."</td></td>";
} elsif($hba->isa("HostInternetScsiHba")) {
$hbaString .= "<td>iSCSI</td><td>".$hba->device."</td><td>".$hba->pci."</td><td>".$hba->model."</td><td>".$hba->driver."</td><td>".$hba->status."</td><td>".(($hba->authenticationProperties->chapAuthEnabled) ? "CHAP ENABLED" : "CHAP DISABLED")."</td>";
} elsif($hba->isa("HostParallelScsiHba")) {
$hbaString .= "<td>SCSI</td><td>".$hba->device."</td><td>".$hba->pci."</td><td>".$hba->model."</td><td>".$hba->driver."</td><td>".$hba->status."</td>";
} elsif($hba->isa("HostBlockHba")) {
$hbaString .= "<td>BLOCK</td><td>".$hba->device."</td><td>".$hba->pci."</td><td>".$hba->model."</td><td>".$hba->driver."</td><td>".$hba->status."</td>";
}
$hbaString .= "</tr>\n";
}
}
}
######################
# iSCSI
######################
if($HOST_ISCSI eq "yes" && ($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.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 .= "<tr>";
$iscsiString .= "<td>".$host_name."</td>";
$iscsiString .= "<td>".(defined($iscsiPort->vnicDevice) ? $iscsiPort->vnicDevice : "N/A")."</td>";
if($iscsiPort->vnic->spec->ip->ipAddress) {
$iscsiString .= "<td>".$iscsiPort->vnic->spec->ip->ipAddress."</td>";
} else { $iscsiString .= "<td>N/A</td>"; }
if($iscsiPort->vnic->spec->ip->subnetMask) {
$iscsiString .= "<td>".$iscsiPort->vnic->spec->ip->subnetMask."</td>";
} else { $iscsiString .= "<td>N/A</td>"; }
if($iscsiPort->vnic->spec->mac) {
$iscsiString .= "<td>".$iscsiPort->vnic->spec->mac."</td>";
} else { $iscsiString .= "<td>N/A</td>"; }
if($iscsiPort->vnic->spec->mtu) {
$iscsiString .= "<td>".$iscsiPort->vnic->spec->mtu."</td>";
} else { $iscsiString .= "<td>N/A</td>"; }
if(defined($iscsiPort->vnic->spec->tsoEnabled)) {
$iscsiString .= "<td>".($iscsiPort->vnic->spec->tsoEnabled ? "YES" : "NO")."</td>";
} else { $iscsiString .= "<td>N/A</td>"; }
if($iscsiPort->pnic) {
$iscsiString .= "<td>".$iscsiPort->pnic->linkSpeed->speedMb . " (" . ($iscsiPort->pnic->linkSpeed->duplex ? "FULL-DUPLEX" : "HALF-DUPLEX") . ")"."</td>";
} else { $iscsiString .= "<td>N/A</td>"; }
$iscsiString .= "<td>".(defined($iscsiPort->pnicDevice) ? $iscsiPort->pnicDevice : "N/A")."</td>";
$iscsiString .= "<td>".(defined($iscsiPort->portgroupName) ? $iscsiPort->portgroupName : "N/A")."</td>";
$iscsiString .= "<td>".(defined($iscsiPort->switchName) ? $iscsiPort->switchName : "N/A")."</td>";
$iscsiString .= "<td>".(defined($iscsiPort->switchUuid) ? $iscsiPort->switchUuid : "N/A")."</td>";
$iscsiString .= "<td>".(defined($iscsiPort->pathStatus) ? $iscsiPort->pathStatus : "N/A")."</td>";
$iscsiString .= "</tr>";
}
}
}
}
}
}
######################
# CAPABILITY
######################
if($HOST_CAPABILITY eq "yes") {
if($local_host->capability) {
$capString .= "<tr>";
$capString .= "<td>".$host_name."</td>";
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
## MAX VMS ##
if($local_host->capability->maxHostRunningVms) {
$capString .= "<td>".$local_host->capability->maxHostRunningVms."</td>";
} else { $capString .= "<td>N/A</td>"; }
## MAX VCPU ##
if($local_host->capability->maxHostSupportedVcpus) {
$capString .= "<td>".$local_host->capability->maxHostSupportedVcpus."</td>";
} else { $capString .= "<td>N/A</td>"; }
## VMFS VERSION ##
if($local_host->capability->supportedVmfsMajorVersion) {
$capString .= "<td>".join(",",@{$local_host->capability->supportedVmfsMajorVersion})."</td>";
} else { $capString .= "<td>N/A</td>"; }
}
## FT ##
$capString .= "<td>".($local_host->capability->ftSupported ? "YES" : "NO")."</td>";
## IPMI ##
if($local_host->capability->ipmiSupported) {
$capString .= "<td>".($local_host->capability->ipmiSupported ? "YES" : "NO")."</td>";
} else {
$capString .= "<td>N/A</td>";
}
## TPM ##
$capString .= "<td>".($local_host->capability->tpmSupported ? "YES" : "NO")."</td>";
## HV ##
$capString .= "<td>".($local_host->capability->virtualExecUsageSupported ? "YES" : "NO")."</td>";
if($aversion eq '4.1.0' || $aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0' || $hostAPIVersion eq '5.5.0') {
## STORAGE IORM ##
$capString .= "<td>".($local_host->capability->storageIORMSupported ? "YES" : "NO")."</td>";
## DPG 2 ##
$capString .= "<td>".($local_host->capability->vmDirectPathGen2Supported ? "YES" : "NO")."</td>";
## vStorage ##
$capString .= "<td>".($local_host->capability->vStorageCapable ? "YES" : "NO")."</td>";
} else {
$capString .= "<td>N/A</td>";
$capString .= "<td>N/A</td>";
$capString .= "<td>N/A</td>";
}
}
## SSL THUMBPRINT ##
if($local_host->capability->loginBySSLThumbprintSupported) {
$capString .= "<td>".($local_host->capability->loginBySSLThumbprintSupported ? "YES" : "NO")."</td>";
} else {
$capString .= "<td>N/A</td>";
}
$capString .= "</tr>\n";
}
}
######################
# CONFIGURATIONS
######################
if($HOST_CONFIGURATION eq "yes") {
my $netMgr = Vim::get_view(mo_ref => $local_host->configManager->networkSystem);
$configString .= "\n<table border=\"1\">\n<tr><th colspan=3>".$host_name."</th></tr>\n";
#############
## VMOTION ##
#############
if($HOST_VMOTION eq "yes") {
if($local_host->summary->config->vmotionEnabled) {
$configString .= "<tr><th>VMOTION ENABLED </th><td>YES</td></tr>\n";
if($demo eq "no") {
$configString .= "<tr><th>IP ADDRESS </th><td>".$local_host->config->vmotion->ipConfig->ipAddress." => ".$local_host->summary->config->name."</td></tr>\n";
$configString .= "<tr><th>NETMASK </th><td>".$local_host->config->vmotion->ipConfig->subnetMask."</td></tr>\n";
} else {
$configString .= "<tr><th>IP ADDRESS </th><td>X.X.X.X</td></tr>\n";
$configString .= "<tr><th>NETMASK </th><td>X.X.X.X</td></tr>\n";
}
}
}
#############
## GATEWAY ##
#############
if($HOST_GATEWAY eq "yes") {
if($demo eq "no") {
if($netMgr->consoleIpRouteConfig) {
if($netMgr->consoleIpRouteConfig->defaultGateway) {
$configString .= "<tr><th>GATEWAY </th><td>".$netMgr->consoleIpRouteConfig->defaultGateway."</td></tr>\n";
} else {
$configString .= "<tr><th>GATEWAY </th><td>0.0.0.0</td></tr>\n";
}
if($netMgr->consoleIpRouteConfig->ipV6DefaultGateway) {
$configString .= "<tr><th>IPv6 GATEWAY </th><td>".$netMgr->consoleIpRouteConfig->ipV6DefaultGateway."</td></tr>\n";
} else {
$configString .= "<tr><th>IPv6 GATEWAY </th><td>0.0.0.0</td></tr>\n";
}
} else {
$configString .= "<tr><th>GATEWAY </th><td>N/A</td></tr>\n";
$configString .= "<tr><th>IPv6 GATEWAY </th><td>N/A</td></tr>\n";
}
if($netMgr->ipRouteConfig->defaultGateway) {
$configString .= "<tr><th>VMKERNEL GATEWAY </th><td>".$netMgr->ipRouteConfig->defaultGateway."</td></tr>\n";
} else {
$configString .= "<tr><th>VMKERNEL GATEWAY </th><td>0.0.0.0</td></tr>\n";
}
if($netMgr->ipRouteConfig->ipV6DefaultGateway) {
$configString .= "<tr><th>VMKERNEL IPv6 GATEWAY </th><td>".$netMgr->ipRouteConfig->ipV6DefaultGateway."</td></tr>\n";
} else {
$configString .= "<tr><th>VMKERNEL IPv6 GATEWAY </th><td>0.0.0.0</td></tr>\n";
}
} else {
$configString .= "<tr><th>GATEWAY </th><td>X.X.X.X</td></tr>\n";
}
}
#####################
## SOFTWARE iSCSI ##
#####################
if($HOST_ISCSI eq "yes") {
$configString .= "<tr><th>SOFTWAE iSCSI ENABLED</th><td>".($local_host->config->storageDevice->softwareInternetScsiEnabled ? "YES" : "NO")."</td></tr>\n";
}
#############
## IPV6 ##
#############
if($HOST_IPV6 eq "yes") {
$configString .= "<tr><th>IPv6 ENABLED</th><td>".($local_host->config->network->ipV6Enabled ? "YES" : "NO")."</td></tr>\n";
}
#############
# FT ##
#############
if($HOST_FT eq "yes") {
$configString .= "<tr><th>FT ENABLED</th><td>".($local_host->summary->config->faultToleranceEnabled ? "YES" : "NO")."</td></tr>\n";
}
#############
# SSL ##
#############
if($HOST_SSL eq "yes") {
$configString .= "<tr><th>SSL THUMBPRINT</th><td>".($local_host->summary->config->sslThumbprint ? $local_host->summary->config->sslThumbprint : "N/A")."</td></tr>\n";
}
#############
## DNS ##
#############
if($HOST_DNS eq "yes") {
my $searchDomains = $local_host->config->network->dnsConfig->searchDomain;
my $searchString = "";
foreach(@$searchDomains) {
$searchString .= "search ".$_."<br/>";
}
my $dnsAddress = $local_host->config->network->dnsConfig->address;
my $dnsString = "";
foreach(@$dnsAddress) {
$dnsString .= "nameserver ".$_."<br/>";
}
if($demo eq "no") {
$configString .= "<tr><th>DNS</th><td>"."domain ".($local_host->config->network->dnsConfig->domainName ? $local_host->config->network->dnsConfig->domainName : "N/A")."<br/>".$searchString.$dnsString."</td></tr>\n";
} else {
$configString .= "<tr><th>DNS</th><td>domain demo_mode<br/>search demo_mode<br/>nameserver demo_mode</td></tr>\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 .= "<tr><th>UPTIME</th><td>".&days_between($host_date, $todays_date)." Days - ".$local_host->runtime->bootTime."</td></tr>\n";
}
#################
## DIAGONISTIC ##
#################
if($HOST_DIAGONISTIC eq "yes") {
if($local_host->config->activeDiagnosticPartition) {
my $diag_string .= "<tr><td>".$local_host->config->activeDiagnosticPartition->diagnosticType."</td><td>".$local_host->config->activeDiagnosticPartition->id->diskName.$local_host->config->activeDiagnosticPartition->id->partition."</td><td>".$local_host->config->activeDiagnosticPartition->storageType."</td></tr>";
$configString .= "<tr><th>DIAGNOSTIC PARTITION</th><td><table border=\"1\" width=100%><tr><th>TYPE</th><th>PARITION</th><th>STORAGE TYPE</th></tr>".$diag_string."</table></td></tr>\n";
}
}
###################
## AUTH SERVICES ##
###################
if($HOST_AUTH_SERVICE eq "yes" && $hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0' || $hostAPIVersion eq '5.5.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 .= $_ . "<br/>";
}
} else {
$trustedDomains = "N/A";
}
}
$authString .= "<tr><td>".$authType."</td><td>".$authEnabled."</td><td>".$authStatus."</td><td>".$authDomain."</td><td>".$trustedDomains."</td></tr>";
}
$configString .= "<tr><th>AUTHENTICATION SERVICE(s)</th><td><table border=\"1\" width=100%><tr><th>AUTH TYPE</th><th>ENABLED</th><th>STATUS</th><th>DOMAIN</th><th>TRUSTED DOMAIN</th></tr>".$authString."</table></td></tr>\n";
}
}
###############
## SERVICES ##
###############
if($HOST_SERVICE eq "yes") {
my $services = $local_host->config->service->service;
if($services) {
my $serviceString = "";
foreach(@$services) {
$serviceString .= "<tr><td>".$_->label."</td>";
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
if($_->sourcePackage) {
$serviceString .= "<td>".$_->sourcePackage->sourcePackageName."</td>";
} else { $serviceString .= "<td>N/A</td>"; }
}
$serviceString .= "<td>".$_->policy."</td><td>".(($_->running) ? "YES" : "NO")."</td></tr>";
}
if($aversion eq '5.0.0' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
$configString .= "<tr><th>SERVICE(s)</th><td><table border=\"1\" width=100%><tr><th>NAME</th><th>SOURCE PACKAGE</ah><th>POLICY TYPE</th><th>RUNNING</th></tr>".$serviceString."</table></td></tr>\n";
} else {
$configString .= "<tr><th>SERVICE(s)</th><td><table border=\"1\" width=100%><tr><th>NAME</th><th>POLICY TYPE</th><th>RUNNING</th></tr>".$serviceString."</table></td></tr>\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 .= "$_<br/>";
}
} else { $ntpString = "NONE CONFIGURED"; }
$ntpString = "<tr><td>".$ntpString."</td>";
$ntpString .= "<td>".$local_host->config->dateTimeInfo->timeZone->description."</td><td>".$local_host->config->dateTimeInfo->timeZone->gmtOffset."</td><td>".$local_host->config->dateTimeInfo->timeZone->name."</td></tr>";
$configString .= "<tr><th>NTP</th><td><table border=\"1\" width=100%><tr><th>NTP SERVERS</th><th>TIME ZONE</th><th>GMT OFFSET</th><th>LOCATION</th></tr>".$ntpString."</table></td></tr>\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 .= "<tr><td>".$_->device."</td><td>".$_->portgroup."</td><td>".$_->spec->ip->ipAddress."</td><td>".$_->spec->ip->subnetMask."</td><td>".$_->spec->mac."</td><td>".(($_->spec->ip->dhcp) ? "YES" : "NO")."</td></tr>";
} else {
$vswifString .= "<tr><td>".$_->device."</td><td>demo_mode</td><td>X.X.X.X</td><td>X.X.X.X</td><td>demo_mode</td><td>".(($_->spec->ip->dhcp) ? "YES" : "NO")."</td></tr>";
}
}
$configString .= "<tr><th>VSWIF(s)</th><td><table border=\"1\" width=100%><tr><th>NAME</th><th>PORTGROUP</th><th>IP ADDRESS</th><th>NETMASK</th><th>MAC</th><th>DHCP</th></tr>".$vswifString."</table></td></tr>\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 .= "<tr><td>".$_->device."</td><td>".$_->portgroup."</td><td>".$_->spec->ip->ipAddress."</td><td>".$_->spec->ip->subnetMask."</td><td>".$_->spec->mac."</td><td>".(($_->spec->ip->dhcp) ? "YES" : "NO")."</td></tr>";
} else {
$vmkString .= "<tr><td>".$_->device."</td><td>demo_mode</td><td>X.X.X.X</td><td>X.X.X.X</td><td>X.X.X.X</td><td>".(($_->spec->ip->dhcp) ? "YES" : "NO")."</td></tr>";
}
}
$configString .= "<tr><th>VMKERNEL(s)</th><td><table border=\"1\" width=100%><tr><th>INTERFACE</th><th>PORTGROUP</th><th>IP ADDRESS</th><th>NETMASK</th><th>MAC</th><th>DHCP</th></tr>".$vmkString."</table></td></tr>\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 .= "<tr><th>VSWITCH NAME</th><th>NUM OF PORTS</th><th>USED PORTS</th><th>MTU</th><th>UPLINKS</th><th>CDP ENABLED</th></tr><tr><td>".$vSwitch->name."</td><td>".$vSwitch->numPorts."</td><td>".($vSwitch->numPorts - $vSwitch->numPortsAvailable)."</td><td>".$mtu."</td><td>".$pNicName."</td><td>".$cdp_vswitch."</td></tr>\n";
$vswitchString .= "<tr><th>PORTGROUP NAME</th><th>VLAN ID</th><th>USED PORTS</th><th colspan=3>UPLINKS</th></tr>\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 .= "<tr><td>".$pg->spec->name."</td><td>".$pg->spec->vlanId."</td><td>".$usedPorts."</td><td colspan=3>".$pNicName."</td></tr>\n";
} else {
$vswitchString .= "<tr><td>demo_mode</td><td>demo_mode</td><td>".$usedPorts."</td><td colspan=3>".$pNicName."</td></tr>\n";
}
$vswitch_portgroup_mappping{$pg->spec->name} = $vswitch_name;
}
}
$configString .= "<tr><th>VSWITCH(s)</th><td><table border=\"1\">".$vswitchString."</table></td></tr>\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(defined($snmp_system->configuration)) {
if($snmp_system->configuration->enabled) {
my $snmpString = "";
$snmpString .= "<tr><td>".$snmp_system->configuration->port."</td><td>";
my $ro_community = $snmp_system->configuration->readOnlyCommunities;
foreach(@$ro_community) {
$snmpString .= $_ . ", ";
}
$snmpString .= "</td><td>";
my $trap_targets = $snmp_system->configuration->trapTargets;
foreach(@$trap_targets) {
$snmpString .= "<b>Community:</b> " . $_->community . " <b>Hostname:</b> " . $_->hostName . " <b>Port:</b> " . $_->port . "<br/>\n";
}
$snmpString .= "</td></tr>";
$configString .= "<tr><th>SNMP</th><td><table border=\"1\" width=100%><tr><th>SNMP PORT</th><th>RO COMMUNITIES</th><th>TRAP TARGETS</th></tr>".$snmpString."</table></td></tr>\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' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
if(defined($rule->allowedHosts)) {
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' || $aversion eq '5.1.0' || $aversion eq '5.5.0' || $aversion eq '6.0.0' || $aversion eq '6.5.0') {
$fwPortType = $_->portType ? uc($_->portType->val) : "N/A";
}
$fwProto = $_->protocol;
$fw_known_string .= "<tr><td>".$rule->label."</td><td>".$fwDirection."</td><td>".$fwPortType."</td><td>".$fwPort."</td><td>".$fwProto."</td><td>".$allowedIPs."</td></tr>\n";
}
}
}
$configString .= "<tr><th>FIREWALL<br/> KNOWN SERVICES ENABLED</th><td><table border=\"1\" width=100%><tr><th>LABEL</th><th>DIRECTION</th><th>PORT TYPE</th><th>PORT</th><th>PROTOCOL</th><th>ALLOWED IPS</th>".$fw_known_string."</table></td></tr>\n";
my $defaultPolicy = "<tr><td>".($fw_sys->defaultPolicy->incomingBlocked ? "YES" : "NO")."</td><td>".($fw_sys->defaultPolicy->outgoingBlocked ? "YES" : "NO")."</td></tr>\n";
$configString .= "<tr><th>FIREWALL POLICY</th><td><table border=\"1\" width=100%><tr><th>INCOMING ENABLED</th><th>OUTGOING ENABLED</th></tr>".$defaultPolicy."</table></td></tr>\n";
}
}
###########
## POWER ##
###########
if($HOST_POWER eq "yes") {
if($local_host->hardware->cpuPowerManagementInfo) {
my $cpu_power_info = "";
$cpu_power_info .= "<tr><td>".($local_host->hardware->cpuPowerManagementInfo->currentPolicy)."</td><td>".($local_host->hardware->cpuPowerManagementInfo->hardwareSupport)."</td></tr>";
$configString .= "<tr><th>CPU POWER MGMT INFO</th><td><table border=\"1\" width=100%><tr><th>CURRENT POLICY</th><th>HARDWARE SUPPORT</th></tr>".$cpu_power_info."</table></td></tr>\n";
}
}
######################
# FEATURE VERSION
######################
if($HOST_FEATURE_VERSION eq "yes" && $hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0' || $hostAPIVersion eq '5.5.0') {
if($local_host->summary->config->featureVersion) {
my $featurever = $local_host->summary->config->featureVersion;
my $featureString = "";
foreach(@$featurever) {
$featureString .= "<tr><td>".$_->key."</td><td>".$_->value."</td></tr>\n";
}
$configString .= "<tr><th>FEATURE VERSION</th><td><table border=\"1\" width=100%><tr><th>FEATURE</th><th>VERSION</th></tr>".$featureString."</table></td></tr>\n";
}
}
$configString .= "</table>\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 .= "<tr>";
$advString .= "<td>".$host_name."</td>";
$advString .= "<td>".$diskUDR."</td>";
$advString .= "<td>".$diskULR."</td>";
$advString .= "<td>".$diskSNRO."</td>";
$advString .= "<td>".$scsiCR."</td>";
$advString .= "<td>".$nfsMV."</td>";
$advString .= "<td>".$SBS."</td>";
$advString .= "<td>".$RBS."</td>";
$advString .= "<td>".$netTHS."</td>";
$advString .= "<td>".$nfsHF."</td>";
$advString .= "<td>".$nfsHT."</td>";
$advString .= "<td>".$nfsHMF."</td>";
$advString .= "<td>".$vmkernelBSM."</td>";
$advString .= "<td>".$vmfs3HAL."</td>";
$advString .= "<td>".$dataMHAM."</td>";
$advString .= "<td>".$dataMHAI."</td>";
$advString .= "</tr>\n";
}
######################
# HOST AGENT SETTING
######################
if($HOST_AGENT eq "yes" && $atype eq "VirtualCenter" && $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0' || $hostAPIVersion eq '5.5.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 .= "<tr>";
$agentString .= "<td>".$host_name."</td>";
$agentString .= "<td>".$agentDSName."</td>";
$agentString .= "<td>".$agentNetName."</td>";
$agentString .= "</tr>\n";
}
}
}
######################
# NUMA
######################
if($HOST_NUMA eq "yes") {
if($local_host->hardware->numaInfo) {
my $numaInfo = $local_host->hardware->numaInfo;
if($numaInfo->numNodes == 0) {
$numaString .= "<tr><td>".$host_name."</td><td>NUMA-incapable</td><td>".$numaInfo->type."</td><td>N/A</td>";
} else {
$numaString .= "<tr><td>".$host_name."</td><td>".$numaInfo->numNodes."</td><td>".$numaInfo->type."</td><td>";
if($numaInfo->numaNode) {
my $nodes = $numaInfo->numaNode;
$numaString .= "<table border=\"1\"><tr><th>NODE ID</th><th>CPU ID</th><th>MEM RANGE BEGIN</th><th>MEM RANGE LENGTH</th></tr>";
foreach(@$nodes) {
my $cpuID = $_->cpuID;
my $idString = "";
foreach(@$cpuID) {
$idString = $_ . " " . $idString;
}
$numaString .= "<tr><td>".$_->typeId."</td><td>&nbsp;[".$idString."]&nbsp;</td><td>".&prettyPrintData($_->memoryRangeBegin,'B')."</td><td>".&prettyPrintData($_->memoryRangeLength,'B')."</td></tr>";
}
$numaString .= "</table>";
} else {
$numaString .= "N/A</td>"
}
$numaString .= "<tr>\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,