hyperbart

Modified script for vCenter 5.5

Jan 28th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 272.85 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. # Copyright (c) 2009-2010 William Lam All rights reserved.
  4.  
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. # 1. Redistributions of source code must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. #    notice, this list of conditions and the following disclaimer in the
  12. #    documentation and/or other materials provided with the distribution.
  13. # 3. The name of the author or contributors may not be used to endorse or
  14. #    promote products derived from this software without specific prior
  15. #    written permission.
  16. # 4. Consent from original author prior to redistribution
  17.  
  18. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
  19. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  22. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. # SUCH DAMAGE.
  29.  
  30. ##################################################################
  31. # Author: William Lam
  32. # 03/03/2010
  33. # http://www.virtuallyghetto.com
  34. ##################################################################
  35. use strict;
  36. use warnings;
  37. use Math::BigInt;
  38. use Tie::File;
  39. use POSIX qw/mktime/;
  40. use Socket;
  41. use Getopt::Long;
  42. use POSIX qw(ceil floor);
  43. use VMware::VIRuntime;
  44. use VMware::VILib;
  45. use Net::SMTP;
  46.  
  47. ########### DO NOT MODIFY PAST HERE ###########
  48.  
  49. ################################
  50. # VERSION
  51. ################################
  52. my $version = "5.5.0";
  53. $Util::script_version = $version;
  54.  
  55. my @supportedVersion = qw(4.0.0 4.1.0 5.0.0 5.1.0 5.5.0);
  56.  
  57. my %opts = (
  58.     cluster => {
  59.         type => "=s",
  60.             help => "The name of a vCenter cluster to query",
  61.             required => 0,
  62.         },
  63.         datacenter => {
  64.             type => "=s",
  65.             help => "The name of a vCenter datacenter to query",
  66.             required => 0,
  67.         },
  68.     hostlist => {
  69.                 type => "=s",
  70.                 help => "File containting list of ESX/ESXi host(s) to query",
  71.                 required => 0,
  72.         },
  73.     vmlist => {
  74.                 type => "=s",
  75.                 help => "File containting list of VM(s) to query",
  76.                 required => 0,
  77.         },
  78.         type => {
  79.             type => "=s",
  80.             help => "Type: [vcenter|datacenter|cluster|host]\n",
  81.             required => 1,
  82.         },
  83.         report => {
  84.             type => "=s",
  85.             help => "The name of the report to output. Please add \".html\" extension",
  86.             required => 0,
  87.         default => "vmware_health_report.html",
  88.         },
  89.         logcount => {
  90.             type => "=s",
  91.             help => "The number of lines to output from hostd logs",
  92.             required => 0,
  93.         default => 15,
  94.         },
  95.         vmperformance => {
  96.             type => "=s",
  97.             help => "Enable VM Performance gathering [yes|no] (Can potentially double your runtime)",
  98.             required => 0,
  99.             default => "no",
  100.         },
  101.         hostperformance => {
  102.             type => "=s",
  103.             help => "Enable Host Performance gathering [yes|no] (Can potentially increase your runtime)",
  104.             required => 0,
  105.             default => "no",
  106.         },
  107.         clusterperformance => {
  108.             type => "=s",
  109.             help => "Enable Cluster Performance gathering [yes|no] (Can potentially increase your runtime)",
  110.             required => 0,
  111.             default => "no",
  112.         },
  113.         email => {
  114.             type => "=s",
  115.             help => "[yes|no]",
  116.             required => 0,
  117.             default => "no",
  118.         },
  119.     demo => {
  120.                 type => "=s",
  121.                 help => "[yes|no]",
  122.                 required => 0,
  123.                 default => "no",
  124.         },
  125.     conf => {
  126.                 type => "=s",
  127.                 help => "File containing Host and VM specific configurations to output",
  128.                 required => 0,
  129.         },
  130.     printerfriendly => {
  131.                 type => "=s",
  132.                 help => "Whether the html output will be printer friendly [yes|no]",
  133.                 required => 0,
  134.         default => "no",
  135.         },
  136.     debug  => {
  137.                 type => "=s",
  138.                 help => "Enable/Disable debugging to help William troubleshot [0|1]",
  139.         required => 0,
  140.     },
  141. );
  142.  
  143. # validate options, and connect to the server
  144. Opts::add_options(%opts);
  145.  
  146. # validate options, and connect to the server
  147. Opts::parse();
  148. Opts::validate();
  149. Util::connect();
  150.  
  151. ###############
  152. # GLOBAL VARS
  153. ###############
  154.  
  155. 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);
  156. my (@vmw_apps,@perf_host_list,@vms_perf,@hosts_in_cluster,@portgroups_in_cluster,@hosts_seen,@datastores_seen,@hosts_in_portgroups,@dvs,@vmsnapshots,@vmdeltas) = ();
  157. my (%hostlists,%vmlists,%configurations,%vmmac_to_portgroup_mapping,%vswitch_portgroup_mappping,%lun_row_info,%luns,%datastore_row_info,%datastores,%portgroup_row_info,%seen_dvs) = ();
  158. 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) = ("","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","");
  159. my (@datastore_cluster_jump_tags,@cluster_jump_tags,@host_jump_tags,@vm_jump_tags) = ();
  160.  
  161. ###############
  162. # COLORS
  163. ###############
  164. my $green = "#00FF00";
  165. my $red = "#FF0000";
  166. my $orange = "#FF6600";
  167. my $yellow = "#FFFF33";
  168. my $white = "#FFFFFF";
  169. my $light_green = "#66FF99";
  170. my $light_red = "#FF6666";
  171.  
  172. ############################
  173. # PARSE COMMANDLINE OPTIONS
  174. #############################
  175.  
  176. $system_name = Opts::get_option('server');
  177. $report = Opts::get_option('report');
  178. $demo = Opts::get_option('demo');
  179. $email = Opts::get_option('email');
  180. $logcount = Opts::get_option('logcount');
  181. $vmperformance = Opts::get_option('vmperformance');
  182. $hostperformance = Opts::get_option('hostperformance');
  183. $clusterperformance = Opts::get_option('clusterperformance');
  184. $type = Opts::get_option('type');
  185. $clusterInput = Opts::get_option('cluster');
  186. $datacenterInput = Opts::get_option('datacenter');
  187. $conf = Opts::get_option('conf');
  188. $hostlist = Opts::get_option('hostlist');
  189. $vmlist = Opts::get_option('vmlist');
  190. $printerfriendly = Opts::get_option('printerfriendly');
  191. $debug = Opts::get_option('debug');
  192.  
  193. ##########################
  194. # DEFAULT CONFIGUFRATION
  195. ##########################
  196. my $EMAIL_HOST = 'emailserver';
  197. my $EMAIL_DOMAIN = 'localhost.localdomain';
  198. my @EMAIL_TO = 'william@primp-industries.com.com,tuan@primp-industries.com';
  199. my $EMAIL_FROM = 'vMA@primp-industries.com';
  200. my $YELLOW_WARN = 30;
  201. my $ORANGE_WARN = 15;
  202. my $RED_WARN = 10;
  203. my $SNAPSHOT_YELLOW_WARN = 15;
  204. my $SNAPSHOT_ORANGE_WARN = 30;
  205. my $SNAPSHOT_RED_WARN = 60;
  206. my $SYSTEM_LICENSE="yes";
  207. my $SYSTEM_FEATURE="yes";
  208. my $SYSTEM_PERMISSION="yes";
  209. my $SYSTEM_SESSION="yes";
  210. my $SYSTEM_HOST_PROFILE="yes";
  211. my $SYSTEM_PLUGIN="yes";
  212. my $DVS_SUMMARY="yes";
  213. my $DVS_CAPABILITY="yes";
  214. my $DVS_CONFIG="yes";
  215. my $DATASTORE_CLUSTER_SUMMARY="yes";
  216. my $DATASTORE_CLUSTER_POD_CONFIG="yes";
  217. my $DATASTORE_CLUSTER_POD_ADV_CONFIG="yes";
  218. my $DATASTORE_CLUSTER_POD_STORAGE="yes";
  219. my $CLUSTER_SUMMARY="yes";
  220. my $CLUSTER_PERFORMANCE="no";
  221. my $CLUSTER_HA="yes";
  222. my $CLUSTER_DRS="yes";
  223. my $CLUSTER_DPM="yes";
  224. my $CLUSTER_AFFINITY="yes";
  225. my $CLUSTER_GROUP="yes";
  226. my $CLUSTER_RP="yes";
  227. my $CLUSTER_VAPP="yes";
  228. my $HOST_HARDWARE_CONFIGURATION="yes";
  229. my $HOST_MGMT="yes";
  230. my $HOST_STATE="yes";
  231. my $HOST_HEALTH="yes";
  232. my $HOST_PERFORMANCE="no";
  233. my $HOST_NIC="yes";
  234. my $HOST_HBA="yes";
  235. my $HOST_CAPABILITY="yes";
  236. my $HOST_CONFIGURATION="yes";
  237. my $HOST_VMOTION="yes";
  238. my $HOST_GATEWAY="yes";
  239. my $HOST_ISCSI="yes";
  240. my $HOST_IPV6="yes";
  241. my $HOST_FT="yes";
  242. my $HOST_SSL="yes";
  243. my $HOST_DNS="yes";
  244. my $HOST_UPTIME="yes";
  245. my $HOST_DIAGONISTIC="yes";
  246. my $HOST_AUTH_SERVICE="yes";
  247. my $HOST_SERVICE="yes";
  248. my $HOST_NTP="yes";
  249. my $HOST_VSWIF="yes";
  250. my $HOST_VMKERNEL="yes";
  251. my $HOST_VSWITCH="yes";
  252. my $HOST_SNMP="yes";
  253. my $HOST_FIREWALL="yes";
  254. my $HOST_POWER="yes";
  255. my $HOST_FEATURE_VERSION="yes";
  256. my $HOST_ADVOPT="yes";
  257. my $HOST_AGENT="yes";
  258. my $HOST_NUMA="yes";
  259. my $HOST_CDP="yes";
  260. my $HOST_DVS="yes";
  261. my $HOST_LUN="yes";
  262. my $HOST_DATASTORE="yes";
  263. my $HOST_CACHE="yes";
  264. my $HOST_MULTIPATH="yes";
  265. my $HOST_PORTGROUP="yes";
  266. my $HOST_LOG="yes";
  267. my $HOST_TASK="yes";
  268. my $VM_STATE = "yes";
  269. my $VM_CONFIG="yes";
  270. my $VM_STATS="yes";
  271. my $VM_RESOURCE_ALLOCATION="yes";
  272. my $VM_PERFORMANCE="no";
  273. my $VM_FT="yes";
  274. my $VM_EZT="yes";
  275. my $VM_THIN="yes";
  276. my $VM_DEVICE="yes";
  277. my $VM_STORAGE="yes";
  278. my $VM_NETWORK="yes";
  279. my $VM_SNAPSHOT="yes";
  280. my $VM_DELTA="yes";
  281. my $VM_CDROM="yes";
  282. my $VM_FLOPPY="yes";
  283. my $VM_RDM="yes";
  284. my $VM_NPIV="yes";
  285. my $VM_TOOL="yes";
  286. my $VMW_APP="yes";
  287. my $VPX_SETTING="yes";
  288.  
  289. ############################
  290. # START OF SCRIPT
  291. ############################
  292.  
  293. ($service_content,$hostType,$apiType,$apiVersion) = &getServiceInfo();
  294.  
  295. &validateSystem($apiVersion);
  296. &processOptions($type,$apiType,$conf);
  297. &processAdditionalConf();
  298. &startReport();
  299. &startBody($apiType,$apiVersion);
  300. &getSystemSummary($service_content,$hostType,$apiType,$apiVersion);
  301. &getCluster($type,$apiType,$apiVersion);
  302. &getDatastoreCluster($type,$apiType,$apiVersion,$service_content);
  303. &getHost($type,$apiType,$apiVersion,$service_content);
  304. &getVM($type,$apiType,$apiVersion,$service_content);
  305. &getVPXSettings($VPX_SETTING,$apiType,$service_content);
  306. &getVMwareApps($VMW_APP,$apiType,$service_content);
  307. &endBody();
  308. &endReport();
  309. &emailReport();
  310.  
  311. ############################
  312. # END OF SCRIPT
  313. ############################
  314.  
  315. Util::disconnect();
  316.  
  317. #####################
  318. # HELPER FUNCTIONS
  319. #####################
  320.  
  321. sub emailReport {
  322.     if($email eq "yes") {
  323.         my $smtp = Net::SMTP->new($EMAIL_HOST ,Hello => $EMAIL_DOMAIN,Timeout => 30,);
  324.        
  325.         unless($smtp) {
  326.                     die "Error: Unable to setup connection with email server: \"" . $EMAIL_HOST . "\"!\n";
  327.             }
  328.  
  329.         open(DATA, $report) || die("Could not open the file");
  330.         my @report = <DATA>;
  331.         close(DATA);
  332.  
  333.         my @EMAIL_RECIPIENTS = $smtp->recipient(@EMAIL_TO,{SkipBad => 1});
  334.  
  335.         my $boundary = 'frontier';
  336.  
  337.             $smtp->mail($EMAIL_FROM);
  338.             $smtp->to(@EMAIL_TO);
  339.             $smtp->data();
  340.             $smtp->datasend('From: '.$EMAIL_FROM."\n");
  341.             $smtp->datasend('To: '.@EMAIL_TO."\n");
  342.             $smtp->datasend('Subject: VMware vSphere Health Check Report Completed - '.giveMeDate('MDYHMS'). " (" . $system_name . ")\n");
  343.             $smtp->datasend("MIME-Version: 1.0\n");
  344.             $smtp->datasend("Content-type: multipart/mixed;\n\tboundary=\"$boundary\"\n");
  345.             $smtp->datasend("\n");
  346.             $smtp->datasend("--$boundary\n");
  347.             $smtp->datasend("Content-type: text/plain\n");
  348.             $smtp->datasend("Content-Disposition: quoted-printable\n");
  349.             $smtp->datasend("\nReport $report is attached!\n");
  350.             $smtp->datasend("--$boundary\n");
  351.             $smtp->datasend("Content-Type: application/text; name=\"$report\"\n");
  352.             $smtp->datasend("Content-Disposition: attachment; filename=\"$report\"\n");
  353.             $smtp->datasend("\n");
  354.         $smtp->datasend("@report\n");
  355.             $smtp->datasend("--$boundary--\n");
  356.             $smtp->dataend();
  357.             $smtp->quit;
  358.     }
  359. }
  360.  
  361. sub getServiceInfo {
  362.     my $sc = Vim::get_service_content();
  363.     # service content
  364.     # esx,embeddedEsx,gsx,vpx
  365.     # HostAgent,VirtualCenter
  366.     # 4.0.0
  367.     return ($sc,$sc->about->productLineId,$sc->about->apiType,$sc->about->version);
  368. }
  369.  
  370. sub getSystemSummary {
  371.     my ($sc,$htype,$atype,$aversion) = @_;
  372.  
  373.     my $summary_start = "<div id=\"tab1\" class=\"content\">\n";
  374.  
  375.     ###########################
  376.     # SYSTEM BUILD INFO
  377.     ###########################
  378.  
  379.     if($atype eq 'VirtualCenter') {
  380.         $summary_start .= "<h2>VMware vCenter System Summary</h2>"
  381.     } else {
  382.         if($htype eq 'esx') {
  383.             $summary_start .= "<h2>VMware ESX System Summary</h2>"
  384.         }elsif($htype eq 'embeddedEsx') {
  385.             $summary_start .= "<h2>VMware ESXi System Summary</h2>"
  386.         }
  387.     }  
  388.  
  389.     $summary_start .= "\n<table border=\"1\">\n";
  390.     $summary_start .= "<tr><th>FULL NAME</th><th>VCENTER SERVER</th><th>INSTANCE UUID</th></tr>\n";
  391.     $summary_start .= "<tr><td>".$sc->about->fullName."</td><td>$system_name</td><td>".$sc->about->instanceUuid."</td></tr>\n";
  392.     $summary_start .= "</table>\n";
  393.  
  394.     ###########################
  395.     # LICENSE
  396.     ###########################
  397.     my ($features,$feature_string,$feature_info_string) = ("","","");
  398.  
  399.     if($SYSTEM_LICENSE eq "yes") {
  400.         my $licenseMgr = Vim::get_view (mo_ref => $sc->licenseManager);
  401.  
  402.         $summary_start .= "<h3>Licenses:</h3>\n";
  403.         $summary_start .= "<table border=\"1\">\n";
  404.         $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";
  405.  
  406.         my $licenses = $licenseMgr->licenses;
  407.         foreach(@$licenses) {
  408.             if($demo eq "no") {
  409.                 $summary_start .= "<tr><td>".$_->name."</td><td>".$_->editionKey."</td><td>".$_->licenseKey."</td><td>".$_->costUnit."</td><td>".$_->total."</td><td>".$_->used."</td><td>".($_->total - $_->used)."</td></tr>\n";
  410.                 my $licenseProperties = $_->properties;
  411.                 if($licenseProperties) {
  412.                     $feature_info_string .= "<tr><th>EDITION w/FEATURES</th><th>EXPIRATION (HOURS)</th><th>EXPIRATION (MINS)</th><th>EXPIRATION DATE</th></tr>\n";
  413.                     $feature_info_string .= "<tr><td><b>".$_->editionKey."</b></td>\n";
  414.                 }  
  415.                 foreach(@$licenseProperties) {
  416.                     if($_->key ne 'feature') {
  417.                                         if($_->key eq 'expirationHours' ) { $feature_info_string .= "<td>".$_->value."</td>"; }
  418.                                         if($_->key eq 'expirationMinutes' ) { $feature_info_string .= "<td>".$_->value."</td>"; }
  419.                                         if($_->key eq 'expirationDate' ) { $feature_info_string .= "<td>".$_->value."</td></tr>\n"; }
  420.                     } else {
  421.                         my $feature = $_->value;
  422.                         $features .= "<tr><td>".$feature->value."</td></tr>\n";
  423.                     }
  424.                 }
  425.             } else {
  426.                             $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";
  427.                     }
  428.             $feature_string .= $feature_info_string . $features;
  429.             ($features,$feature_info_string) = ("","");
  430.         }
  431.         $summary_start .= "</table>\n";
  432.     }
  433.  
  434.     ###########################
  435.     # FEATURES
  436.     ###########################
  437.     if($SYSTEM_FEATURE eq "yes" && $SYSTEM_LICENSE eq "yes") {
  438.         $summary_start .= "<h3>Features:</h3>\n";
  439.         $summary_start .= "<table border=\"1\">\n";
  440.    
  441.         if($demo eq "no") {
  442.             $summary_start .= $feature_string; 
  443.         } else {
  444.             $summary_start .= "<tr><td>DEMO_MODE</td></tr>\n";
  445.         }
  446.         $summary_start .= "</table>\n";
  447.     }
  448.  
  449.     ###########################
  450.     # PERMISSIONS
  451.     ###########################
  452.     if($SYSTEM_PERMISSION eq "yes") {  
  453.         $summary_start .= "<h3>Permissions:</h3>\n";
  454.         $summary_start .= "<table border=\"1\">\n";
  455.         $summary_start .= "<tr><th>USER/GROUP</th><th>ROLE</th><th>DEFINED IN</th><th>PROPAGATE</th><th>IS GROUP</th></tr>\n";
  456.    
  457.         my $authMgr = Vim::get_view (mo_ref => $sc->authorizationManager);
  458.         my $roleLists = $authMgr->roleList;
  459.         my %rolemapping;
  460.             foreach(@$roleLists) {
  461.                     $rolemapping{$_->roleId} = $_->name;
  462.             }  
  463.    
  464.         if($demo eq "no") {
  465.             eval {
  466.                 my $permissions = $authMgr->RetrieveAllPermissions();
  467.                 foreach(@$permissions) {
  468.                     my $ent = Vim::get_view(mo_ref => $_->entity, properties => ['name']);
  469.                     $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";
  470.                 }
  471.             };
  472.             if($@) { print "ERROR: Unable to query for permissions: " . $@ . "\n"; }
  473.         } else {
  474.             $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";
  475.         }
  476.         $summary_start .= "</table>\n";
  477.     }
  478.  
  479.     ###########################
  480.     # SESSIONS
  481.     ###########################
  482.     if($SYSTEM_SESSION eq "yes") {
  483.         $summary_start .= "<h3>Active Session(s):</h3>\n";
  484.         $summary_start .= "<table border=\"1\">\n";
  485.         $summary_start .= "<tr><th>USERNAME</th><th>FULL NAME</th><th>LOGON TIME</th><th>LAST ACTIVE</th></tr>\n";
  486.  
  487.         if($demo eq "no") {
  488.             my $sessionMgr =  Vim::get_view (mo_ref => $sc->sessionManager);
  489.                     my $sess_list = $sessionMgr->sessionList;
  490.             foreach(sort {$a->userName cmp $b->userName} @$sess_list) {
  491.                 $summary_start .=  "<tr><td>".$_->userName."</td><td>".$_->fullName."</td><td>".$_->loginTime."</td><td>".$_->lastActiveTime."</td></tr>\n";
  492.             }
  493.         } else {
  494.             $summary_start .= "<tr><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td><td>DEMO_MODE</td></tr>\n";
  495.         }
  496.         $summary_start .= "</table>\n";
  497.     }
  498.  
  499.     ###########################
  500.     # HOST PROFILES
  501.     ###########################
  502.     if($SYSTEM_HOST_PROFILE eq "yes") {
  503.         my $hostProfileMgr;
  504.         eval {
  505.             $hostProfileMgr = Vim::get_view (mo_ref => $sc->hostProfileManager);
  506.         };
  507.         if(!$@) {
  508.             my $profiles = Vim::get_views (mo_ref_array => $hostProfileMgr->profile);
  509.             my $hasProfile = 0;
  510.             my $profile_string = "";
  511.             foreach(sort {$a->name cmp $b->name} @$profiles) {
  512.                 $hasProfile = 1;
  513.                 my $profileDescription = "N/A";
  514.                 if($_->config->annotation) { $profileDescription = $_->config->annotation; }
  515.                 $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";
  516.             }
  517.             if($hasProfile eq 1) {
  518.                                 $summary_start .= "<h3>Host Profile(s):</h3>\n";
  519.                                 $summary_start .= "<table border=\"1\">\n";
  520.                                 $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";
  521.                 $summary_start .= $profile_string;
  522.                         }
  523.         }
  524.         $summary_start .= "</table>\n";
  525.     }
  526.     ###########################
  527.     # PLUGIN
  528.     ###########################
  529.     if($SYSTEM_PLUGIN eq "yes") {
  530.         my $extMgr;
  531.         eval {
  532.             $extMgr = Vim::get_view (mo_ref => $sc->extensionManager);
  533.         };
  534.         if(!$@) {
  535.             my $extList = $extMgr->extensionList;
  536.             my $ext_string = "";   
  537.        
  538.             foreach(sort {$a->description->label cmp $b->description->label} @$extList) {
  539.                 $ext_string .= "<tr>";
  540.                 $ext_string .= "<td>".$_->description->label."</td>";
  541.                 $ext_string .= "<td>".($_->version ? $_->version : "N/A")."</td>";
  542.                 $ext_string .= "<td>".($_->company ? $_->company : "N/A")."</td>";
  543.                 $ext_string .= "</tr>\n";
  544.             }
  545.             $summary_start .= "<h3>Plugin(s):</h3>\n";
  546.             $summary_start .= "<table border=\"1\">\n";
  547.             $summary_start .= "<tr><th>PLUGIN NAME</th><th>VERSION</th><th>COMPANY</th></tr>\n";
  548.             $summary_start .= $ext_string;
  549.             $summary_start .= "</table>\n";    
  550.         }
  551.     }
  552.  
  553.     $summary_start .= "\n</div>";
  554.     print REPORT_OUTPUT $summary_start;
  555. }
  556.  
  557. sub getCluster {
  558.     my ($type,$atype,$aversion) = @_;
  559.  
  560.     my $cluster_count = 0;
  561.  
  562.     if($type eq 'cluster') {
  563.         print REPORT_OUTPUT "<div id=\"tab2\" class=\"content\">";
  564.         #please do not touch this, else the jump tags will break
  565.             print REPORT_OUTPUT "\n/<!-- insert cluster jump -->/\n";
  566.         $cluster_count++;
  567.         &printClusterSummary($cluster_view,$cluster_count,$atype,$aversion);
  568.         print REPORT_OUTPUT "</div>\n";
  569.     }elsif($type eq 'datacenter') {
  570.         $cluster_views = Vim::find_entity_views(view_type => 'ClusterComputeResource',begin_entity => $datacenter_view);
  571.         if($cluster_views) {
  572.             print REPORT_OUTPUT "<div id=\"tab2\" class=\"content\">";
  573.             #please do not touch this, else the jump tags will break
  574.                     print REPORT_OUTPUT "\n/<!-- insert cluster jump -->/\n";
  575.                     foreach(sort {$a->name cmp $b->name} @$cluster_views) {
  576.                         $cluster_count++;
  577.                 if($_->isa("ClusterComputeResource")) {
  578.                                        &printClusterSummary($_,$cluster_count,$atype,$aversion);
  579.                                 }
  580.                     }
  581.             print REPORT_OUTPUT "</div>\n";
  582.         }
  583.     }elsif($type eq 'vcenter') {
  584.         if($cluster_views) {
  585.             print REPORT_OUTPUT "<div id=\"tab2\" class=\"content\">";
  586.             #please do not touch this, else the jump tags will break
  587.                 print REPORT_OUTPUT "\n/<!-- insert cluster jump -->/\n";
  588.             foreach(sort {$a->name cmp $b->name} @$cluster_views) {
  589.                 $cluster_count++;
  590.                 if($_->isa("ClusterComputeResource")) {
  591.                                        &printClusterSummary($_,$cluster_count,$atype,$aversion);
  592.                                 }
  593.             }
  594.         }
  595.         print REPORT_OUTPUT "</div>\n";
  596.     }
  597. }
  598.  
  599. sub getDatastoreCluster {
  600.     my ($type,$atype,$aversion) = @_;
  601.  
  602.     my $datastore_cluster_count = 0;
  603.  
  604.     if($type eq 'cluster' && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  605.         print REPORT_OUTPUT "<div id=\"tab7\" class=\"content\">";
  606.         #please do not touch this, else the jump tags will break
  607.         print REPORT_OUTPUT "\n/<!-- insert datastore cluster jump -->/\n";
  608.         my $cluster_folder = Vim::get_view(mo_ref => $cluster_view->parent);
  609.         my $cluster_parent = Vim::get_view(mo_ref => $cluster_folder->parent); 
  610.         $datastore_cluster_count++;
  611.         &printDatacenterSummary($cluster_parent,$datastore_cluster_count,$atype,$aversion);
  612.         print REPORT_OUTPUT "</div>\n";
  613.     } elsif($type eq 'datacenter' && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  614.         print REPORT_OUTPUT "<div id=\"tab7\" class=\"content\">";
  615.                 #please do not touch this, else the jump tags will break
  616.                 print REPORT_OUTPUT "\n/<!-- insert datastore cluster jump -->/\n";
  617.         $datastore_cluster_count++;
  618.                 &printDatacenterSummary($datacenter_view,$datastore_cluster_count,$atype,$aversion);
  619.         print REPORT_OUTPUT "</div>\n";
  620.     } elsif($type eq 'vcenter' && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  621.         print REPORT_OUTPUT "<div id=\"tab7\" class=\"content\">";
  622.         #please do not touch this, else the jump tags will break
  623.         print REPORT_OUTPUT "\n/<!-- insert datastore cluster jump -->/\n";
  624.         $datacenter_views = Vim::find_entity_views(view_type => 'Datacenter');
  625.         foreach(sort {$a->name cmp $b->name} @$datacenter_views) {
  626.             $datastore_cluster_count++;
  627.             &printDatacenterSummary($_,$datastore_cluster_count,$atype,$aversion);
  628.         }
  629.         print REPORT_OUTPUT "</div>\n";
  630.     }
  631. }
  632.  
  633. sub getHost {
  634.     my ($type,$atype,$aversion,$sc) = @_;
  635.  
  636.     print REPORT_OUTPUT "<div id=\"tab3\" class=\"content\">\n";
  637.  
  638.     my $cluster_count = 0;
  639.  
  640.     if($type eq 'host') {
  641.         #please do not touch this, else the jump tags will break
  642.                 print REPORT_OUTPUT "\n/<!-- insert host jump -->/\n";
  643.         &printHostSummary($host_view,undef,$cluster_count,$type,$atype,$aversion,$sc);
  644.     }elsif($type eq 'datacenter') {
  645.         #please do not touch this, else the jump tags will break
  646.                 print REPORT_OUTPUT "\n/<!-- insert host jump -->/\n";
  647.         foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) {
  648.             $cluster_count++;
  649.             my $clusterTag = "host-".$cluster->name."-$cluster_count";
  650.             my $clusterShortTag = $cluster->name;
  651.                     push @host_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
  652.             print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
  653.             print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
  654.             my $hosts = Vim::get_views (mo_ref_array => $cluster->host);
  655.             &printHostSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc);
  656.         }
  657.     }elsif($type eq 'cluster') {
  658.         $cluster_count++;
  659.         #please do not touch this, else the jump tags will break
  660.         print REPORT_OUTPUT "\n/<!-- insert host jump -->/\n";
  661.         my $clusterTag = "host-".$cluster_view->name."-$cluster_count";
  662.                 my $clusterShortTag = $cluster_view->name;
  663.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
  664.                 print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
  665.         print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
  666.         my $hosts = Vim::get_views (mo_ref_array => $cluster_view->host);
  667.         &printHostSummary($hosts,$cluster_view->name,$cluster_count,$type,$atype,$aversion,$sc);
  668.     }elsif($type eq 'vcenter') {
  669.         #please do not touch this, else the jump tags will break
  670.                 print REPORT_OUTPUT "\n/<!-- insert host jump -->/\n";
  671.         foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) {
  672.             $cluster_count++;
  673.             my $clusterTag = "host-".$cluster->name."-$cluster_count";
  674.                         my $clusterShortTag = $cluster->name;
  675.                         push @host_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
  676.             print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
  677.                 print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
  678.  
  679.             my $hosts = Vim::get_views (mo_ref_array => $cluster->host);
  680.             &printHostSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc);
  681.                 }
  682.     }
  683.     print REPORT_OUTPUT "</div>\n";
  684. }
  685.  
  686. sub getVM {
  687.         my ($type,$atype,$aversion,$sc) = @_;
  688.  
  689.         print REPORT_OUTPUT "<div id=\"tab4\" class=\"content\">\n";
  690.  
  691.         my $cluster_count = 0;
  692.  
  693.         if($type eq 'host') {
  694.                 #please do not touch this, else the jump tags will break
  695.                 print REPORT_OUTPUT "\n/<!-- insert vm jump -->/\n";
  696.                 &printVMSummary($host_view,undef,$cluster_count,$type,$atype,$aversion,$sc);
  697.         }elsif($type eq 'datacenter') {
  698.                 #please do not touch this, else the jump tags will break
  699.                 print REPORT_OUTPUT "\n/<!-- insert vm jump -->/\n";
  700.                 foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) {
  701.                         $cluster_count++;
  702.                         my $clusterTag = "vm-".$cluster->name."-$cluster_count";
  703.                         my $clusterShortTag = $cluster->name;
  704.                         push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
  705.                         print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
  706.             print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
  707.                         my $hosts = Vim::get_views (mo_ref_array => $cluster->host);
  708.                         &printVMSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc);
  709.                 }
  710.         }elsif($type eq 'cluster') {
  711.                 $cluster_count++;
  712.         #please do not touch this, else the jump tags will break
  713.         print REPORT_OUTPUT "\n/<!-- insert vm jump -->/\n";
  714.         my $clusterTag = "vm-".$cluster_view->name."-$cluster_count";
  715.         my $clusterShortTag = $cluster_view->name;
  716.         push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
  717.         print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
  718.         print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
  719.         my $hosts = Vim::get_views (mo_ref_array => $cluster_view->host);
  720.                 &printVMSummary($hosts,$cluster_view->name,$cluster_count,$type,$atype,$aversion,$sc);
  721.         }elsif($type eq 'vcenter') {
  722.                 #please do not touch this, else the jump tags will break
  723.                 print REPORT_OUTPUT "\n/<!-- insert vm jump -->/\n";
  724.                 foreach my $cluster(sort {$a->name cmp $b->name} @$cluster_views) {
  725.                         $cluster_count++;
  726.                         my $clusterTag = "vm-".$cluster->name."-$cluster_count";
  727.                         my $clusterShortTag = $cluster->name;
  728.                         push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;<a href=\"#$clusterTag\">Cluster: $clusterShortTag</a><br/>\n";
  729.                         print REPORT_OUTPUT "<br/><a name=\"$clusterTag\"></a>\n";
  730.             print REPORT_OUTPUT "<h2>Cluster: $clusterShortTag</h2>\n";
  731.                         my $hosts = Vim::get_views (mo_ref_array => $cluster->host);
  732.                         &printVMSummary($hosts,$cluster->name,$cluster_count,$type,$atype,$aversion,$sc);
  733.                 }
  734.         }
  735.     print REPORT_OUTPUT "</div>\n";
  736. }
  737.  
  738. sub getVPXSettings {
  739.         my ($vpxcheck,$atype,$sc) = @_;
  740.  
  741.         if($vpxcheck eq "yes" && $atype eq "VirtualCenter") {
  742.                 my $setting = Vim::get_view(mo_ref => $sc->setting);
  743.                 my $vpxSettings = $setting->setting;
  744.  
  745.                 my $vpxString = "";
  746.                 if($vpxSettings) {
  747.                         print REPORT_OUTPUT "<div id=\"tab5\" class=\"content\">\n";
  748.                         print REPORT_OUTPUT "<h2>vCenter VPX Configurations</h2>\n";
  749.                         print REPORT_OUTPUT "<table border=\"1\">\n";
  750.                         print REPORT_OUTPUT "<tr><th>KEY</th><th>VALUE</th></tr>\n";
  751.                         foreach(sort {$a->key cmp $b->key} @$vpxSettings) {
  752.                                 my $key = $_->key;
  753.                                 my $value = $_->value;
  754.                                 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/)) {
  755.                                         $value = "DEMO_MODE";
  756.                                 }
  757.                                 $vpxString .= "<tr><td>".$key."</td><td>".$value."</tr>\n";
  758.                         }
  759.                         print REPORT_OUTPUT $vpxString;
  760.                         print REPORT_OUTPUT "</table>\n";
  761.                         print REPORT_OUTPUT "</div>\n";
  762.                 }
  763.         }
  764. }
  765.  
  766. sub getVMwareApps {
  767.         my ($vmwcheck,$atype,$sc) = @_;
  768.  
  769.         if($vmwcheck eq "yes" && $atype eq "VirtualCenter") {
  770.  
  771.                 my $vmwAppString = "";
  772.                 if(@vmw_apps) {
  773.                         print REPORT_OUTPUT "<div id=\"tab6\" class=\"content\">\n";
  774.                         print REPORT_OUTPUT "<h2>VMware and 3rd Party Applications in a VM</h2>\n";
  775.                         print REPORT_OUTPUT "<table border=\"1\">\n";
  776.                         print REPORT_OUTPUT "<tr><th>CLUSTER</th><th>VM NAME</th><th>VMWARE/3RD PARTY APPLICATION</th></tr>\n";
  777.                         foreach(@vmw_apps) {
  778.                                 $vmwAppString .= $_;
  779.                         }
  780.                         print REPORT_OUTPUT $vmwAppString;
  781.                         print REPORT_OUTPUT "</table>\n";
  782.                         print REPORT_OUTPUT "</div>\n";
  783.                 }
  784.         }
  785. }
  786.  
  787. sub printVMSummary {
  788.     my ($local_hosts,$cluster_name,$cluster_count,$type,$atype,$aversion,$sc) = @_;
  789.  
  790.     if(@$local_hosts) {
  791.         foreach my $local_host(sort {$a->summary->config->name cmp $b->summary->config->name} @$local_hosts) {
  792.             if($demo eq "no") {
  793.                 $host_name = $local_host->name;
  794.             }
  795.  
  796.             #skip if host is not accessible
  797.                         next if($local_host->runtime->connectionState->val ne "connected");
  798.            
  799.             #skip if VM is not in valid list
  800.                         if($hostlist) {
  801.                                 next if(!$hostlists{$local_host->name});
  802.                         }
  803.  
  804.             my $vms = Vim::get_views(mo_ref_array => $local_host->vm);
  805.             foreach my $vm (sort {$a->name cmp $b->name} @$vms) {
  806.                 #skip if vm is disconnected
  807.                 next if(!defined($vm->config));
  808.  
  809.                 #skip if VM is not in valid list
  810.                 if($vmlist) {
  811.                     my $vmname = $vm->name;
  812.                     next if(!$vmlists{$vmname});
  813.                 }
  814.  
  815.                 ######################
  816.                                 # VM TAG
  817.                                 ######################
  818.                                 if(defined($vm->tag)) {
  819.                                         my $vmTags = $vm->tag;
  820.                                         foreach(sort {$a->key cmp $b->key} @$vmTags) {
  821.                                                 my $tagString = "<tr><td>".$cluster_name."</td><td>".$vm->name."</td><td>".$_->key."</td></tr>\n";
  822.                                                 push @vmw_apps, $tagString;
  823.                                         }
  824.                                 }
  825.                 ######################
  826.                 # VM STATE
  827.                 ######################
  828.                 if($VM_STATE eq "yes") {
  829.                     $vmstateString .= "<tr>";
  830.  
  831.                     ## ESX/ESXi host ##
  832.                                         $vmstateString .= "<td>".$host_name."</td>";
  833.  
  834.                                         ## DISPLAY NAME ##
  835.                                         $vmstateString .= "<td>".$vm->name."</td>";
  836.  
  837.                     ## BOOT TIME ##
  838.                                         $vmstateString .= "<td>".($vm->runtime->bootTime ? $vm->runtime->bootTime : "N/A")."</td>";
  839.  
  840.                                         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  841.                                                 ## UPTIME ##
  842.                                                 $vmstateString .= "<td>".($vm->summary->quickStats->uptimeSeconds ? &getUptime($vm->summary->quickStats->uptimeSeconds) : "N/A")."</td>";
  843.                                         }
  844.                    
  845.                     ## OVERALL STATUS ##
  846.                                         my $vm_health = $vm->summary->overallStatus->val;
  847.                                         if ($vm_health eq 'green') { $vmstateString .= "<td bgcolor=\"$green\">VM is OK</td>"; }
  848.                                         elsif ($vm_health eq 'red') { $vmstateString .= "<td bgcolor=\"$red\">VM has a problem</td>"; }
  849.                                         elsif ($vm_health eq 'yellow') { $vmstateString .= "<td bgcolor=\"$yellow\">VM<might have a problem</td>"; }
  850.                                         else { $vmstateString .="<td bgcolor=\"gray\">UNKNOWN</td>"; }
  851.  
  852.                     if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  853.                         ## HA PROTECTION ##
  854.                         if($vm->runtime->dasVmProtection) {
  855.                         $vmstateString .= "<td>".($vm->runtime->dasVmProtection->dasProtected ? "YES" : "NO")."</td>";
  856.                         } else { $vmstateString .= "<td>N/A</td>"; }
  857.                     } else { $vmstateString .= "<td>N/A</td>"; }
  858.  
  859.                                         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  860.                                                 ## APP HEARTBEAT ##
  861.                                                 $vmstateString .= "<td>".($vm->guest->appHeartbeatStatus ? $vm->guest->appHeartbeatStatus : "N/A")."</td>";
  862.                                         }
  863.  
  864.                                         ## CONNECTION STATE ##
  865.                                         $vmstateString .= "<td>".$vm->runtime->connectionState->val."</td>";
  866.  
  867.                                         ## POWER STATE ##
  868.                                         $vmstateString .= "<td>".$vm->runtime->powerState->val."</td>";
  869.  
  870.                     ## CONSOLIDATION ##
  871.                     if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  872.                         $vmstateString .= "<td>".($vm->runtime->consolidationNeeded ? "YES" : "NO")."</td>";
  873.                     } else { $vmstateString .= "<td>N/A</td>"; }
  874.  
  875.                     $vmstateString .= "</tr>";
  876.                 }
  877.                 ######################
  878.                 # VM CONFIG
  879.                 ######################
  880.                 if($VM_CONFIG eq "yes") {
  881.                     $vmconfigString .= "<tr>";
  882.  
  883.                     ## ESX/ESXi host ##
  884.                     $vmconfigString .= "<td>".$host_name."</td>";
  885.  
  886.                     ## DISPLAY NAME ##
  887.                     $vmconfigString .= "<td>".$vm->name."</td>";
  888.  
  889.                     ## VIRTUAL HARDWARE VER ##
  890.                                         $vmconfigString .= "<td>".$vm->config->version."</td>";
  891.  
  892.                     ## GUEST HOSTNAME ##
  893.                     $vmconfigString .= "<td>".($vm->guest->hostName ? $vm->guest->hostName : "N/A")."</td>";
  894.  
  895.                     ## UUID ##
  896.                     $vmconfigString .= "<td>".($vm->summary->config->uuid ? $vm->summary->config->uuid : "N/A")."</td>";
  897.  
  898.                     ## FIRMWARE ##
  899.                     if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  900.                         $vmconfigString .= "<td>".($vm->config->firmware ? $vm->config->firmware : "N/A")."</td>";
  901.                     } else { $vmconfigString .= "<td>N/A</td>"; }
  902.  
  903.                     ## OS ##   
  904.                     $vmconfigString .= "<td>".($vm->config->guestFullName ? $vm->config->guestFullName : "N/A")."</td>";
  905.                
  906.                     ## vCPU ##
  907.                     $vmconfigString .= "<td>".($vm->summary->config->numCpu ? $vm->summary->config->numCpu : "N/A")."</td>";                   
  908.                     ## vMEM ##
  909.                     $vmconfigString .= "<td>".($vm->summary->config->memorySizeMB ? &prettyPrintData($vm->summary->config->memorySizeMB,'M') : "N/A")."</td>";
  910.                    
  911.                     ## vDISK ##
  912.                                         $vmconfigString .= "<td>".($vm->summary->config->numVirtualDisks ? $vm->summary->config->numVirtualDisks : "N/A")."</td>";
  913.  
  914.                     ## DISK CAPACITY ##
  915.                     if($vm->summary->storage) {
  916.                         my ($commit,$uncommit) = (0,0);
  917.                         if(defined($vm->summary->storage->committed)) { $commit = $vm->summary->storage->committed; }
  918.                         if(defined($vm->summary->storage->uncommitted)) { $uncommit = $vm->summary->storage->uncommitted; }
  919.                         $vmconfigString .= "<td>".&prettyPrintData(($commit + $uncommit),'B')."</td>";
  920.                     } else {
  921.                         $vmconfigString .= "<td>N/A</td>";
  922.                     }
  923.  
  924.                     ## vNIC ##
  925.                     $vmconfigString .= "<td>".($vm->summary->config->numEthernetCards ? $vm->summary->config->numEthernetCards : "N/A")."</td>";
  926.  
  927.                     if(!$vm->config->template) {
  928.                         ## CPU RESERV ##
  929.                         $vmconfigString .= "<td>".($vm->summary->config->cpuReservation ? &prettyPrintData($vm->summary->config->cpuReservation,'MHZ') : "N/A")."</td>";
  930.  
  931.                         ## MEM RESERV ##
  932.                         $vmconfigString .= "<td>".($vm->summary->config->memoryReservation ? &prettyPrintData($vm->summary->config->memoryReservation,'M') : "N/A")."</td>";
  933.                     } else {
  934.                         $vmconfigString .= "<td>N/A</td>";
  935.                         $vmconfigString .= "<td>N/A</td>";
  936.                     }          
  937.  
  938.                     ## TEMPLATE ##
  939.                     $vmconfigString .= "<td>".($vm->config->template ? "YES" : "NO")."</td>";
  940.  
  941.                     $vmconfigString .= "</tr>\n";
  942.                 }
  943.                 ######################
  944.                 # STATISTICS
  945.                 ######################
  946.                 if($VM_STATS eq "yes") {
  947.                     if(!$vm->config->template) {
  948.                         $vmstatString .= "<tr>";
  949.  
  950.                         ## ESX/ESXi host ##
  951.                                             $vmstatString .= "<td>".$host_name."</td>";
  952.  
  953.                                             ## DISPLAY NAME ##
  954.                                             $vmstatString .= "<td>".$vm->name."</td>";
  955.  
  956.                         ## CPU USAGE ##
  957.                         $vmstatString .= "<td>".($vm->summary->quickStats->overallCpuUsage ? &prettyPrintData($vm->summary->quickStats->overallCpuUsage,'MHZ') : "N/A" )."</td>";
  958.  
  959.                         ## MEM USAGE ##
  960.                         $vmstatString .= "<td>".($vm->summary->quickStats->guestMemoryUsage ? &prettyPrintData($vm->summary->quickStats->guestMemoryUsage,'M') : "N/A")."</td>";
  961.                        
  962.                         ## MAX CPU USAGE ##
  963.                         $vmstatString .= "<td>".($vm->runtime->maxCpuUsage ? &prettyPrintData($vm->runtime->maxCpuUsage,'MHZ') : "N/A")."</td>";
  964.  
  965.                         ## MAX MEM USAGE ##
  966.                         $vmstatString .= "<td>".($vm->runtime->maxMemoryUsage ? &prettyPrintData($vm->runtime->maxMemoryUsage,'M') : "N/A")."</td>";
  967.  
  968.                         ## ACTIVE MEM ##
  969.                         $vmstatString .= "<td>".($vm->summary->quickStats->guestMemoryUsage ? &prettyPrintData($vm->summary->quickStats->guestMemoryUsage,'M') : "N/A")."</td>";
  970.  
  971.                         ## CONSUMED MEM ##
  972.                         $vmstatString .= "<td>".($vm->summary->quickStats->hostMemoryUsage ? &prettyPrintData($vm->summary->quickStats->hostMemoryUsage,'M') : "N/A")."</td>";
  973.  
  974.                         ## INITIAL MEM RESV OVERHEAD + INITIAL MEM SWAP RESV OVERHEAD ##
  975.                         if(($aversion eq '5.0.0' || $aversion eq '5.1.0') && $vm->config->initialOverhead) {
  976.                             $vmstatString .= "<td>".($vm->config->initialOverhead->initialMemoryReservation ? &prettyPrintData($vm->config->initialOverhead->initialMemoryReservation,'B') : "N/A")."</td>";
  977.                             $vmstatString .= "<td>".($vm->config->initialOverhead->initialSwapReservation ? &prettyPrintData($vm->config->initialOverhead->initialSwapReservation,'B') : "N/A")."</td>";
  978.                         } else { $vmstatString .= "<td>N/A</td><td>N/A</td>"; }
  979.  
  980.                         ## MEM OVERHEAD ##
  981.                         $vmstatString .= "<td>".($vm->summary->quickStats->consumedOverheadMemory ? &prettyPrintData($vm->summary->quickStats->consumedOverheadMemory,'M') : "N/A")."</td>";
  982.                        
  983.                         ## MEM BALLON ##
  984.                         $vmstatString .= "<td>".($vm->summary->quickStats->balloonedMemory ? &prettyPrintData($vm->summary->quickStats->balloonedMemory,'M') : "N/A")."</td>";
  985.  
  986.                         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  987.                             ## COMPRESSED MEM ##
  988.                             if(defined($vm->summary->quickStats->compressedMemory)) {
  989.                                 if($debug) { print "---DEBUG compressedMemory for " . $vm->name . ": \"" . $vm->summary->quickStats->compressedMemory . "\" ---DEBUG\n"; }
  990.                                 my $compressedMem = "N/A";
  991.                                 if($vm->summary->quickStats->compressedMemory > 0) {
  992.                                     $compressedMem = &prettyPrintData($vm->summary->quickStats->compressedMemory,'K');
  993.                                 }
  994.                                 $vmstatString .= "<td>".$compressedMem."</td>";
  995.                             } else { $vmstatString .= "<td>N/A</td>"; }
  996.                         }
  997.  
  998.                         $vmstatString .= "</tr>\n";
  999.                     }
  1000.                 }
  1001.                 ######################
  1002.                 # VM RESOURCE
  1003.                 ######################
  1004.                 if($VM_RESOURCE_ALLOCATION eq "yes") {
  1005.                     if(!$vm->config->template && $vm->resourceConfig) {
  1006.                         $vmrscString .= "<tr>";
  1007.            
  1008.                         ## ESX/ESXi host ##
  1009.                         $vmrscString .= "<td>".$host_name."</td>";
  1010.  
  1011.                         ## DISPLAY NAME ##
  1012.                         $vmrscString .= "<td>".$vm->name."</td>";
  1013.  
  1014.                         ## MODIFIED ##
  1015.                         $vmrscString .= "<td>".($vm->resourceConfig->lastModified ? $vm->resourceConfig->lastModified : "N/A")."</td>";
  1016.  
  1017.                         my $cpuAllocation = $vm->resourceConfig->cpuAllocation;
  1018.                         my $memAllocation = $vm->resourceConfig->memoryAllocation;
  1019.                    
  1020.                         #cpu
  1021.                        
  1022.                         ## RESERVATION ##
  1023.                         $vmrscString .= "<td>".($cpuAllocation->reservation ? &prettyPrintData($cpuAllocation->reservation,'MHZ') : "N/A")."</td>";
  1024.  
  1025.                         ## LIMIT ##
  1026.                         $vmrscString .= "<td>".($cpuAllocation->limit ? &prettyPrintData($cpuAllocation->limit,'MHZ') : "N/A")."</td>";
  1027.  
  1028.                         ## SHARES ##
  1029.  
  1030.                         # SHARES VALUE
  1031.                         $vmrscString .= "<td>".($cpuAllocation->shares->shares ? $cpuAllocation->shares->shares : "N/A")."</td>";
  1032.  
  1033.                         # SHARES LEVEL
  1034.                         $vmrscString .= "<td>".($cpuAllocation->shares->level->val ? $cpuAllocation->shares->level->val : "N/A")."</td>";
  1035.  
  1036.                         ## EXPAND RESERVATION ##
  1037.                         $vmrscString .= "<td>".($cpuAllocation->expandableReservation ? "YES" : "NO")."</td>";
  1038.  
  1039.                         ## OVERHEAD LIMIT ##
  1040.                         $vmrscString .= "<td>".($cpuAllocation->overheadLimit ? &prettyPrintData($cpuAllocation->overheadLimit,'MHZ') : "N/A")."</td>";
  1041.  
  1042.                         #mem
  1043.  
  1044.                         ## RESERVATION ##
  1045.                                                 $vmrscString .= "<td>".($memAllocation->reservation ? &prettyPrintData($memAllocation->reservation,'M') : "N/A")."</td>";
  1046.  
  1047.                                                 ## LIMIT ##
  1048.                                                 $vmrscString .= "<td>".($memAllocation->limit ? &prettyPrintData($memAllocation->limit,'M') : "N/A")."</td>";
  1049.  
  1050.                                                 ## SHARES ##
  1051.  
  1052.                                                 # SHARES VALUE
  1053.                                                 $vmrscString .= "<td>".($memAllocation->shares->shares ? $memAllocation->shares->shares : "N/A")."</td>";
  1054.  
  1055.                                                 # SHARES LEVEL
  1056.                                                 $vmrscString .= "<td>".($memAllocation->shares->level->val ? $memAllocation->shares->level->val : "N/A")."</td>";
  1057.  
  1058.                                                 ## EXPAND RESERVATION ##
  1059.                                                 $vmrscString .= "<td>".($memAllocation->expandableReservation ? "YES" : "NO")."</td>";
  1060.  
  1061.                                                 ## OVERHEAD LIMIT ##
  1062.                                                 $vmrscString .= "<td>".($memAllocation->overheadLimit ? &prettyPrintData($memAllocation->overheadLimit,'M') : "N/A")."</td>";
  1063.  
  1064.                         $vmrscString .= "</tr>\n";
  1065.                     }
  1066.                 }
  1067.                 ######################
  1068.                                 # VM PERFORMANCE
  1069.                                 ######################
  1070.                 if($VM_PERFORMANCE eq "yes" || $vmperformance eq "yes") {
  1071.                     if($vm->runtime->powerState->val eq 'poweredOn') {
  1072.                                         my $vmperf = &getCpuAndMemPerf($vm);
  1073.                                         $vmPerfString .= $vmperf;
  1074.                     }
  1075.                 }
  1076.                 ######################
  1077.                 # FT
  1078.                 ######################
  1079.                 if($VM_FT eq "yes") {
  1080.                                         if(!$vm->config->template && defined($vm->summary->config->ftInfo)) {          
  1081.                         $vmftString .= "<tr>";
  1082.  
  1083.                         ## ESX/ESXi host ##
  1084.                                                 $vmftString .= "<td>".$host_name."</td>";
  1085.  
  1086.                                                 ## DISPLAY NAME ##
  1087.                                                 $vmftString .= "<td>".$vm->name."</td>";
  1088.  
  1089.                         ## FT STATE ##
  1090.                         $vmftString .= "<td>".$vm->runtime->faultToleranceState->val."</td>";
  1091.  
  1092.                         ## FT ROLE ##
  1093.                         my $role = "";
  1094.                         if($vm->summary->config->ftInfo->role eq 1) { $role = "PRIMARY"; } else { $role = "SECONDARY"; }
  1095.                         $vmftString .= "<td>".$role."</td>";
  1096.  
  1097.                         ## FT INSTANCE UUIDS ##
  1098.                         my $ftuuids = $vm->summary->config->ftInfo->instanceUuids;
  1099.                         my $instanceuuids = "";
  1100.                         if($vm->summary->config->ftInfo->role eq 1) {
  1101.                             $instanceuuids = $ftuuids->[0];
  1102.                         } else {
  1103.                             $instanceuuids = $ftuuids->[1];
  1104.                         }
  1105.                         $vmftString .= "<td>".$instanceuuids."</td>";  
  1106.  
  1107.                         ## FT SECONDARY LATENCY ##
  1108.                                             $vmftString .= "<td>".($vm->summary->quickStats->ftSecondaryLatency ? $vm->summary->quickStats->ftSecondaryLatency : "N/A")."</td>";
  1109.  
  1110.                         ## FT BW ##
  1111.                                             $vmftString .= "<td>".($vm->summary->quickStats->ftLogBandwidth ? $vm->summary->quickStats->ftLogBandwidth : "N/A")."</td>";
  1112.                         $vmftString .= "</tr>\n";
  1113.                     }
  1114.                 }
  1115.                 ######################
  1116.                                 # EZT
  1117.                                 ######################
  1118.                                 if($VM_EZT eq "yes" && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  1119.                                         if(!$vm->config->template) {
  1120.                                                 my $devices = $vm->config->hardware->device;
  1121.                                                 my ($ezt_disk_string,$ezt_size_string,$ezt_label_string) = ("","","");
  1122.                                                 my $hasEZT = 0;
  1123.                                                 foreach(@$devices) {
  1124.                                                         if($_->isa('VirtualDisk') && $_->backing->isa('VirtualDiskFlatVer2BackingInfo')) {
  1125.                                                                 my $diskName = $_->backing->fileName;
  1126.                                                                 my $label = ($_->deviceInfo->label ? $_->deviceInfo->label : "N/A");
  1127.                                                                 if(!$_->backing->thinProvisioned && defined($_->backing->eagerlyScrub)) {
  1128.                                     if($_->backing->eagerlyScrub) {
  1129.                                                                             $hasEZT = 1;
  1130.                                                                             $ezt_label_string .= $label."<br/>";
  1131.                                                                             $ezt_disk_string .= $diskName."<br/>";
  1132.                                                                             $ezt_size_string .= &prettyPrintData($_->capacityInKB,'K')."<br/>";
  1133.                                     }
  1134.                                                                 }
  1135.                                                         }
  1136.                                                 }
  1137.                                                 if($hasEZT eq 1) {
  1138.                                                         $vmeztString .= "<tr>";
  1139.  
  1140.                                                         ## ESX/ESXi host ##
  1141.                                                         $vmeztString .= "<td>".$host_name."</td>";
  1142.  
  1143.                                                         ## DISPLAY NAME ##
  1144.                                                         $vmeztString .= "<td>".$vm->name."</td>";
  1145.  
  1146.                                                         ## EZT LABEL ##
  1147.                                                         $vmeztString .= "<td>".$ezt_label_string."</td>";
  1148.  
  1149.                                                         ## EZT DISKS ##
  1150.                                                         $vmeztString .= "<td>".$ezt_disk_string."</td>";
  1151.  
  1152.                                                         ## EZT DISKS SIZE ##
  1153.                                                         $vmeztString .= "<td>".$ezt_size_string."</td>";
  1154.  
  1155.                                                         $vmeztString .= "</tr>\n";
  1156.                                                 }
  1157.                                         }
  1158.                                 }
  1159.                 ######################
  1160.                 # THIN
  1161.                 ######################
  1162.                 if($VM_THIN eq "yes") {
  1163.                                         if(!$vm->config->template) {
  1164.                         my $devices = $vm->config->hardware->device;
  1165.                         my ($thin_disk_string,$thin_size_string,$thin_label_string) = ("","","");
  1166.                         my $hasThin = 0;
  1167.                         foreach(@$devices) {
  1168.                             if($_->isa('VirtualDisk') && $_->backing->isa('VirtualDiskFlatVer2BackingInfo')) {
  1169.                                 my $diskName = $_->backing->fileName;
  1170.                                 my $label = ($_->deviceInfo->label ? $_->deviceInfo->label : "N/A");
  1171.                                 if($_->backing->thinProvisioned) {
  1172.                                     $hasThin = 1;
  1173.                                     $thin_label_string .= $label."<br/>";
  1174.                                     $thin_disk_string .= $diskName."<br/>";
  1175.                                     $thin_size_string .= &prettyPrintData($_->capacityInKB,'K')."<br/>";
  1176.                                 }
  1177.                             }
  1178.                         }  
  1179.                         if($hasThin eq 1) {
  1180.                             $vmthinString .= "<tr>";           
  1181.    
  1182.                             ## ESX/ESXi host ##
  1183.                                                     $vmthinString .= "<td>".$host_name."</td>";
  1184.  
  1185.                             ## DISPLAY NAME ##
  1186.                             $vmthinString .= "<td>".$vm->name."</td>";
  1187.  
  1188.                             ## THIN LABEL ##
  1189.                             $vmthinString .= "<td>".$thin_label_string."</td>";
  1190.  
  1191.                             ## THIN DISKS ##
  1192.                             $vmthinString .= "<td>".$thin_disk_string."</td>";
  1193.  
  1194.                             ## THIN DISKS SIZE ##
  1195.                             $vmthinString .= "<td>".$thin_size_string."</td>";
  1196.  
  1197.                             $vmthinString .= "</tr>\n";
  1198.                         }
  1199.                                         }
  1200.                                 }
  1201.                 ######################
  1202.                 # DEVICE
  1203.                 ######################
  1204.                 if($VM_DEVICE eq "yes") {
  1205.                     if(!$vm->config->template) {
  1206.                         $vmdeviceString .= "<tr>";
  1207.  
  1208.                                                 ## ESX/ESXi host ##
  1209.                                                 $vmdeviceString .= "<td>".$host_name."</td>";
  1210.  
  1211.                                                 ## DISPLAY NAME ##
  1212.                                                 $vmdeviceString .= "<td>".$vm->name."</td>";
  1213.  
  1214.                         my %deviceMapper = ();
  1215.  
  1216.                         my $devices = $vm->config->hardware->device;
  1217.                         #foreach(@$devices) {
  1218.                         #   $deviceMapper{$_->key} = $_->deviceInfo->label;
  1219.                         #} 
  1220.                                            
  1221.                         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);
  1222.  
  1223.                         foreach my $device (@$devices) {
  1224.                             if($device->isa('VirtualCdrom')) {
  1225.                                 $cdrom++;
  1226.                             }elsif($device->isa('VirtualController')) {
  1227.                                 if($device->isa('VirtualIDEController')) {
  1228.                                     $idecontroller++;
  1229.                                 }elsif($device->isa('VirtualPCIController')) {
  1230.                                     $pcicontroller++;
  1231.                                 }elsif($device->isa('VirtualPS2Controller')) {
  1232.                                     $ps2controller++;
  1233.                                 }elsif($device->isa('VirtualSCSIController')) {
  1234.                                     if($device->isa('ParaVirtualSCSIController')) {
  1235.                                         $paracontroller++;
  1236.                                     }elsif($device->isa('VirtualBusLogicController')) {
  1237.                                         $buscontroller++;
  1238.                                     }elsif($device->isa('VirtualLsiLogicController')) {
  1239.                                         $lsicontroller++;
  1240.                                     }elsif($device->isa('VirtualLsiLogicSASController')) {
  1241.                                         $lsilogiccontroller++;
  1242.                                     }
  1243.                                 }elsif($device->isa('VirtualSIOController')) {
  1244.                                     $siocontroller++;
  1245.                                 }elsif($device->isa('VirtualUSBController')) {
  1246.                                     $usbcontroller++;
  1247.                                 }
  1248.                             }elsif($device->isa('VirtualDisk')) {
  1249.                                 $disk++;
  1250.                             }elsif($device->isa('VirtualEthernetCard')) {
  1251.                                 if($device->isa('VirtualE1000')) {
  1252.                                     $e1000ethernet++;
  1253.                                 }elsif($device->isa('VirtualPCNet32')) {
  1254.                                     $pcnet32ethernet++;
  1255.                                 }elsif($device->isa('VirtualVmxnet')) {
  1256.                                     if($device->isa('VirtualVmxnet2')) {
  1257.                                         $vmxnet2ethernet++;
  1258.                                     }elsif($device->isa('VirtualVmxnet3')) {
  1259.                                         $vmxnet3ethernet++;
  1260.                                     }
  1261.                                 }
  1262.                             }elsif($device->isa('VirtualFloppy')) {
  1263.                                 $floppy++;
  1264.                             }elsif($device->isa('VirtualKeyboard')) {
  1265.                                 $keyboard++;
  1266.                             }elsif($device->isa('VirtualMachineVideoCard')) {
  1267.                                 $videocard++;
  1268.                             }elsif($device->isa('VirtualMachineVMCIDevice')) {
  1269.                                 $vmci++;
  1270.                             }elsif($device->isa('VirtualMachineVMIROM')) {
  1271.                                 $vmi++;
  1272.                             }elsif($device->isa('VirtualParallelPort')) {
  1273.                                 $parallelport++;
  1274.                             }elsif($device->isa('VirtualPCIPassthrough')) {
  1275.                                 $pcipassthrough++;
  1276.                             }elsif($device->isa('VirtualPointingDevice')) {
  1277.                                 $pointingdevice++;
  1278.                             }elsif($device->isa('VirtualSCSIPassthrough')) {
  1279.                                 $scsipassthrough++;
  1280.                                                         }elsif($device->isa('VirtualSerialPort')) {
  1281.                                 $serialport++;
  1282.                                                         }elsif($device->isa('VirtualSoundCard')) {
  1283.                                 if($device->isa('VirtualEnsoniq1371')) {
  1284.                                     $ensoniqsoundcard++;
  1285.                                 }elsif($device->isa('VirtualSoundBlaster16')) {
  1286.                                     $blastersoundcard++;
  1287.                                 }
  1288.                                                         }elsif($device->isa('VirtualUSB')) {
  1289.                                 $usb++;
  1290.                             }
  1291.                         }
  1292.                        
  1293.                         ## OS ##
  1294.                                             $vmdeviceString .= "<td>".($vm->config->guestFullName ? $vm->config->guestFullName : "N/A")."</td>";
  1295.  
  1296.                         ## CDROM ##
  1297.                         $vmdeviceString .= "<td>".$cdrom."</td>";
  1298.  
  1299.                         ## CONTROLER ##
  1300.                         my $controllerString = "";
  1301.                         if($idecontroller != 0) {
  1302.                             $controllerString .= $idecontroller . " x IDE Controller<br/>";
  1303.                         }
  1304.                         if($pcicontroller != 0) {
  1305.                                                         $controllerString .= $pcicontroller . " x PCI Controller<br/>";
  1306.                         }
  1307.                         if($ps2controller != 0) {
  1308.                                                         $controllerString .= $ps2controller . " x PS2 Controller<br/>";
  1309.                                                 }
  1310.                         if($paracontroller != 0) {
  1311.                                                         $controllerString .= $paracontroller . " x PARA-VIRT Controller<br/>";
  1312.                                                 }
  1313.                         if($buscontroller != 0) {
  1314.                                                         $controllerString .= $buscontroller . " x BUS Controller<br/>";
  1315.                                                 }
  1316.                         if($lsicontroller != 0) {
  1317.                                                         $controllerString .= $lsicontroller . " x LSI LOGIC Controller<br/>";
  1318.                                                 }
  1319.                         if($lsilogiccontroller != 0) {
  1320.                                                         $controllerString .= $lsilogiccontroller . " x LSI LOGIC SAS Controller<br/>";
  1321.                                                 }
  1322.                         if($siocontroller != 0) {
  1323.                                                         $controllerString .= $siocontroller . " x SIO Controller<br/>";
  1324.                                                 }
  1325.                         if($usbcontroller != 0) {
  1326.                                                         $controllerString .= $usbcontroller . " x USB Controller<br/>";
  1327.                                                 }
  1328.                         if($controllerString eq "") { $controllerString = "N/A"; }
  1329.                         $vmdeviceString .= "<td>".$controllerString."</td>";
  1330.  
  1331.                         ## DISK ##
  1332.                         $vmdeviceString .= "<td>".$disk."</td>";
  1333.                        
  1334.                         ## ETHERNET CARD ##
  1335.                         my $ethString = "";
  1336.                         if($e1000ethernet != 0) {
  1337.                             $ethString .= $e1000ethernet . " x e1000<br/>";
  1338.                         }
  1339.                         if($pcnet32ethernet != 0) {
  1340.                             $ethString .= $pcnet32ethernet . " x PCNET32<br/>";
  1341.                                                 }
  1342.                         if($vmxnet2ethernet != 0) {
  1343.                             $ethString .= $vmxnet2ethernet . " x VMXNET2<br/>";
  1344.                                                 }
  1345.                         if($vmxnet3ethernet != 0) {
  1346.                             $ethString .= $vmxnet3ethernet . " x VMXNET3<br/>";
  1347.                                                 }
  1348.                         if($ethString eq "") { $ethString = "N/A"; }
  1349.                         $vmdeviceString .= "<td>".$ethString."</td>";                      
  1350.  
  1351.                         ## FLOPPY ##
  1352.                         $vmdeviceString .= "<td>".$floppy."</td>";                     
  1353.  
  1354.                         ## KEYBOARD ##
  1355.                         $vmdeviceString .= "<td>".$keyboard."</td>";
  1356.  
  1357.                         ## VIDEO CARD ##
  1358.                         $vmdeviceString .= "<td>".$videocard."</td>";
  1359.  
  1360.                         ## VMCI ##
  1361.                         $vmdeviceString .= "<td>".$vmci."</td>";       
  1362.  
  1363.                         ## VMIROM ##
  1364.                         $vmdeviceString .= "<td>".$vmi."</td>";
  1365.  
  1366.                         ## PARALLEL PORT ##
  1367.                         $vmdeviceString .= "<td>".$parallelport."</td>";
  1368.  
  1369.                         ## PCI PASS THROUGH ##
  1370.                         $vmdeviceString .= "<td>".$pcipassthrough."</td>";
  1371.  
  1372.                         ## POINTING DEVICE ##
  1373.                         $vmdeviceString .= "<td>".$pointingdevice."</td>";
  1374.  
  1375.                         ## SCSI PASS THROUGH ##
  1376.                         $vmdeviceString .= "<td>".$scsipassthrough."</td>";
  1377.                
  1378.                         ## SERIAL PORT ##
  1379.                         $vmdeviceString .= "<td>".$serialport."</td>";
  1380.  
  1381.                         ## SOUND CARD ##
  1382.                         my $soundString = "";
  1383.                         if($ensoniqsoundcard != 0) {
  1384.                             $soundString .= $ensoniqsoundcard . " x Ensoiq1373 Sound Card<br/>";
  1385.                         }
  1386.                         if($blastersoundcard != 0) {
  1387.                             $soundString .= $blastersoundcard . " x Soundblaster Sound Card<br/>";
  1388.                                                 }
  1389.                         if($soundString eq "") { $soundString = "N/A"; }
  1390.                         $vmdeviceString .= "<td>".$soundString."</td>";
  1391.  
  1392.                         ## USB ##
  1393.                         $vmdeviceString .= "<td>".$usb."</td>";                        
  1394.  
  1395.                         $vmdeviceString .= "</tr>\n";
  1396.                     }
  1397.                 }
  1398.                 ######################
  1399.                 # VM STORAGE
  1400.                 ######################
  1401.                 if($VM_STORAGE eq "yes") {
  1402.                                         if(!$vm->config->template && $vm->guest->disk) {
  1403.                                                 $vmstorageString .= "<tr>";
  1404.  
  1405.                                                 ## ESX/ESXi host ##
  1406.                                                 $vmstorageString .= "<td>".$host_name."</td>";
  1407.  
  1408.                                                 ## DISPLAY NAME ##
  1409.                                                 $vmstorageString .= "<td>".$vm->name."</td>";
  1410.  
  1411.                         my $vdisks = $vm->guest->disk;
  1412.                         my $disk_string = "";
  1413.                         foreach my $disk (@$vdisks) {
  1414.                             my $vm_disk_path = $disk->diskPath;
  1415.                             my $vm_disk_free = prettyPrintData($disk->freeSpace,'B');
  1416.                             my $vm_disk_cap = prettyPrintData($disk->capacity,'B');
  1417.                             my $vm_perc_free = &restrict_num_decimal_digits((($disk->freeSpace / $disk->capacity) * 100),2);
  1418.                             my $perc_string = getColor($vm_perc_free);
  1419.                             $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>";  
  1420.                         }
  1421.                         $vmstorageString .= $disk_string;
  1422.                                                 $vmstorageString .= "</tr>\n";
  1423.                                         }
  1424.                                 }
  1425.                 ######################
  1426.                                 # VM NETWORK
  1427.                                 ######################
  1428.                 if($VM_NETWORK eq "yes" && $vm->guest->net) {
  1429.                                         if(!$vm->config->template) {
  1430.                                                 $vmnetworkString .= "<tr>";
  1431.  
  1432.                                                 ## ESX/ESXi host ##
  1433.                                                 $vmnetworkString .= "<td>".$host_name."</td>";
  1434.  
  1435.                                                 ## DISPLAY NAME ##
  1436.                                                 $vmnetworkString .= "<td>".$vm->name."</td>";
  1437.  
  1438.                         my ($vm_ip_string,$vm_mac_string,$vm_pg_string,$vm_connect_string) = ("","","","");
  1439.  
  1440.                         my $vnics = $vm->guest->net;
  1441.                         foreach(@$vnics) {
  1442.                             ## IP ADDRESS ##
  1443.                             if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  1444.                                 if($_->ipConfig) {
  1445.                                     my $ips = $_->ipConfig->ipAddress;
  1446.                                     foreach(@$ips) {
  1447.                                         if($demo eq "no") {
  1448.                                                                                         $vm_ip_string .= $_->ipAddress."<br/>";
  1449.                                                                                 } else {
  1450.                                                                                         $vm_ip_string .= "demo_mode<br/>";
  1451.                                                                                 }
  1452.                                     }
  1453.                                 } else { $vm_ip_string .= "N/A<br/>"; }
  1454.                             } else {
  1455.                                 if($_->ipAddress) {
  1456.                                     my $ips = $_->ipAddress;
  1457.                                     foreach(@$ips) {
  1458.                                         if($demo eq "no") {
  1459.                                             $vm_ip_string .= $_."<br/>";
  1460.                                         } else {
  1461.                                             $vm_ip_string .= "demo_mode<br/>";
  1462.                                         }
  1463.                                     }
  1464.                                 } else {
  1465.                                     $vm_ip_string .= "N/A<br/>";
  1466.                                 }
  1467.                             }
  1468.  
  1469.                             ## MAC ADDRESS ##
  1470.                             if($_->macAddress) {
  1471.                                 if($demo eq "no") {
  1472.                                     $vm_mac_string .= $_->macAddress."<br/>";
  1473.                                 } else {
  1474.                                                                         $vm_mac_string .= "demo_mode<br/>";
  1475.                                                                 }
  1476.                             } else {
  1477.                                 $vm_mac_string .= "N/A<br/>";
  1478.                             }
  1479.    
  1480.                             ## PORTGROUP ##
  1481.                             if($_->network) {
  1482.                                 if($demo eq "no") {
  1483.                                     $vm_pg_string .= $_->network."<br/>";
  1484.                                 } else {
  1485.                                                                         $vm_pg_string .= "demo_mode<br/>";
  1486.                                                                 }
  1487.                             } else {
  1488.                                 $vm_pg_string .=  "N/A<br/>";
  1489.                             }
  1490.  
  1491.                             ## CONNECTED ##
  1492.                             $vm_connect_string .= ($_->connected ? "YES<br/>" : "NO<br/>");
  1493.                         }  
  1494.                         $vmnetworkString .= "<td>".$vm_ip_string."</td><td>".$vm_mac_string."</td><td>".$vm_pg_string."</td><td>".$vm_connect_string."</td>";
  1495.                                                 $vmnetworkString .= "</tr>\n";
  1496.                                         }
  1497.                                 }
  1498.                 ######################
  1499.                 # SNAPSHOT
  1500.                 ######################
  1501.                 if($VM_SNAPSHOT eq "yes") {
  1502.                                         if(!$vm->config->template) {
  1503.                         if($vm->snapshot) {
  1504.                             &getSnapshotTree($host_name,$vm->name,$vm->snapshot->currentSnapshot,$vm->snapshot->rootSnapshotList);
  1505.                             foreach(@vmsnapshots) {
  1506.                                 $vmsnapString .= "<tr>".$_."</tr>\n";
  1507.                             }
  1508.                             @vmsnapshots = ();
  1509.                         }
  1510.                                         }
  1511.                                 }
  1512.                 ######################
  1513.                 # CDROM
  1514.                 ######################
  1515.                 if($VM_CDROM eq "yes") {
  1516.                                         if(!$vm->config->template) {
  1517.                         my $devices = $vm->config->hardware->device;
  1518.                                                 my ($cd_string) = ("");
  1519.                                                 my $hasCD = 0;
  1520.                                                 foreach(@$devices) {
  1521.                                                         if($_->isa('VirtualCdrom') && $_->connectable->connected) {
  1522.                                 $hasCD = 1;
  1523.                                 if($_->deviceInfo->summary) {
  1524.                                     $cd_string .= $_->deviceInfo->summary."<br/>";
  1525.                                 } else {
  1526.                                     $cd_string .= "N/A";
  1527.                                 }
  1528.                                                         }
  1529.                                                 }
  1530.                                                 if($hasCD eq 1) {
  1531.                                                         $vmcdString .= "<tr>";
  1532.  
  1533.                                                         ## ESX/ESXi host ##
  1534.                                                         $vmcdString .= "<td>".$host_name."</td>";
  1535.  
  1536.                                                         ## DISPLAY NAME ##
  1537.                                                         $vmcdString .= "<td>".$vm->name."</td>";
  1538.  
  1539.                             ## ISO ##
  1540.                             $vmcdString .= "<td>".$cd_string."</td>";
  1541.  
  1542.                                                         $vmcdString .= "</tr>\n";
  1543.                                                 }
  1544.  
  1545.                                         }
  1546.                                 }
  1547.                 ######################
  1548.                 # FLOPPY
  1549.                 ######################
  1550.                 if($VM_FLOPPY eq "yes") {
  1551.                                         if(!$vm->config->template) {
  1552.                         my $devices = $vm->config->hardware->device;
  1553.                                                 my ($flp_string) = ("");
  1554.                                                 my $hasFLP = 0;
  1555.                                                 foreach(@$devices) {
  1556.                                                         if($_->isa('VirtualFloppy') && $_->connectable->connected) {
  1557.                                                                 $hasFLP = 1;
  1558.                                                                 if($_->deviceInfo->summary) {
  1559.                                                                         $flp_string .= $_->deviceInfo->summary."<br/>";
  1560.                                                                 } else {
  1561.                                                                         $flp_string .= "N/A";
  1562.                                                                 }
  1563.                                                         }
  1564.                                                 }
  1565.                                                 if($hasFLP eq 1) {
  1566.                                                         $vmflpString .= "<tr>";
  1567.  
  1568.                                                         ## ESX/ESXi host ##
  1569.                                                         $vmflpString .= "<td>".$host_name."</td>";
  1570.  
  1571.                                                         ## DISPLAY NAME ##
  1572.                                                         $vmflpString .= "<td>".$vm->name."</td>";
  1573.  
  1574.                                                         ## FLP ##
  1575.                                                         $vmflpString .= "<td>".$flp_string."</td>";
  1576.  
  1577.                                                         $vmflpString .= "</tr>\n";
  1578.                                                 }
  1579.                                         }
  1580.                                 }
  1581.                 ######################
  1582.                                 # TOOLS
  1583.                                 ######################
  1584.                 if($VM_TOOL eq "yes") {
  1585.                                         if(!$vm->config->template) {
  1586.                         $vmtoolString .= "<tr>";
  1587.  
  1588.                         ## ESX/ESXi host ##
  1589.                                                 $vmtoolString .= "<td>".$host_name."</td>";
  1590.  
  1591.                                                 ## DISPLAY NAME ##
  1592.                                                 $vmtoolString .= "<td>".$vm->name."</td>";
  1593.  
  1594.                         if($vm->guest) {
  1595.                             ## TOOLS VERSION ##
  1596.                                                         $vmtoolString .= "<td>".($vm->guest->toolsVersion ? $vm->guest->toolsVersion : "N/A")."</td>";
  1597.  
  1598.                             ## TOOLS RUNNING STATUS ##
  1599.                             $vmtoolString .= "<td>".($vm->guest->toolsRunningStatus ? $vm->guest->toolsRunningStatus : "N/A")."</td>";                         
  1600.                             ## TOOLS VERSION STATUS ##
  1601.                             if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  1602.                                 $vmtoolString .= "<td>".($vm->guest->toolsVersionStatus2 ? $vm->guest->toolsVersionStatus2 : "N/A")."</td>";
  1603.                             } else {
  1604.                                 $vmtoolString .= "<td>".($vm->guest->toolsVersionStatus ? $vm->guest->toolsVersionStatus : "N/A")."</td>";
  1605.                             }
  1606.                         } else {
  1607.                             $vmtoolString .= "<td>N/A</td>";
  1608.                             $vmtoolString .= "<td>N/A</td>";
  1609.                             $vmtoolString .= "<td>N/A</td>";
  1610.                         }
  1611.                         if($vm->config->tools) {
  1612.                             ## TOOLS UPGRADE POLICY ## 
  1613.                             $vmtoolString .= "<td>".($vm->config->tools->toolsUpgradePolicy ? $vm->config->tools->toolsUpgradePolicy : "N/A")."</td>";
  1614.  
  1615.                             ## SYNC TIME ##
  1616.                             $vmtoolString .= "<td>".($vm->config->tools->syncTimeWithHost ? "YES" : "NO")."</td>";
  1617.                                                 } else {
  1618.                             $vmtoolString .= "<td>N/A</td>";
  1619.                             $vmtoolString .= "<td>N/A</td>";
  1620.                         }
  1621.                         $vmtoolString .= "</tr>\n";
  1622.                                         }
  1623.                                 }
  1624.                 ######################
  1625.                 # RDM
  1626.                 ######################
  1627.                 if($VM_RDM eq "yes") {
  1628.                                         if(!$vm->config->template) {
  1629.                         my $devices = $vm->config->hardware->device;
  1630.                                                 my $hasRDM = 0;
  1631.                                                 foreach(@$devices) {
  1632.                             my ($rdm_string) = ("");
  1633.                                                         if($_->isa('VirtualDisk') && ($_->backing->isa('VirtualDiskRawDiskVer2BackingInfo') || $_->backing->isa('VirtualDiskRawDiskMappingVer1BackingInfo'))) {
  1634.                                                                 $hasRDM = 1;
  1635.                                 my $compat_mode = ($_->backing->compatibilityMode ? $_->backing->compatibilityMode : "N/A");
  1636.                                 my $vmhba = ($_->backing->deviceName ? $_->backing->deviceName : "N/A");
  1637.                                                         my $disk_mode = ($_->backing->diskMode ? $_->backing->diskMode : "N/A");
  1638.                                                         my $lun_uuid = ($_->backing->lunUuid ? $_->backing->lunUuid : "N/A");
  1639.                                                         my $vm_uuid = ($_->backing->uuid ? $_->backing->uuid : "N/A");
  1640.                                                                 $rdm_string .= "<td>".$compat_mode."</td><td>".$vmhba."</td><td>".$disk_mode."</td><td>".$lun_uuid."</td><td>".$vm_uuid."</td>";
  1641.                                                        
  1642.                                                 #}
  1643.                                                 #if($hasRDM eq 1) {
  1644.                                                         $vmrdmString .= "<tr>";
  1645.  
  1646.                                                         ## ESX/ESXi host ##
  1647.                                                         $vmrdmString .= "<td>".$host_name."</td>";
  1648.  
  1649.                                                         ## DISPLAY NAME ##
  1650.                                                         $vmrdmString .= "<td>".$vm->name."</td>";
  1651.  
  1652.                                                         ## RDM ##
  1653.                                                         $vmrdmString .= $rdm_string;
  1654.  
  1655.                                                         $vmrdmString .= "</tr>\n";
  1656.                                                 }}
  1657.                                         }
  1658.                                 }
  1659.                 ######################
  1660.                 # NPIV
  1661.                 ######################
  1662.                 if($VM_NPIV eq "yes") {
  1663.                                         if(!$vm->config->template) {
  1664.                         if($vm->config->npivNodeWorldWideName && $vm->config->npivPortWorldWideName) {
  1665.                                                     $vmnpivString .= "<tr>";
  1666.    
  1667.                                                     ## ESX/ESXi host ##
  1668.                                                     $vmnpivString .= "<td>".$host_name."</td>";
  1669.  
  1670.                                                     ## DISPLAY NAME ##
  1671.                                                     $vmnpivString .= "<td>".$vm->name."</td>";
  1672.                        
  1673.                             my $nwwns = $vm->config->npivNodeWorldWideName;
  1674.                             my $pwwns = $vm->config->npivPortWorldWideName;    
  1675.                             my $type = ($vm->config->npivWorldWideNameType ? $vm->config->npivWorldWideNameType : "N/A");
  1676.                             my $desirednwwn = ($vm->config->npivDesiredNodeWwns ? $vm->config->npivDesiredNodeWwns : "N/A");
  1677.                             my $desiredpwwn = ($vm->config->npivDesiredPortWwns ? $vm->config->npivDesiredPortWwns : "N/A");   
  1678.                             my $npiv_string = "<td>";
  1679.                             foreach(@$nwwns) {
  1680.                                 my $nwwn = (Math::BigInt->new($_))->as_hex();
  1681.                                 $nwwn =~ s/^..//;
  1682.                                 $nwwn = join(':', unpack('A2' x 8, $nwwn));
  1683.                                 if($demo eq "no") {
  1684.                                     $npiv_string .= "$nwwn<br/>";
  1685.                                 } else {
  1686.                                     $npiv_string .= "XX:XX:XX:XX:XX:XX:XX:XX<br/>";
  1687.                                 }
  1688.                             }
  1689.                             $npiv_string .= "</td><td>";
  1690.                             foreach(@$pwwns) {
  1691.                                 my $pwwn = (Math::BigInt->new($_))->as_hex();
  1692.                                                     $pwwn =~ s/^..//;
  1693.                                                     $pwwn = join(':', unpack('A2' x 8, $pwwn));
  1694.                                 if($demo eq "no") {
  1695.                                                             $npiv_string .= "$pwwn<br/>";
  1696.                                                     } else {
  1697.                                     $npiv_string .= "XX:XX:XX:XX:XX:XX:XX:XX<br/>";
  1698.                                 }
  1699.                                                         }
  1700.                             my $npivtype = "";
  1701.                             if($type eq "vc") { $npivtype = "Virtual Center"; }
  1702.                             elsif($type eq "external") { $npivtype = "External Source"; }
  1703.                             elsif($type eq "host") { $npivtype = "ESX or ESXi"; }
  1704.                             $npiv_string .= "</td><td>".$npivtype."</td><td>".$desirednwwn."</td><td>".$desiredpwwn."</td>";
  1705.  
  1706.                             $vmnpivString .= $npiv_string;
  1707.                                                     $vmnpivString .= "</tr>\n";
  1708.                         }
  1709.                                         }
  1710.                                 }
  1711.  
  1712.  
  1713.                 if($VM_STATS eq "yesaaaaa") {
  1714.                                         if(!$vm->config->template) {
  1715.                         $vmstatString .= "<tr>";
  1716.  
  1717.                         ## ESX/ESXi host ##
  1718.                                                 $vmstatString .= "<td>".$host_name."</td>";
  1719.  
  1720.                                                 ## DISPLAY NAME ##
  1721.                                                 $vmstatString .= "<td>".$vm->name."</td>";
  1722.  
  1723.  
  1724.                         $vmstatString .= "</tr>\n";
  1725.                                         }
  1726.                                 }
  1727.        
  1728.                 ## STOP ###        
  1729.             }
  1730.         }
  1731.  
  1732.         ######################
  1733.                 # DLETA
  1734.                 ######################
  1735.                 if($VM_DELTA eq "yes") {
  1736.             foreach(@vmdeltas) {
  1737.                 $vmdeltaString .= "<tr>".$_."</tr>\n";
  1738.             }
  1739.             @vmdeltas = ();
  1740.                 }
  1741.         &buildVMReport($cluster_name,$cluster_count,$type,$atype,$aversion);
  1742.     }
  1743. }
  1744.  
  1745. sub printHostSummary {
  1746.     my ($local_hosts,$cluster_name,$cluster_count,$type,$atype,$aversion,$sc) = @_;
  1747.  
  1748.     if(@$local_hosts) {
  1749.         foreach my $local_host(sort {$a->summary->config->name cmp $b->summary->config->name} @$local_hosts) {
  1750.             if($demo eq "no") {
  1751.                 $host_name = $local_host->name;
  1752.             }
  1753.  
  1754.             #skip if host is not accessible
  1755.             next if($local_host->runtime->connectionState->val ne "connected");
  1756.  
  1757.             #skip if VM is not in valid list
  1758.                     if($hostlist) {
  1759.                             next if(!$hostlists{$local_host->name});
  1760.                         }
  1761.  
  1762.             #capture unique hosts for later use
  1763.             push @hosts_seen,$host_name;
  1764.  
  1765.             #host api version
  1766.             my $hostAPIVersion = $local_host->config->product->version;
  1767.  
  1768.             ######################
  1769.             # HARDWARE
  1770.             ######################
  1771.             if($HOST_HARDWARE_CONFIGURATION eq "yes") {
  1772.                 $hardwareConfigurationString .= "<tr>";
  1773.                 $hardwareConfigurationString .= "<td>".$host_name."</td>";
  1774.                 $hardwareConfigurationString .= "<td>".$local_host->summary->hardware->vendor."</td>";
  1775.  
  1776.                 my $additional_vendor_info = "";
  1777.                 if($local_host->summary->hardware->otherIdentifyingInfo) {
  1778.                     my $add_info = $local_host->summary->hardware->otherIdentifyingInfo;
  1779.                             foreach (@$add_info) {
  1780.                                         $additional_vendor_info .= $_->identifierType->key.": ".$_->identifierValue." ";
  1781.                                 }
  1782.                                 if($additional_vendor_info eq '') {
  1783.                                         $additional_vendor_info = "UNKNOWN";
  1784.                                 }
  1785.                 }
  1786.                 $hardwareConfigurationString .= "<td>".$additional_vendor_info."</td>";
  1787.                 $hardwareConfigurationString .= "<td>".$local_host->summary->hardware->model."</td>";
  1788.                 $hardwareConfigurationString .= "<td>".$local_host->summary->hardware->cpuModel."</td>";
  1789.                 if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  1790.                     $hardwareConfigurationString .= "<td>".(($local_host->hardware->smcPresent) ? "YES" : "NO")."</td>";
  1791.                 } else { $hardwareConfigurationString .= "<td>N/A</td>"; }
  1792.                 $hardwareConfigurationString .= "<td>".(($local_host->config->hyperThread->available) ? "YES" : "NO")."</td>";
  1793.                 $hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->hardware->numCpuCores*$local_host->summary->hardware->cpuMhz,'MHZ')."</td>";
  1794.                 $hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->quickStats->overallCpuUsage,'MHZ')."</td>";
  1795.                 $hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numCpuPkgs."</td>";
  1796.                 $hardwareConfigurationString .= "<td>".($local_host->summary->hardware->numCpuCores/$local_host->summary->hardware->numCpuPkgs)."</td>";
  1797.                 $hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numCpuThreads."</td>";
  1798.                 $hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->hardware->memorySize,'B')."</td>";
  1799.                 $hardwareConfigurationString .= "<td>".prettyPrintData($local_host->summary->quickStats->overallMemoryUsage,'M')."</td>";
  1800.                 $hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numNics."</td>";
  1801.                 $hardwareConfigurationString .= "<td>".$local_host->summary->hardware->numHBAs."</td>";
  1802.                 $hardwareConfigurationString .= "</tr>\n";
  1803.             }
  1804.             ######################
  1805.             # MGMT
  1806.             ######################
  1807.             if($HOST_MGMT eq "yes") {
  1808.                 $mgmtString .= "<tr>";
  1809.            
  1810.                 $mgmtString .= "<td>".$host_name."</td>";
  1811.    
  1812.                 my $mgmtIp = "N/A";
  1813.                 if($local_host->summary->managementServerIp) {
  1814.                     if($demo eq "no") {
  1815.                         my ($ipaddress,$dnsname) = ("N/A","N/A");
  1816.                         eval {
  1817.                             $ipaddress = inet_aton($local_host->summary->managementServerIp);
  1818.                             if($debug) { print "---DEBUG managementServerIp: " . $local_host->summary->managementServerIp . " ---\n"; }
  1819.                             $dnsname = gethostbyaddr($ipaddress, AF_INET);
  1820.                             if(!defined($dnsname)) {
  1821.                                 $dnsname = "N/A";
  1822.                             }
  1823.                             if($debug) { print "---DEBUG dnsname: " . $dnsname . " ---\n"; }
  1824.                         };
  1825.                         if(!$@) {
  1826.                             $mgmtIp = $local_host->summary->managementServerIp . " ( $dnsname )";
  1827.                         } else {
  1828.                             $mgmtIp = $local_host->summary->managementServerIp . " ( UNKNOWN )";
  1829.                         }
  1830.                     } else {
  1831.                         $mgmtIp = "demo_mode";
  1832.                     }
  1833.                 }
  1834.    
  1835.                 $mgmtString .= "<td>".$mgmtIp."</td>";
  1836.  
  1837.                 if($atype eq "VirtualCenter") {
  1838.                                         if($local_host->summary->config->product) {
  1839.                                             $mgmtString .= "<td>".($local_host->config->adminDisabled ? "YES" : "NO")."</td>";
  1840.                                         }
  1841.                                 } else {
  1842.                     $mgmtString .= "<td>UNKNOWN</td>";
  1843.                 }
  1844.  
  1845.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  1846.                     if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  1847.                         my $systemFile = "";
  1848.                         if($local_host->config->systemFile) {
  1849.                             my $systemfile = $local_host->config->systemFile;
  1850.                             foreach(@$systemfile) {
  1851.                                 $systemFile .= $_ . "<br/>";
  1852.                             }
  1853.                         } else {
  1854.                             $systemFile = "N/A";
  1855.                         }
  1856.                         $mgmtString .= "<td>$systemFile</td>";
  1857.                     } else {
  1858.                         $mgmtString .= "<td>N/A</td>";
  1859.                     }
  1860.                 }
  1861.                
  1862.                 $mgmtString .= "<td>".$local_host->summary->hardware->uuid."</td>";
  1863.                 if($local_host->config->consoleReservation) {
  1864.                     $mgmtString .= "<td>".($local_host->config->consoleReservation->serviceConsoleReserved ? &prettyPrintData($local_host->config->consoleReservation->serviceConsoleReserved,'B') : "N/A")."</td>";
  1865.                 } else {
  1866.                     $mgmtString .= "<td>N/A</td>";
  1867.                 }
  1868.  
  1869.                 $mgmtString .= "</tr>\n";  
  1870.             }
  1871.             ######################
  1872.             # STATE
  1873.             ###################### 
  1874.             if($HOST_STATE eq "yes") {
  1875.                 $stateString .= "<tr>";
  1876.                                 $stateString .= "<td>".$host_name."</td>";
  1877.                 my $host_health .= $local_host->overallStatus->val;
  1878.                 if ($host_health eq 'green') { $stateString .= "<td bgcolor=\"$green\">HOST is OK</td>"; }
  1879.                         elsif ($host_health eq 'red') { $stateString .= "<td bgcolor=\"$red\">HOST has a problem</td>"; }
  1880.                         elsif ($host_health eq 'yellow') { $stateString .= "<td bgcolor=\"$yellow\">HOST might have a problem</td>"; }
  1881.                         else { $stateString .= "<td bgcolor=\"gray\">UNKNOWN</td>"; }
  1882.                 $stateString .= "<td>".$local_host->runtime->powerState->val."</td>";
  1883.                 if($local_host->runtime->bootTime) { $stateString .= "<td>".$local_host->runtime->bootTime."</td>"; }
  1884.                 else { $stateString .= "<td>UNKNOWN</td>"; }
  1885.            
  1886.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  1887.                                         if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  1888.                         if($local_host->summary->quickStats->uptime) {
  1889.                             my $uptime = $local_host->summary->quickStats->uptime;
  1890.                             $stateString .= "<td>".&getUptime($uptime)."</td>";
  1891.                         }
  1892.                                         else { $stateString .= "<td>UNKNOWN</td>"; }
  1893.                     } else {
  1894.                         $stateString .= "<td>N/A</td>";
  1895.                     }
  1896.                 }
  1897.  
  1898.                 if(($aversion eq '5.0.0' || $aversion eq '5.1.0') && $atype eq "VirtualCenter") {
  1899.                     if($local_host->runtime->dasHostState) {
  1900.                         $stateString .= "<td>".$local_host->runtime->dasHostState->state."</td>";
  1901.                     } else {
  1902.                         $stateString .= "<td>N/A</td>";
  1903.                     }  
  1904.                 } else {
  1905.                     $stateString .= "<td>N/A</td>";
  1906.                 }
  1907.  
  1908.                 $stateString .= "<td>".$local_host->runtime->connectionState->val."</td>";
  1909.                 $stateString .= "<td>".(($local_host->summary->runtime->inMaintenanceMode) ? "YES" : "NO")."</td>";
  1910.                
  1911.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  1912.                                         if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  1913.                         $stateString .= "<td>".(($local_host->runtime->standbyMode) ? $local_host->runtime->standbyMode : "N/A")."</td>";
  1914.                     } else {
  1915.                         $stateString .= "<td>N/A</td>";
  1916.                     }
  1917.                 }
  1918.  
  1919.                 $stateString .= "<td>".(($local_host->summary->config->vmotionEnabled) ? "YES" : "NO")."</td>";
  1920.                 $stateString .= "<td>".${$local_host->summary->config->product}{'fullName'}."</td>";
  1921.                 $stateString .= "</tr>\n";
  1922.             }
  1923.             ######################
  1924.             # HEALTH
  1925.             ######################
  1926.             if($HOST_HEALTH eq "yes") {
  1927.                 if($local_host->runtime->healthSystemRuntime) {
  1928.                     if($local_host->runtime->healthSystemRuntime->hardwareStatusInfo) {
  1929.                         my $hardwareStatusInfo = $local_host->runtime->healthSystemRuntime->hardwareStatusInfo;
  1930.                         my ($cpuInfo,$memInfo,$storageInfo);
  1931.                         $healthHardwareString .= "<tr><th align=\"left\">".$host_name."</th></tr>\n";
  1932.                         my ($sensor_health_color,$sensor_health) = ("","");;
  1933.  
  1934.                         if($hardwareStatusInfo->cpuStatusInfo) {
  1935.                             $cpuInfo = $hardwareStatusInfo->cpuStatusInfo;
  1936.                             foreach(@$cpuInfo) {
  1937.                                 $sensor_health = $_->status->key;
  1938.                                 if ($sensor_health =~ m/green/i) { $sensor_health_color="<td bgcolor=\"$green\">OK</td>"; }
  1939.                                 elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
  1940.                                                             elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
  1941.                                                             else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
  1942.                                 $healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";       
  1943.                             }
  1944.                         }
  1945.                         if($hardwareStatusInfo->memoryStatusInfo) {
  1946.                             $memInfo = $hardwareStatusInfo->memoryStatusInfo;
  1947.                             foreach(@$memInfo) {
  1948.                                 $sensor_health = $_->status->key;
  1949.                                                                 if ($sensor_health =~ m/green/i) { $sensor_health_color="<td bgcolor=\"$green\">OK</td>"; }
  1950.                                                                 elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
  1951.                                                                 elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
  1952.                                                                 else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
  1953.                                                                 $healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";
  1954.                             }
  1955.                         }
  1956.                         if($hardwareStatusInfo->storageStatusInfo) {
  1957.                             $storageInfo = $hardwareStatusInfo->storageStatusInfo;
  1958.                             foreach(@$storageInfo) {
  1959.                                 $sensor_health = $_->status->key;
  1960.                                                                 if ($sensor_health =~ m/green/i) { $sensor_health_color="<td bgcolor=\"$green\">OK</td>"; }
  1961.                                                                 elsif ($sensor_health_color =~ m/red/i) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
  1962.                                                                 elsif ($sensor_health_color =~ m/yellow/i) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
  1963.                                                                 else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
  1964.                                                                 $healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";
  1965.                             }
  1966.                         }
  1967.                     }
  1968.                     if($local_host->runtime->healthSystemRuntime->systemHealthInfo) {
  1969.                         my $sensors = $local_host->runtime->healthSystemRuntime->systemHealthInfo->numericSensorInfo;
  1970.                         $healthSoftwareString .= "<tr><th align=\"left\">".$host_name."</th></tr>\n";
  1971.                         my $sensor_health_color = "";
  1972.                         foreach(sort {$a->name cmp $b->name} @$sensors) {
  1973.                             my $sensor_health = $_->healthState->key;
  1974.                             if ($sensor_health =~ m/green/) { $sensor_health_color="<td bgcolor=\"$green\">OK</td>"; }
  1975.                             elsif ($sensor_health_color =~ m/red/) { $sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; }
  1976.                             elsif ($sensor_health_color =~ m/yellow/) { $sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; }
  1977.                             else { $sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; }
  1978.  
  1979.                             my $reading;
  1980.                             if(defined($_->rateUnits)) {
  1981.                                 $reading =  &restrict_num_decimal_digits(($_->currentReading * (10 ** $_->unitModifier)),3) . " " . $_->baseUnits . "/" . $_->rateUnits;
  1982.                             } else {
  1983.                                 $reading =  &restrict_num_decimal_digits(($_->currentReading * (10 ** $_->unitModifier)),3) . " " . $_->baseUnits;
  1984.                             }
  1985.                             $healthSoftwareString .= "<tr><td>".$_->name."</td><td>".$reading."</td>".$sensor_health_color."</tr>\n";
  1986.                         }  
  1987.                     }
  1988.                 }
  1989.             }
  1990.             ######################
  1991.             # PERFORMANCE
  1992.             ######################
  1993.             if($HOST_PERFORMANCE eq "yes" || $hostperformance eq "yes") {
  1994.                 my $hostperf = &getCpuAndMemPerf($local_host);
  1995.                 $hostPerfString .= $hostperf;
  1996.             }
  1997.             ######################
  1998.             # NIC
  1999.             ######################
  2000.             if($HOST_NIC eq "yes") {
  2001.                 my $nics = $local_host->config->network->pnic;
  2002.                 foreach my $nic (@$nics) {
  2003.                     $nicString .= "<tr><td>".$host_name."</td>";
  2004.                     $nicString .= "<td>".$nic->device."</td><td>".$nic->pci."</td><td>".$nic->driver."</td>";
  2005.                     if($nic->linkSpeed) {
  2006.                         $nicString .= "<td>".(($nic->linkSpeed->duplex) ? "FULL DUPLEX" : "HALF-DUPLEX")."</td><td>".$nic->linkSpeed->speedMb." MB</td>";
  2007.                     } else {
  2008.                         $nicString .= "<td>UNKNOWN</td><td>UNKNOWN</td>";
  2009.                     }
  2010.                     $nicString .= "<td>".(($nic->wakeOnLanSupported) ? "YES" : "NO")."</td>";
  2011.                     if($demo eq "no") {
  2012.                         $nicString .= "<td>".$nic->mac."</td></tr>\n";
  2013.                     } else {
  2014.                         $nicString .= "<td>demo_mode</td></tr>\n";
  2015.                     }
  2016.                 }
  2017.                 }
  2018.             ######################
  2019.             # HBA
  2020.             ######################
  2021.             if($HOST_HBA eq "yes") {
  2022.                 my $hbas;
  2023.                 eval { $hbas = $local_host->config->storageDevice->hostBusAdapter; };
  2024.                 if(!$@) {
  2025.                     foreach my $hba (@$hbas) {
  2026.                         $hbaString .= "<tr><td>".$host_name."</td>";
  2027.                         if($hba->isa("HostFibreChannelHba")) {
  2028.                             my $hbaType = "FC";
  2029.                             my ($fcfMac,$vnportMac) = ("","");
  2030.                             if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2031.                                 if($hba->isa("HostFibreChannelOverEthernetHba")) {
  2032.                                     $hbaType = "FCoE";
  2033.                                     $fcfMac = $hba->linkInfo->fcfMac;
  2034.                                     $vnportMac = $hba->linkInfo->vnportMac;
  2035.                                 }
  2036.                             }
  2037.                             my $nwwn = (Math::BigInt->new($hba->nodeWorldWideName))->as_hex();
  2038.                             my $pwwn = (Math::BigInt->new($hba->portWorldWideName))->as_hex();
  2039.                             $nwwn =~ s/^..//;
  2040.                             $pwwn =~ s/^..//;
  2041.                             $nwwn = join(':', unpack('A2' x 8, $nwwn));
  2042.                             $pwwn = join(':', unpack('A2' x 8, $pwwn));
  2043.  
  2044.                             if($demo eq "yes") {
  2045.                                 $nwwn = "XX:XX:XX:XX:XX:XX:XX:XX";
  2046.                                                                 $pwwn = "XX:XX:XX:XX:XX:XX:XX:XX";
  2047.                                                                 $fcfMac = "XX:XX:XX:XX:XX:XX";
  2048.                                                                 $vnportMac = "XX:XX:XX:XX:XX:XX";
  2049.                             }
  2050.                             $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>";
  2051.                             if(($aversion eq '5.0.0' || $aversion eq '5.1.0') && $hbaType eq "FCoE") {
  2052.                                 $hbaString .= "<td><b><FCFMAC</b> ".$fcfMac."</td><td><b>VNPORTMAC</b> ".$vnportMac."</td>";
  2053.                             }
  2054.                             $hbaString .= "<td><b>PORT TYPE</b> ".$hba->portType->val."</td><td><b>SPEED</b> ".$hba->speed."</td></td>";
  2055.                         } elsif($hba->isa("HostInternetScsiHba")) {
  2056.                             $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>";
  2057.                         } elsif($hba->isa("HostParallelScsiHba")) {
  2058.                             $hbaString .= "<td>SCSI</td><td>".$hba->device."</td><td>".$hba->pci."</td><td>".$hba->model."</td><td>".$hba->driver."</td><td>".$hba->status."</td>";
  2059.                         } elsif($hba->isa("HostBlockHba")) {
  2060.                             $hbaString .= "<td>BLOCK</td><td>".$hba->device."</td><td>".$hba->pci."</td><td>".$hba->model."</td><td>".$hba->driver."</td><td>".$hba->status."</td>";
  2061.                         }
  2062.                         $hbaString .= "</tr>\n";
  2063.                     }
  2064.                 }
  2065.             }
  2066.             ######################
  2067.             # iSCSI
  2068.             ######################
  2069.             if($HOST_ISCSI eq "yes" && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2070.                 my $hbas;
  2071.                 eval { $hbas = $local_host->config->storageDevice->hostBusAdapter; };
  2072.                 if(!$@) {
  2073.                     my @iSCSIHBAs = ();
  2074.                     foreach my $hba (@$hbas) {
  2075.                         if($hba->isa("HostInternetScsiHba")) {
  2076.                             push @iSCSIHBAs, $hba->device;
  2077.                         }
  2078.                     }
  2079.  
  2080.                     my $iscsiMgr;
  2081.                     eval { $iscsiMgr = Vim::get_view(mo_ref => $local_host->configManager->iscsiManager); };
  2082.                     if(!$@) {
  2083.                         foreach my $iscsiHBA (@iSCSIHBAs) {
  2084.                             my $iscsiPortInfo = $iscsiMgr->QueryBoundVnics(iScsiHbaName => $iscsiHBA);
  2085.                             if(defined($iscsiPortInfo)) {
  2086.                                 foreach my $iscsiPort (@$iscsiPortInfo) {
  2087.                                     $iscsiString .= "<tr>";
  2088.                                     $iscsiString .= "<td>".$host_name."</td>";
  2089.                                     $iscsiString .= "<td>".(defined($iscsiPort->vnicDevice) ? $iscsiPort->vnicDevice : "N/A")."</td>";
  2090.                                     if($iscsiPort->vnic->spec->ip->ipAddress) {
  2091.                                         $iscsiString .= "<td>".$iscsiPort->vnic->spec->ip->ipAddress."</td>";
  2092.                                     } else { $iscsiString .= "<td>N/A</td>"; }
  2093.                                     if($iscsiPort->vnic->spec->ip->subnetMask) {
  2094.                                                                                 $iscsiString .= "<td>".$iscsiPort->vnic->spec->ip->subnetMask."</td>";
  2095.                                                                         } else { $iscsiString .= "<td>N/A</td>"; }
  2096.                                     if($iscsiPort->vnic->spec->mac) {
  2097.                                                                                 $iscsiString .= "<td>".$iscsiPort->vnic->spec->mac."</td>";
  2098.                                                                         } else { $iscsiString .= "<td>N/A</td>"; }
  2099.                                     if($iscsiPort->vnic->spec->mtu) {
  2100.                                                                                 $iscsiString .= "<td>".$iscsiPort->vnic->spec->mtu."</td>";
  2101.                                                                         } else { $iscsiString .= "<td>N/A</td>"; }
  2102.                                     if(defined($iscsiPort->vnic->spec->tsoEnabled)) {
  2103.                                         $iscsiString .= "<td>".($iscsiPort->vnic->spec->tsoEnabled ? "YES" : "NO")."</td>";
  2104.                                                                         } else { $iscsiString .= "<td>N/A</td>"; }
  2105.                                     if($iscsiPort->pnic) {
  2106.                                         $iscsiString .= "<td>".$iscsiPort->pnic->linkSpeed->speedMb . " (" . ($iscsiPort->pnic->linkSpeed->duplex ? "FULL-DUPLEX" : "HALF-DUPLEX") . ")"."</td>";
  2107.                                     } else { $iscsiString .= "<td>N/A</td>"; }
  2108.                                     $iscsiString .= "<td>".(defined($iscsiPort->pnicDevice) ? $iscsiPort->pnicDevice : "N/A")."</td>";
  2109.                                     $iscsiString .= "<td>".(defined($iscsiPort->portgroupName) ? $iscsiPort->portgroupName : "N/A")."</td>";
  2110.                                     $iscsiString .= "<td>".(defined($iscsiPort->switchName) ? $iscsiPort->switchName : "N/A")."</td>";
  2111.                                     $iscsiString .= "<td>".(defined($iscsiPort->switchUuid) ? $iscsiPort->switchUuid : "N/A")."</td>"; 
  2112.                                     $iscsiString .= "<td>".(defined($iscsiPort->pathStatus) ? $iscsiPort->pathStatus : "N/A")."</td>";
  2113.                                     $iscsiString .= "</tr>";
  2114.                                 }
  2115.                             }
  2116.                         }
  2117.                     }
  2118.                 }
  2119.             }
  2120.             ######################
  2121.             # CAPABILITY
  2122.             ######################
  2123.             if($HOST_CAPABILITY eq "yes") {
  2124.                 if($local_host->capability) {
  2125.                     $capString .= "<tr>";
  2126.                                     $capString .= "<td>".$host_name."</td>";
  2127.  
  2128.                     if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2129.                         ## MAX VMS ##
  2130.                         if($local_host->capability->maxHostRunningVms) {
  2131.                             $capString .= "<td>".$local_host->capability->maxHostRunningVms."</td>";
  2132.                         } else { $capString .= "<td>N/A</td>"; }   
  2133.  
  2134.                         ## MAX VCPU ##
  2135.                         if($local_host->capability->maxHostSupportedVcpus) {
  2136.                                                         $capString .= "<td>".$local_host->capability->maxHostSupportedVcpus."</td>";
  2137.                                                 } else { $capString .= "<td>N/A</td>"; }                       
  2138.  
  2139.                         ## VMFS VERSION ##
  2140.                         if($local_host->capability->supportedVmfsMajorVersion) {
  2141.                             $capString .= "<td>".join(",",@{$local_host->capability->supportedVmfsMajorVersion})."</td>";
  2142.                         } else { $capString .= "<td>N/A</td>"; }
  2143.                     }
  2144.  
  2145.                     ## FT ##
  2146.                     $capString .= "<td>".($local_host->capability->ftSupported ? "YES" : "NO")."</td>";
  2147.                    
  2148.                     ## IPMI ##
  2149.                     if($local_host->capability->ipmiSupported) {
  2150.                         $capString .= "<td>".($local_host->capability->ipmiSupported ? "YES" : "NO")."</td>";
  2151.                     } else {
  2152.                         $capString .= "<td>N/A</td>";
  2153.                     }
  2154.  
  2155.                     ## TPM ##
  2156.                     $capString .= "<td>".($local_host->capability->tpmSupported ? "YES" : "NO")."</td>";
  2157.  
  2158.                     ## HV ##
  2159.                     $capString .= "<td>".($local_host->capability->virtualExecUsageSupported ? "YES" : "NO")."</td>";
  2160.    
  2161.                     if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2162.                                             if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  2163.                             ## STORAGE IORM ##
  2164.                             $capString .= "<td>".($local_host->capability->storageIORMSupported ? "YES" : "NO")."</td>";
  2165.                
  2166.                             ## DPG 2 ##
  2167.                             $capString .= "<td>".($local_host->capability->vmDirectPathGen2Supported ? "YES" : "NO")."</td>";
  2168.    
  2169.                             ## vStorage ##
  2170.                             $capString .= "<td>".($local_host->capability->vStorageCapable ? "YES" : "NO")."</td>";
  2171.                         } else {
  2172.                             $capString .= "<td>N/A</td>";
  2173.                             $capString .= "<td>N/A</td>";
  2174.                             $capString .= "<td>N/A</td>";
  2175.                         }
  2176.                     }
  2177.    
  2178.                     ## SSL THUMBPRINT ##
  2179.                     if($local_host->capability->loginBySSLThumbprintSupported) {
  2180.                         $capString .= "<td>".($local_host->capability->loginBySSLThumbprintSupported ? "YES" : "NO")."</td>";
  2181.                     } else {
  2182.                                                 $capString .= "<td>N/A</td>";
  2183.                                         }
  2184.  
  2185.                     $capString .= "</tr>\n";
  2186.                 }
  2187.             }
  2188.             ######################
  2189.             # CONFIGURATIONS
  2190.             ######################
  2191.             if($HOST_CONFIGURATION eq "yes") {
  2192.                 my $netMgr = Vim::get_view(mo_ref => $local_host->configManager->networkSystem);
  2193.            
  2194.                 $configString .= "\n<table border=\"1\">\n<tr><th colspan=3>".$host_name."</th></tr>\n";
  2195.    
  2196.                 #############
  2197.                 ## VMOTION ##
  2198.                 #############
  2199.                 if($HOST_VMOTION eq "yes") {
  2200.                     if($local_host->summary->config->vmotionEnabled) {
  2201.                         $configString .= "<tr><th>VMOTION ENABLED </th><td>YES</td></tr>\n";
  2202.                         if($demo eq "no") {
  2203.                             $configString .= "<tr><th>IP ADDRESS </th><td>".$local_host->config->vmotion->ipConfig->ipAddress." => ".$local_host->summary->config->name."</td></tr>\n";
  2204.                             $configString .= "<tr><th>NETMASK </th><td>".$local_host->config->vmotion->ipConfig->subnetMask."</td></tr>\n";
  2205.                         } else {
  2206.                             $configString .= "<tr><th>IP ADDRESS </th><td>X.X.X.X</td></tr>\n";
  2207.                             $configString .= "<tr><th>NETMASK </th><td>X.X.X.X</td></tr>\n";
  2208.                         }  
  2209.                     }
  2210.                 }
  2211.  
  2212.                 #############
  2213.                 ## GATEWAY ##
  2214.                 #############
  2215.                 if($HOST_GATEWAY eq "yes") {
  2216.                     if($demo eq "no") {
  2217.                         if($netMgr->consoleIpRouteConfig) {
  2218.                             if($netMgr->consoleIpRouteConfig->defaultGateway) {
  2219.                                 $configString .= "<tr><th>GATEWAY </th><td>".$netMgr->consoleIpRouteConfig->defaultGateway."</td></tr>\n";
  2220.                             } else {
  2221.                                 $configString .= "<tr><th>GATEWAY </th><td>0.0.0.0</td></tr>\n";
  2222.                             }
  2223.                             if($netMgr->consoleIpRouteConfig->ipV6DefaultGateway) {
  2224.                                 $configString .= "<tr><th>IPv6 GATEWAY </th><td>".$netMgr->consoleIpRouteConfig->ipV6DefaultGateway."</td></tr>\n";
  2225.                             } else {
  2226.                                 $configString .= "<tr><th>IPv6 GATEWAY </th><td>0.0.0.0</td></tr>\n";
  2227.                             }
  2228.                         } else {
  2229.                             $configString .= "<tr><th>GATEWAY </th><td>N/A</td></tr>\n";
  2230.                             $configString .= "<tr><th>IPv6 GATEWAY </th><td>N/A</td></tr>\n";
  2231.                         }
  2232.                         if($netMgr->ipRouteConfig->defaultGateway) {
  2233.                             $configString .= "<tr><th>VMKERNEL GATEWAY </th><td>".$netMgr->ipRouteConfig->defaultGateway."</td></tr>\n";
  2234.                         } else {
  2235.                         $configString .= "<tr><th>VMKERNEL GATEWAY </th><td>0.0.0.0</td></tr>\n";
  2236.                         }
  2237.                         if($netMgr->ipRouteConfig->ipV6DefaultGateway) {
  2238.                             $configString .= "<tr><th>VMKERNEL IPv6 GATEWAY </th><td>".$netMgr->ipRouteConfig->ipV6DefaultGateway."</td></tr>\n";
  2239.                         } else {
  2240.                             $configString .= "<tr><th>VMKERNEL IPv6 GATEWAY </th><td>0.0.0.0</td></tr>\n";
  2241.                         }
  2242.                     } else {
  2243.                         $configString .= "<tr><th>GATEWAY </th><td>X.X.X.X</td></tr>\n";
  2244.                     }
  2245.                 }
  2246.  
  2247.                 #####################
  2248.                 ## SOFTWARE iSCSI  ##
  2249.                 #####################
  2250.                 if($HOST_ISCSI eq "yes") {
  2251.                     $configString .= "<tr><th>SOFTWAE iSCSI ENABLED</th><td>".($local_host->config->storageDevice->softwareInternetScsiEnabled ? "YES" : "NO")."</td></tr>\n"; 
  2252.                 }              
  2253.  
  2254.                 #############
  2255.                 ## IPV6    ##
  2256.                 #############
  2257.                 if($HOST_IPV6 eq "yes") {
  2258.                     $configString .= "<tr><th>IPv6 ENABLED</th><td>".($local_host->config->network->ipV6Enabled ? "YES" : "NO")."</td></tr>\n";        
  2259.                 }
  2260.  
  2261.                 #############
  2262.                 # FT       ##
  2263.                 #############
  2264.                 if($HOST_FT eq "yes") {
  2265.                     $configString .= "<tr><th>FT ENABLED</th><td>".($local_host->summary->config->faultToleranceEnabled ? "YES" : "NO")."</td></tr>\n";        
  2266.                 }
  2267.  
  2268.                 #############
  2269.                 # SSL      ##
  2270.                 #############
  2271.                 if($HOST_SSL eq "yes") {
  2272.                     $configString .= "<tr><th>SSL THUMBPRINT</th><td>".($local_host->summary->config->sslThumbprint ? $local_host->summary->config->sslThumbprint : "N/A")."</td></tr>\n";
  2273.                 }
  2274.        
  2275.  
  2276.                 #############
  2277.                 ## DNS     ##
  2278.                 #############
  2279.                 if($HOST_DNS eq "yes") {
  2280.                     my $searchDomains = $local_host->config->network->dnsConfig->searchDomain;
  2281.                     my $searchString = "";
  2282.                     foreach(@$searchDomains) {
  2283.                         $searchString .= "search ".$_."<br/>";
  2284.                     }
  2285.                     my $dnsAddress = $local_host->config->network->dnsConfig->address;
  2286.                     my $dnsString = "";
  2287.                     foreach(@$dnsAddress) {
  2288.                         $dnsString .= "nameserver ".$_."<br/>";
  2289.                     }
  2290.                     if($demo eq "no") {
  2291.                         $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";
  2292.                     } else {
  2293.                         $configString .= "<tr><th>DNS</th><td>domain demo_mode<br/>search demo_mode<br/>nameserver demo_mode</td></tr>\n";
  2294.                     }
  2295.                 }
  2296.  
  2297.                 #############
  2298.                 ## UPTIME  ##
  2299.                 #############
  2300.                 if($HOST_UPTIME eq "yes") {
  2301.                     my ($host_date,$host_time) = split('T',$local_host->runtime->bootTime);
  2302.                     my $todays_date = giveMeDate('YMD');
  2303.                     chomp($todays_date);
  2304.                     $configString .= "<tr><th>UPTIME</th><td>".&days_between($host_date, $todays_date)." Days - ".$local_host->runtime->bootTime."</td></tr>\n";
  2305.                 }
  2306.  
  2307.                 #################
  2308.                 ## DIAGONISTIC ##
  2309.                 #################
  2310.                 if($HOST_DIAGONISTIC eq "yes") {
  2311.                     if($local_host->config->activeDiagnosticPartition) {
  2312.                         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>";
  2313.                         $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";
  2314.                     }
  2315.                 }
  2316.  
  2317.                 ###################
  2318.                 ## AUTH SERVICES ##
  2319.                 ###################
  2320.                 if($HOST_AUTH_SERVICE eq "yes" && $hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  2321.                     my $authMgr = Vim::get_view(mo_ref => $local_host->configManager->authenticationManager);
  2322.                     if($authMgr->info) {
  2323.                         my $authConfigs = $authMgr->info->authConfig;
  2324.                         my $authString = "";
  2325.                         foreach(@$authConfigs) {
  2326.                             my ($authType,$authEnabled,$authStatus,$authDomain,$trustedDomains) = ("","","","","");
  2327.                            
  2328.                             if($_->isa('HostLocalAuthenticationInfo')) {
  2329.                                 $authType = "LOCAL";
  2330.                                 $authEnabled = ($_->enabled ? "YES" : "NO");
  2331.                                 $authStatus = "N/A";
  2332.                                 $authDomain = "N/A";
  2333.                                 $trustedDomains = "N/A";
  2334.                             }
  2335.                             elsif($_->isa('HostActiveDirectoryInfo')) {
  2336.                                 $authType = "ACTIVE DIRECTORY";
  2337.                                 $authEnabled = ($_->enabled ? "YES" : "NO");
  2338.                                 $authStatus = ($_->domainMembershipStatus ? $_->domainMembershipStatus : "N/A");
  2339.                                 $authDomain = ($_->joinedDomain ? $_->joinedDomain : "N/A");
  2340.  
  2341.                                 if($_->trustedDomain) {
  2342.                                     my $domains = $_->trustedDomain;
  2343.                                     foreach(@$domains) {
  2344.                                         $trustedDomains .= $_ . "<br/>";
  2345.                                     }
  2346.                                 } else {
  2347.                                     $trustedDomains = "N/A";
  2348.                                 }
  2349.                             }
  2350.                             $authString .= "<tr><td>".$authType."</td><td>".$authEnabled."</td><td>".$authStatus."</td><td>".$authDomain."</td><td>".$trustedDomains."</td></tr>";
  2351.  
  2352.                         }
  2353.                         $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";
  2354.                     }
  2355.                 }
  2356.  
  2357.                 ###############
  2358.                 ## SERVICES  ##
  2359.                 ###############
  2360.                 if($HOST_SERVICE eq "yes") {
  2361.                     my $services = $local_host->config->service->service;
  2362.                     if($services) {
  2363.                         my $serviceString = "";
  2364.                         foreach(@$services) {
  2365.                             $serviceString .= "<tr><td>".$_->label."</td>";
  2366.                             if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2367.                                 if($_->sourcePackage) {
  2368.                                     $serviceString .= "<td>".$_->sourcePackage->sourcePackageName."</td>";
  2369.                                 } else { $serviceString .= "<td>N/A</td>"; }
  2370.                             }
  2371.                             $serviceString .= "<td>".$_->policy."</td><td>".(($_->running) ? "YES" : "NO")."</td></tr>";
  2372.                         }
  2373.                         if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2374.                             $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";
  2375.                         } else {
  2376.                             $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";
  2377.                         }
  2378.                     }  
  2379.                 }
  2380.  
  2381.                 #############
  2382.                 ## NTP     ##  
  2383.                 #############
  2384.                 if($HOST_NTP eq "yes") {
  2385.                     if($local_host->config->dateTimeInfo) {
  2386.                         my $ntps;
  2387.                         eval { $ntps = $local_host->config->dateTimeInfo->ntpConfig->server; };
  2388.                         if(!$@) {
  2389.                             my $ntpString = "";
  2390.                                         if($ntps) {
  2391.                                                 foreach (@$ntps) {
  2392.                                                         $ntpString .= "$_<br/>";
  2393.                                                 }
  2394.                                         } else { $ntpString = "NONE CONFIGURED"; }
  2395.                             $ntpString = "<tr><td>".$ntpString."</td>";
  2396.                             $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>";
  2397.                             $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";
  2398.                         }
  2399.                     }
  2400.                 }
  2401.  
  2402.                 ###########
  2403.                 ## VSWIF ##
  2404.                 ###########
  2405.                 if($HOST_VSWIF eq "yes") {
  2406.                     if($local_host->config->network->consoleVnic) {
  2407.                         my $vswifString = "";
  2408.                         my $console_vnics = $local_host->config->network->consoleVnic;
  2409.                         foreach(@$console_vnics) {
  2410.                             if($demo eq "no") {
  2411.                                 $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>";
  2412.                             } else {
  2413.                                 $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>";
  2414.                             }
  2415.                         }
  2416.                         $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";       
  2417.                     }
  2418.                 }
  2419.  
  2420.                 ##############
  2421.                 ## VMKERNEL ##
  2422.                 ##############
  2423.                 if($HOST_VMKERNEL eq "yes") {
  2424.                     if($local_host->config->network->vnic) {
  2425.                         my $vmkString = "";
  2426.                         my $vmks = $local_host->config->network->vnic;
  2427.                         foreach(@$vmks) {
  2428.                             if($demo eq "no") {
  2429.                                 $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>";
  2430.                             } else {
  2431.                                 $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>";
  2432.                             }
  2433.                         }
  2434.                         $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";
  2435.                     }
  2436.                 }
  2437.  
  2438.                 #############
  2439.                 ## VSWITCH ##
  2440.                 #############
  2441.                 if($HOST_VSWITCH eq "yes") {
  2442.                     my %vmmac_to_portgroup_mapping = ();
  2443.                     my %cdp_enabled = ();
  2444.                     my $vswitches = $local_host->config->network->vswitch;
  2445.            
  2446.                     my $vswitchString = "";
  2447.                                     foreach my $vSwitch(@$vswitches) {
  2448.                         my ($pNicName,$mtu,$cdp_vswitch,$pNicKey) = ("","","","");
  2449.                                             my $vswitch_name = $vSwitch->name;
  2450.                         my $pNics = $vSwitch->pnic;
  2451.  
  2452.                         foreach (@$pNics) {
  2453.                                             $pNicKey = $_;
  2454.                                             if ($pNicKey ne "") {
  2455.                                                     $pNics = $netMgr->networkInfo->pnic;
  2456.                                                     foreach my $pNic (@$pNics) {
  2457.                                                             if ($pNic->key eq $pNicKey) {
  2458.                                                                     $pNicName = $pNicName ? ("$pNicName," . $pNic->device) : $pNic->device;
  2459.                                                                     if($cdp_enabled{$pNic->device}) {
  2460.                                                                             $cdp_vswitch = $cdp_enabled{$pNic->device};
  2461.                                                                     } else {
  2462.                                                                             $cdp_vswitch = "N/A";
  2463.                                                                     }
  2464.                                                             }
  2465.                                                     }
  2466.                                             }
  2467.                                     }
  2468.                         $mtu = $vSwitch->{mtu} if defined($vSwitch->{mtu});
  2469.                         $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";
  2470.                         $vswitchString .= "<tr><th>PORTGROUP NAME</th><th>VLAN ID</th><th>USED PORTS</th><th colspan=3>UPLINKS</th></tr>\n";   
  2471.                         my $portGroups = $vSwitch->portgroup;
  2472.                         foreach my $portgroup(@$portGroups) {
  2473.                             my $pg = FindPortGroupbyKey ($netMgr, $vSwitch->key, $portgroup);
  2474.                             next unless (defined $pg);
  2475.                             my $usedPorts = (defined $pg->port) ? $#{$pg->port} + 1 : 0;
  2476.                             if($demo eq "no") {
  2477.                                 $vswitchString .= "<tr><td>".$pg->spec->name."</td><td>".$pg->spec->vlanId."</td><td>".$usedPorts."</td><td colspan=3>".$pNicName."</td></tr>\n";  
  2478.                             } else {
  2479.                                 $vswitchString .= "<tr><td>demo_mode</td><td>demo_mode</td><td>".$usedPorts."</td><td colspan=3>".$pNicName."</td></tr>\n";
  2480.                             }
  2481.                                                     $vswitch_portgroup_mappping{$pg->spec->name} = $vswitch_name;
  2482.                                             }
  2483.                                     }
  2484.                     $configString .= "<tr><th>VSWITCH(s)</th><td><table border=\"1\">".$vswitchString."</table></td></tr>\n";  
  2485.  
  2486.                     my $networks = Vim::get_views(mo_ref_array => $local_host->network);
  2487.                     foreach my $portgroup(@$networks) {
  2488.                         my $vms_device = Vim::get_views(mo_ref_array => $portgroup->vm, properties => ["config.name","config.hardware.device"]);
  2489.                         foreach(@$vms_device) {
  2490.                             my $vmname = $_->{'config.name'};
  2491.                             my $devices = $_->{'config.hardware.device'};
  2492.  
  2493.                             foreach(@$devices) {
  2494.                                 if($_->isa("VirtualEthernetCard")) {
  2495.                                     $vmmac_to_portgroup_mapping{$vmname} = $portgroup->name;
  2496.                                 }
  2497.                             }
  2498.                         }
  2499.                     }
  2500.                 }
  2501.  
  2502.                 ##########
  2503.                 ## SNMP ##
  2504.                 ##########
  2505.                 if($HOST_SNMP eq "yes") {
  2506.                     my $snmp_system;
  2507.                     eval { $snmp_system = Vim::get_view (mo_ref => $local_host->configManager->snmpSystem); };
  2508.                     if(!$@) {
  2509.                         if($snmp_system->configuration->enabled) {
  2510.                             my $snmpString = "";
  2511.                             $snmpString .= "<tr><td>".$snmp_system->configuration->port."</td><td>";
  2512.                             my $ro_community = $snmp_system->configuration->readOnlyCommunities;
  2513.                             foreach(@$ro_community) {
  2514.                                 $snmpString .= $_ . ", ";
  2515.                             }
  2516.                             $snmpString .= "</td><td>";
  2517.                             my $trap_targets = $snmp_system->configuration->trapTargets;
  2518.                             foreach(@$trap_targets) {
  2519.                                                     $snmpString .= "<b>Community:</b> " . $_->community . " <b>Hostname:</b> " . $_->hostName . " <b>Port:</b> " . $_->port . "<br/>\n";
  2520.                             }
  2521.                             $snmpString .= "</td></tr>";
  2522.                             $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";
  2523.                         }  
  2524.                     }
  2525.                 }
  2526.  
  2527.                 ##############
  2528.                 ## FIREWALL ##
  2529.                 ##############
  2530.                 if($HOST_FIREWALL eq "yes") {
  2531.                     if($local_host->config->firewall) {
  2532.                         my $fw_sys = $local_host->config->firewall;
  2533.                         my $fw_rules = $fw_sys->ruleset;
  2534.                                     my $fw_known_string = "";
  2535.                                     my $fw_rule_string = "";
  2536.                                     foreach my $rule ( sort{$a->label cmp $b->label}@$fw_rules) {
  2537.                                             if($rule->enabled) {
  2538.                                 my ($allowedIPs) = ("");
  2539.                                 if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2540.                                     if(defined($rule->allowedHosts)) {
  2541.                                         if($rule->allowedHosts->allIp) {
  2542.                                             $allowedIPs = "all";
  2543.                                         } else {
  2544.                                             my $ipNetworks = $rule->allowedHosts->ipNetwork;
  2545.                                             foreach(@$ipNetworks) {
  2546.                                                 $allowedIPs .= $_->network . "/" . $_->prefixLength . ", ";
  2547.                                             }
  2548.                                         }
  2549.                                     }
  2550.                                 }
  2551.                                 my $firewallRules = $rule->rule;
  2552.                                 my ($fwDirection,$fwPort,$fwPortType,$fwProto) = ("N/A","N/A","N/A","N/A");
  2553.                                 foreach(@$firewallRules) {
  2554.                                     $fwDirection = $_->direction->val;
  2555.                                     $fwPort = $_->port;
  2556.                                     if($_->endPort) {
  2557.                                         $fwPort .= "-" . $_->endPort;
  2558.                                     }
  2559.                                     if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2560.                                         $fwPortType = $_->portType ? uc($_->portType->val) : "N/A";
  2561.                                     }
  2562.                                     $fwProto = $_->protocol;
  2563.                                     $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";
  2564.                                 }
  2565.                                             }
  2566.                                     }
  2567.                         $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";
  2568.  
  2569.                         my $defaultPolicy = "<tr><td>".($fw_sys->defaultPolicy->incomingBlocked ? "YES" : "NO")."</td><td>".($fw_sys->defaultPolicy->outgoingBlocked ? "YES" : "NO")."</td></tr>\n";
  2570.                         $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";
  2571.                     }
  2572.                 }
  2573.  
  2574.                 ###########
  2575.                 ## POWER ##
  2576.                 ###########
  2577.                 if($HOST_POWER eq "yes") {
  2578.                     if($local_host->hardware->cpuPowerManagementInfo) {
  2579.                         my $cpu_power_info = "";
  2580.                         $cpu_power_info .= "<tr><td>".($local_host->hardware->cpuPowerManagementInfo->currentPolicy)."</td><td>".($local_host->hardware->cpuPowerManagementInfo->hardwareSupport)."</td></tr>";
  2581.                         $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";
  2582.                     }
  2583.                 }
  2584.  
  2585.                 ######################
  2586.                             # FEATURE VERSION
  2587.                             ######################
  2588.                             if($HOST_FEATURE_VERSION eq "yes" && $hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  2589.                     if($local_host->summary->config->featureVersion) {
  2590.                         my $featurever = $local_host->summary->config->featureVersion;
  2591.                         my $featureString = "";
  2592.                         foreach(@$featurever) {
  2593.                             $featureString .= "<tr><td>".$_->key."</td><td>".$_->value."</td></tr>\n";
  2594.                         }
  2595.                         $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";
  2596.                     }  
  2597.                             }
  2598.  
  2599.                 $configString .= "</table>\n";
  2600.             }
  2601.             ######################
  2602.             # ADVANCED OPTIONS
  2603.             ######################
  2604.             if($HOST_ADVOPT eq "yes") {
  2605.                 my $advopts = Vim::get_view(mo_ref => $local_host->configManager->advancedOption);
  2606.                 my $advSettings = $advopts->setting;
  2607.  
  2608.                 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");
  2609.  
  2610.                 foreach(@$advSettings) {
  2611.                     my $key = $_->key;
  2612.                     my $value = $_->value;
  2613.  
  2614.                     if($key eq "Disk.UseDeviceReset") { $diskUDR = $value; }
  2615.                     if($key eq "Disk.UseLunReset") { $diskULR = $value; }
  2616.                     if($key eq "Disk.SchedNumReqOutstanding") { $diskSNRO = $value; }
  2617.                     if($key eq "Scsi.ConflictRetries") { $scsiCR = $value; }
  2618.                     if($key eq "NFS.MaxVolumes") { $nfsMV = $value; }
  2619.                     if($key eq "SendBufferSize") { $SBS = $value; }
  2620.                     if($key eq "ReceiveBufferSize") { $RBS = $value; }
  2621.                     if($key eq "Net.TcpipHeapSize") { $netTHS = $value; }
  2622.                     if($key eq "NFS.HeartbeatFrequency") { $nfsHF = $value; }
  2623.                     if($key eq "NFS.HeartbeatTimeout") { $nfsHT = $value; }
  2624.                     if($key eq "NFS.HeartbeatMaxFailures") { $nfsHMF = $value; }
  2625.                     if($key eq "VMkernel.Boot.techSupportMode") { $vmkernelBSM = $value; }
  2626.                     if($key eq "VMFS3.HardwareAcceleratedLocking") { $vmfs3HAL = $value; }
  2627.                                         if($key eq "DataMover.HardwareAcceleratedMove") { $dataMHAM = $value; }
  2628.                                         if($key eq "DataMover.HardwareAcceleratedInit") { $dataMHAI = $value; }
  2629.                 }
  2630.                 $advString .= "<tr>";
  2631.                 $advString .= "<td>".$host_name."</td>";
  2632.                 $advString .= "<td>".$diskUDR."</td>";
  2633.                 $advString .= "<td>".$diskULR."</td>";
  2634.                 $advString .= "<td>".$diskSNRO."</td>";
  2635.                 $advString .= "<td>".$scsiCR."</td>";
  2636.                 $advString .= "<td>".$nfsMV."</td>";
  2637.                 $advString .= "<td>".$SBS."</td>";
  2638.                 $advString .= "<td>".$RBS."</td>";
  2639.                 $advString .= "<td>".$netTHS."</td>";
  2640.                 $advString .= "<td>".$nfsHF."</td>";
  2641.                 $advString .= "<td>".$nfsHT."</td>";
  2642.                 $advString .= "<td>".$nfsHMF."</td>";
  2643.                 $advString .= "<td>".$vmkernelBSM."</td>";
  2644.                 $advString .= "<td>".$vmfs3HAL."</td>";
  2645.                                 $advString .= "<td>".$dataMHAM."</td>";
  2646.                                 $advString .= "<td>".$dataMHAI."</td>";
  2647.                 $advString .= "</tr>\n";
  2648.             }
  2649.             ######################
  2650.             # HOST AGENT SETTING
  2651.             ######################
  2652.             if($HOST_AGENT eq "yes" && $atype eq "VirtualCenter" && $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  2653.                 if(defined($local_host->configManager->esxAgentHostManager)) {
  2654.                     my $hostAgentMgr = Vim::get_view(mo_ref => $local_host->configManager->esxAgentHostManager);
  2655.                     my ($agentDSName,$agentNetName) = ("N/A","N/A");
  2656.                        
  2657.                     if($hostAgentMgr->configInfo->agentVmDatastore) {
  2658.                         my $agentDSNameTmp = Vim::get_view(mo_ref => $hostAgentMgr->configInfo->agentVmDatastore, properties => ['name']);
  2659.                         $agentDSName = $agentDSNameTmp->{'name'};
  2660.                     }
  2661.                     if($hostAgentMgr->configInfo->agentVmNetwork) {
  2662.                                                 my $agentNetNameTmp = Vim::get_view(mo_ref => $hostAgentMgr->configInfo->agentVmNetwork, properties => ['name']);
  2663.                         $agentNetName = $agentNetNameTmp->{'name'};
  2664.                                         }
  2665.  
  2666.                     if($agentDSName ne "N/A" && $agentNetName ne "N/A") {
  2667.                         $agentString .= "<tr>";
  2668.                         $agentString .= "<td>".$host_name."</td>";
  2669.                         $agentString .= "<td>".$agentDSName."</td>";
  2670.                         $agentString .= "<td>".$agentNetName."</td>";
  2671.                         $agentString .= "</tr>\n";
  2672.                     }
  2673.                 }
  2674.             }
  2675.             ######################
  2676.             # NUMA
  2677.             ######################
  2678.             if($HOST_NUMA eq "yes") {
  2679.                 if($local_host->hardware->numaInfo) {
  2680.                     my $numaInfo = $local_host->hardware->numaInfo;
  2681.                     if($numaInfo->numNodes == 0) {
  2682.                         $numaString .= "<tr><td>".$host_name."</td><td>NUMA-incapable</td><td>".$numaInfo->type."</td><td>N/A</td>";
  2683.                     } else {
  2684.                         $numaString .= "<tr><td>".$host_name."</td><td>".$numaInfo->numNodes."</td><td>".$numaInfo->type."</td><td>";
  2685.                         if($numaInfo->numaNode) {
  2686.                             my $nodes = $numaInfo->numaNode;
  2687.                             $numaString .= "<table border=\"1\"><tr><th>NODE ID</th><th>CPU ID</th><th>MEM RANGE BEGIN</th><th>MEM RANGE LENGTH</th></tr>";
  2688.                             foreach(@$nodes) {
  2689.                                 my $cpuID = $_->cpuID;
  2690.                                 my $idString = "";
  2691.                                 foreach(@$cpuID) {
  2692.                                     $idString = $_ . " " . $idString;
  2693.                                 }
  2694.                                 $numaString .= "<tr><td>".$_->typeId."</td><td>&nbsp;[".$idString."]&nbsp;</td><td>".&prettyPrintData($_->memoryRangeBegin,'B')."</td><td>".&prettyPrintData($_->memoryRangeLength,'B')."</td></tr>";  
  2695.                             }
  2696.                             $numaString .= "</table>";
  2697.                         } else {
  2698.                             $numaString .= "N/A</td>"
  2699.                         }
  2700.                         $numaString .= "<tr>\n";   
  2701.                     }
  2702.                 }
  2703.             }
  2704.             ######################
  2705.             # CDP
  2706.             ###################### 
  2707.             if($HOST_CDP eq "yes") {
  2708.                 my $netMgr = Vim::get_view(mo_ref => $local_host->configManager->networkSystem);
  2709.                 my ($device,$port,$address,$cdp_ver,$devid,$duplex,$platform,$prefix,$location,$mgmt_addr,$cdpMtu,$samples,$sys_ver,$sys_name,$sys_oid,$timeout,$ttl,$vlan);
  2710.                 my @physicalNicHintInfo = $netMgr->QueryNetworkHint();
  2711.                 foreach (@physicalNicHintInfo){
  2712.                     foreach ( @{$_} ){
  2713.                         if($_->connectedSwitchPort) {
  2714.                             if($demo eq "no") {
  2715.                                 $device = $_->device;
  2716.                                 $port = $_->connectedSwitchPort->portId;
  2717.                                 $address = ($_->connectedSwitchPort->address ? $_->connectedSwitchPort->address : "N/A");
  2718.                                 $cdp_ver = ($_->connectedSwitchPort->cdpVersion ? $_->connectedSwitchPort->cdpVersion : "N/A");
  2719.                                 $devid = ($_->connectedSwitchPort->devId ? $_->connectedSwitchPort->devId : "N/A");
  2720.                                 $duplex = ($_->connectedSwitchPort->fullDuplex ? ($_->connectedSwitchPort->fullDuplex ? "YES" : "NO") : "N/A");
  2721.                                 $platform = ($_->connectedSwitchPort->hardwarePlatform ? $_->connectedSwitchPort->hardwarePlatform : "N/A");
  2722.                                 $prefix = ($_->connectedSwitchPort->ipPrefix ? $_->connectedSwitchPort->ipPrefix : "N/A");
  2723.                                 $location = ($_->connectedSwitchPort->location ? $_->connectedSwitchPort->location : "N/A");
  2724.                                 $mgmt_addr = ($_->connectedSwitchPort->mgmtAddr ? $_->connectedSwitchPort->mgmtAddr : "N/A");
  2725.                                 $cdpMtu = ($_->connectedSwitchPort->mtu ? $_->connectedSwitchPort->mtu : "N/A");
  2726.                                 $samples = ($_->connectedSwitchPort->samples ? $_->connectedSwitchPort->samples : "N/A");
  2727.                                 $sys_ver = ($_->connectedSwitchPort->softwareVersion ? $_->connectedSwitchPort->softwareVersion : "N/A");
  2728.                                 $sys_name = ($_->connectedSwitchPort->systemName ? $_->connectedSwitchPort->systemName : "N/A");
  2729.                                 $sys_oid = ($_->connectedSwitchPort->systemOID ? $_->connectedSwitchPort->systemOID : "N/A");
  2730.                                 $timeout = ($_->connectedSwitchPort->timeout ? $_->connectedSwitchPort->timeout : "N/A");
  2731.                                 $ttl = ($_->connectedSwitchPort->ttl ? $_->connectedSwitchPort->ttl : "N/A");
  2732.                                 $vlan = ($_->connectedSwitchPort->vlan ? $_->connectedSwitchPort->vlan : "N/A");
  2733.                             } else {
  2734.                                 ($device,$address,$cdp_ver,$devid,$duplex,$platform,$prefix,$location,$mgmt_addr,$cdpMtu,$samples,$sys_ver,$sys_name,$sys_oid,$timeout,$ttl,$vlan) = ("demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode","demo_mode");
  2735.                             }
  2736.                             $cdpString .= "<tr><td>".$host_name."</td><td>".$device."</td><td>".$mgmt_addr."</td><td>".$address."</td><td>".$prefix."</td><td>".$location."</td><td>".$sys_name."</td><td>".$sys_ver."</td><td>".$sys_oid."</td><td>".$platform."</td><td>".$devid."</td><td>".$cdp_ver."</td><td>".$duplex."</td><td>".$cdpMtu."</td><td>".$timeout."</td><td>".$ttl."</td><td>".$vlan."</td><td>".$samples."</td></tr>\n";   
  2737.                         }
  2738.                     }
  2739.                 }
  2740.             }
  2741.             ######################
  2742.             # DVS
  2743.             ######################
  2744.             if($HOST_DVS eq "yes") {
  2745.                 if($atype eq 'VirtualCenter') {
  2746.                     my ($dvsMgr,$dvs,$dvpg,$dvs_string);
  2747.                     eval { $dvsMgr = Vim::get_view(mo_ref => $sc->dvSwitchManager); };
  2748.                     if(!$@) {
  2749.                         my $dvs_target = $dvsMgr->QueryDvsConfigTarget(host => $local_host);
  2750.                         if($dvs_target) {
  2751.                             $dvs = $dvs_target->distributedVirtualSwitch;
  2752.                             $dvpg = $dvs_target->distributedVirtualPortgroup;
  2753.                         }
  2754.                         if($dvpg) {
  2755.                             foreach(@$dvpg) {
  2756.                                 $vswitch_portgroup_mappping{$_->portgroupName} = $_->switchName;
  2757.                             }
  2758.                         }
  2759.                         if($dvs) {
  2760.                             foreach(@$dvs) {
  2761.                                 my $sName = defined $_->switchName ? $_->switchName : "N/A";
  2762.                                 if(!$seen_dvs{$sName}) {
  2763.                                     my $sUuid = ($_->switchUuid ? $_->switchUuid : "N/A");
  2764.                                     my $dv_switch = Vim::get_view(mo_ref => $_->distributedVirtualSwitch);
  2765.                                     my $desc = ($dv_switch->summary->description ? $dv_switch->summary->description : "N/A");
  2766.                                     my $contact_name = ($dv_switch->summary->contact->name ? $dv_switch->summary->contact->name : "N/A");
  2767.                                     my $contact_con = ($dv_switch->summary->contact->contact ? $dv_switch->summary->contact->contact : "");
  2768.                                     my $contact_info = $contact_name . " " . $contact_con;
  2769.                                     my $build = ($dv_switch->summary->productInfo->build ? $dv_switch->summary->productInfo->build : "N/A");
  2770.                                     my $bid = ($dv_switch->summary->productInfo->bundleId ? $dv_switch->summary->productInfo->bundleId : "N/A");
  2771.                                     my $burl = ($dv_switch->summary->productInfo->bundleUrl ? $dv_switch->summary->productInfo->bundleUrl: "N/A");
  2772.                                     my $fclass = ($dv_switch->summary->productInfo->forwardingClass ? $dv_switch->summary->productInfo->forwardingClass : "N/A");
  2773.                                     my $vendor = ($dv_switch->summary->productInfo->vendor ? $dv_switch->summary->productInfo->vendor : "N/A");
  2774.                                     my $version = ($dv_switch->summary->productInfo->version ? $dv_switch->summary->productInfo->version : "N/A");
  2775.                                     my $ports = ($dv_switch->summary->numPorts ? $dv_switch->summary->numPorts : "N/A");
  2776.                                     $dvs_string = "<tr><td>".$sName."</td><td>".$desc."</td><td>".$contact_info."</td><td>".$vendor."</td><td>".$version."</td><td>".$sUuid."</td><td>".$build."</td><td>".$bid."</td><td>".$build."</td><td>".$burl."</td><td>".$fclass."</td><td>".$ports."</td></tr>\n";
  2777.                                     push @dvs, $dvs_string;
  2778.                                 }
  2779.                                 $seen_dvs{$sName} = 1;
  2780.                             }
  2781.                         }
  2782.                     }      
  2783.                 }  
  2784.             }
  2785.             ######################
  2786.                         # LUN
  2787.                         ######################
  2788.             if($HOST_LUN eq "yes") {
  2789.                 my $ss = Vim::get_view(mo_ref => $local_host->configManager->storageSystem);
  2790.                 my $fsmount = $ss->fileSystemVolumeInfo->mountInfo;
  2791.                 my $luns = $ss->storageDeviceInfo->scsiLun;
  2792.                 my ($volume,$extents,$diskName,$partition,$deviceName,$lunname,$volumename,$vendor,$model,$queuedepth,$vStorageSupport,$states) = ('','','','','','','','','','','','');
  2793.  
  2794.                 foreach my $fsm (@$fsmount) {
  2795.                     $volume = $fsm->volume;
  2796.                     if ($volume->type eq 'VMFS') {
  2797.                         $extents = $volume->extent;
  2798.                         my $i = 0;
  2799.                         foreach my $extent (@$extents) {
  2800.                             $diskName = $extent->diskName;
  2801.                             my $lun_row = "";
  2802.                             foreach my $lun (sort {$a->canonicalName cmp $b->canonicalName} @$luns) {
  2803.                                 if ($diskName eq $lun->canonicalName) {
  2804.                                     $deviceName = $lun->deviceName;
  2805.                                     $volumename = $volume->name;
  2806.                                     $lunname = $lun->canonicalName;
  2807.                                     $vendor = $lun->vendor;
  2808.                                     $model = $lun->model;
  2809.                                     $queuedepth = $lun->queueDepth;
  2810.                                     if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2811.                                                                                 if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  2812.                                                                                         $vStorageSupport = ($lun->vStorageSupport ? $lun->vStorageSupport : "N/A");
  2813.                                                                                 } else {
  2814.                                                                                         $vStorageSupport = "N/A"
  2815.                                                                                 }
  2816.                                                                         }
  2817.                                     $states = $lun->operationalState;
  2818.                                     last;
  2819.                                 }
  2820.                             }
  2821.                             $partition = $extent->partition;
  2822.                             $luns{$volume->uuid} .= $host_name . "_" . $lunname . ",";
  2823.                             $lun_row .= "<td>".$volumename."</td>";
  2824.                             $lun_row .= "<td>"."$diskName:$partition"."</td>";
  2825.                             $lun_row .= "<td>"."$deviceName:$partition"."</td>";
  2826.                             if($queuedepth) { $lun_row .= "<td>".$queuedepth."</td"; } else { $lun_row .= "<td>N/A</td>"; }
  2827.                             my $state_string = "";
  2828.                             foreach (@$states) {
  2829.                                 $state_string .= $_." ";
  2830.                             }
  2831.                             if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2832.                                                         if($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  2833.                                     $lun_row .= "<td>".$vStorageSupport."</td>";
  2834.                                 } else {
  2835.                                     $lun_row .= "<td>N/A</td>";
  2836.                                 }
  2837.                             }
  2838.                             $lun_row .= "<td>".$state_string."</td><td>".$vendor."</td><td>".$model."</td>";
  2839.                             $lun_row_info{$volume->uuid} = $lun_row;
  2840.                         }
  2841.                     }
  2842.                 }
  2843.             }
  2844.             ######################
  2845.                         # DATASTORE
  2846.                         ######################
  2847.             if($HOST_DATASTORE eq "yes") {
  2848.                 my $ds_views = Vim::get_views (mo_ref_array => $local_host->datastore);
  2849.                 my $ctr = 0;
  2850.                 foreach my $ds (sort {$a->info->name cmp $b->info->name} @$ds_views) {
  2851.                     my $ds_row = "";
  2852.                     if($ds->summary->accessible) {
  2853.                         #capture unique datastores seen in cluster
  2854.                         if (!grep {$_ eq $ds->info->name} @datastores_seen) {
  2855.                             push @datastores_seen,$ds->info->name;
  2856.                             my ($perc_free,$perc_string,$ds_used,$ds_free,$ds_cap,$ds_block,$ds_ver) = ("","","","","","N/A","N/A");
  2857.                             if ( ($ds->summary->freeSpace gt 0) || ($ds->summary->capacity gt 0) ) {
  2858.                                 $ds_cap = &restrict_num_decimal_digits($ds->summary->capacity/1024/1000,2);
  2859.                                 $ds_used = prettyPrintData(($ds->summary->capacity - $ds->summary->freeSpace),'B');
  2860.                                 $ds_free = &restrict_num_decimal_digits(($ds->summary->freeSpace/1024/1000),2);
  2861.                                 $perc_free = &restrict_num_decimal_digits(( 100 * $ds_free / $ds_cap),2);
  2862.                                 $perc_string = getColor($perc_free);
  2863.                                 if($ds->summary->type eq 'VMFS') {
  2864.                                     $ds_block = $ds->info->vmfs->blockSizeMb;
  2865.                                     $ds_ver = $ds->info->vmfs->version;
  2866.                                 }
  2867.                             } else {
  2868.                                 ($perc_free,$ds_used,$ds_free) = ("UNKNOWN","UNKNOWN","UNKNOWN");
  2869.                             }
  2870.  
  2871.                             my $vmsInDS = Vim::get_views(mo_ref_array => $ds->vm,properties => ['name']);
  2872.  
  2873.                             if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2874.                                 my ($iormEnable,$iormThres,$dsMaintMode,$iormAggDisable,$iormStatsCollEnable) = ("N/A","N/A","N/A","N/A","N/A");
  2875.                                                                 if(($hostAPIVersion eq '4.1.0' || $hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') && $ds->summary->type eq 'VMFS') {
  2876.                                     $iormEnable = ($ds->iormConfiguration->enabled ? "YES" : "NO");
  2877.                                     $iormThres = ($ds->iormConfiguration->congestionThreshold ? $ds->iormConfiguration->congestionThreshold . " ms" : "N/A");
  2878.                                     if($hostAPIVersion eq '5.0.0' || $hostAPIVersion eq '5.1.0') {
  2879.                                         $dsMaintMode = ($ds->summary->maintenanceMode ? "YES" : "NO");
  2880.                                         $iormAggDisable = ($ds->iormConfiguration->statsAggregationDisabled ? "YES" : "NO");
  2881.                                         $iormStatsCollEnable = ($ds->iormConfiguration->statsCollectionEnabled ? "YES" : "NO");
  2882.                                     }
  2883.                                 }
  2884.                                 $ds_row = "</td><td>".@$vmsInDS."</td><td>".(prettyPrintData($ds->summary->capacity,'B'))."</td><td>".$ds_used."</td><td>".prettyPrintData($ds->summary->freeSpace,'B')."</td>$perc_string<td>$ds_block</td><td>".$ds_ver."</td><td>".$ds->summary->type."</td><td>".$dsMaintMode."</td><td>".$iormEnable."</td><td>".$iormThres."</td><td>".$iormAggDisable."</td><td>".$iormStatsCollEnable."</td>";
  2885.                             } else {
  2886.                                 $ds_row = "</td><td>".@$vmsInDS."</td><td>".(prettyPrintData($ds->summary->capacity,'B'))."</td><td>".$ds_used."</td><td>".prettyPrintData($ds->summary->freeSpace,'B')."</td>$perc_string<td>$ds_block</td><td>".$ds_ver."</td><td>".$ds->summary->type."</td>";
  2887.                             }
  2888.  
  2889.                             $datastore_row_info{$ds->info->name} = $ds_row;
  2890.                         }
  2891.                         $datastores{$ds->info->name} .= $host_name. "_" . $ctr++ .",";
  2892.                     }
  2893.                 }
  2894.             }
  2895.             ######################
  2896.                         # PORTGROUP
  2897.                         ######################
  2898.             if($HOST_PORTGROUP eq "yes") {
  2899.                 my $portgroup_views = Vim::get_views (mo_ref_array => $local_host->network);
  2900.                 foreach my $portgroup (sort {$a->summary->name cmp $b->summary->name} @$portgroup_views) {
  2901.                     my $pg_row = "";
  2902.                     if($portgroup->summary->accessible) {
  2903.                         push @hosts_in_portgroups,$host_name;
  2904.                        
  2905.                         #logic to figure out which hosts can not see this portgroup
  2906.                                         my @intersection = ();
  2907.                                         my @difference = ();
  2908.                                         my %count = ();
  2909.                                         foreach my $element (@hosts_in_portgroups, @hosts_seen) { $count{$element}++ }
  2910.                                         foreach my $element (keys %count) {
  2911.                                                 push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element;
  2912.                                         }
  2913.                         if(@difference) {
  2914.                             my $hosts_not_accessible = "";
  2915.                             foreach (@difference) {
  2916.                                 $hosts_not_accessible .= $_." ";
  2917.                             }
  2918.                             if($demo eq "no") {
  2919.                                 $pg_row .= "<td bgcolor=\"#FF6666\">$hosts_not_accessible</td>";
  2920.                             } else {
  2921.                                 $pg_row .= "<td bgcolor=\"#FF6666\">demo_mode</td>";
  2922.                             }
  2923.                         } else {
  2924.                             $pg_row .= "<td bgcolor=\"#66FF99\">Accessible by all hosts in this cluster</td>";
  2925.                         }
  2926.                         $portgroup_row_info{$portgroup->name} = $pg_row;
  2927.                     }
  2928.                 }
  2929.             }
  2930.             ######################
  2931.             # CACHE
  2932.             ######################
  2933.             if($HOST_CACHE eq "yes" && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  2934.                 my $cacheMgr;
  2935.                 eval { $cacheMgr = Vim::get_view (mo_ref => $local_host->configManager->cacheConfigurationManager); };
  2936.                 if(!$@) {
  2937.                     if($cacheMgr->cacheConfigurationInfo) {
  2938.                         my $cacheConfig = $cacheMgr->cacheConfigurationInfo;
  2939.                         my $cacheConcatString = "";
  2940.  
  2941.                         foreach(@$cacheConfig) {
  2942.                             my $cacheDS = Vim::get_view(mo_ref => $_->key, properties => ['name']);
  2943.                             my $cacheSwap = &prettyPrintData($_->swapSize,'M');
  2944.                             $cacheConcatString .= "<tr><td>".$host_name."</td><td>".$cacheDS->{'name'}."</td><td>".$cacheSwap . "</td></tr>\n";
  2945.                         }
  2946.                         $cacheString .= $cacheConcatString;
  2947.                     }
  2948.                 }
  2949.             }
  2950.             ######################
  2951.                         # MULTIPATH
  2952.                         ######################
  2953.             if($HOST_MULTIPATH eq "yes") {
  2954.                 my $storageSys;
  2955.                 eval { $storageSys = Vim::get_view (mo_ref => $local_host->configManager->storageSystem); };
  2956.                 if(!$@) {
  2957.                             my $luns = $storageSys->storageDeviceInfo->scsiLun;
  2958.                             my $hbas = $storageSys->storageDeviceInfo->hostBusAdapter;
  2959.                             my $mpLuns = $storageSys->storageDeviceInfo->multipathInfo->lun;
  2960.            
  2961.                     $multipathString .= "\n<table border=\"1\"><tr><th colspan=3>".$local_host->name."</th></tr>";
  2962.    
  2963.                     my $verbose;   
  2964.                     foreach my $mpLun (@$mpLuns) {
  2965.                         my $paths = $mpLun->path;
  2966.                         my $numPaths = scalar(@$paths);
  2967.                         my $lun = find_by_key($luns, $mpLun->lun);
  2968.  
  2969.                         my $pol = $mpLun->policy;
  2970.                         my $polPrefer;
  2971.                         if (defined($pol) && defined($pol->{prefer})) {
  2972.                             $polPrefer = $pol->prefer;
  2973.                         }
  2974.                         my $cap = $lun->{capacity};
  2975.                         my $deviceUuidPath = defined($lun->{uuid}) ? ("vml." . $lun->uuid) : "";
  2976.                         $multipathString .= "<table border=\"1\">\n";
  2977.                         $multipathString .= "<tr><th>".(defined($lun->{lunType}) ? $lun->lunType : "")." ".(defined($lun->{canonicalName}) ? $lun->canonicalName : "").($verbose ? " $deviceUuidPath" : "")." ".(defined($cap) ? " ( " . int($cap->block * $cap->blockSize / (1024*1024)) . " MB )" : " ( 0 MB )")." ==  # of Paths: ".$numPaths." Policy: ".((defined($pol) && defined($pol->{policy})) ? $pol->policy : "")."</th></tr>\n";
  2978.  
  2979.                         foreach my $path (@$paths) {
  2980.                             my $hba = find_by_key($hbas, $path->adapter);
  2981.                             my $isFC = $hba->isa("HostFibreChannelHba");
  2982.                             my $state = ($path->{pathState} ? (($path->pathState eq "active") ? "On active" : $path->pathState) : "");
  2983.                             my $pciString = get_pci_string($hba);
  2984.  
  2985.                             my $pathStateColor;
  2986.                             if($path->{pathState} eq "dead") {
  2987.                                 $pathStateColor = $light_red;
  2988.                             } elsif($path->{pathState} eq "disabled" || $path->{pathState} eq "standby") {
  2989.                                 $pathStateColor = $yellow;
  2990.                             } else {
  2991.                                 $pathStateColor = $white;
  2992.                             }
  2993.                             if($demo eq "no") {
  2994.                                 $multipathString .= "<tr><td bgcolor=\"" . $pathStateColor . "\">".($isFC ? "FC" : "Local")." ".$pciString." ".($isFC ? $hba->nodeWorldWideName . "<->" . $hba->portWorldWideName : "")." ".$path->name." ".$state." ".((defined($polPrefer) && ($path->name eq $polPrefer)) ? "preferred" : "")."</td></tr>\n";
  2995.                             } else {
  2996.                                 $multipathString .= "<tr><td bgcolor=\"" . $pathStateColor . "\">".($isFC ? "FC" : "Local")." ".$pciString." "."demo_mode <-> demo_mode "." ".$path->name." ".$state." ".((defined($polPrefer) && ($path->name eq $polPrefer)) ? "preferred" : "")."</td></tr>\n";
  2997.                             }
  2998.                         }
  2999.                         $multipathString .= "</table><br/>\n";
  3000.                     }
  3001.                 }
  3002.             }
  3003.             ######################
  3004.                         # LOG
  3005.                         ######################
  3006.                         if($HOST_LOG eq "yes") {
  3007.                 my $logKey = "hostd";
  3008.                 my ($diagMgr,$logData);
  3009.                 eval { $diagMgr = Vim::get_view(mo_ref => $sc->diagnosticManager); };
  3010.                 if($atype eq 'VirtualCenter') {
  3011.                     $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, host => $local_host, start => "999999999");
  3012.                 } else {
  3013.                     $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, start => "999999999");
  3014.                 }
  3015.                 my $lineEnd = $logData->lineEnd;
  3016.                 my $start = $lineEnd - $logcount;
  3017.                 if($atype eq 'VirtualCenter') {
  3018.                     $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, host => $local_host, start => $start,lines => $logcount);
  3019.                 } else {
  3020.                     $logData = $diagMgr->BrowseDiagnosticLog(key => $logKey, start => $start,lines => $logcount);
  3021.                 }
  3022.                 $logString .= "<tr><th colspan=3>".$host_name."</th></tr>\n";
  3023.                 if ($logData->lineStart != 0) {
  3024.                     my $logConcat = "";
  3025.                     foreach my $line (@{$logData->lineText}) {
  3026.                         if($demo eq "no") {
  3027.                             $logConcat .= $line."<br/>";
  3028.                         } else {
  3029.                             $logConcat = "demo_mode";
  3030.                         }
  3031.                     }
  3032.                     $logString .= "<tr><td>".$logConcat."</td></tr>\n";
  3033.                 }
  3034.             }
  3035.  
  3036.             ## END OF HOSTS ##
  3037.         }
  3038.        
  3039.         ###############################################
  3040.         ## HACK TO PRINT DVS,LUN,DATASTORE and PORTGRUP  ##
  3041.         ###############################################
  3042.         if($HOST_DVS eq "yes") {
  3043.             foreach(@dvs) {
  3044.                 $dvsString .= $_;
  3045.             }
  3046.             @dvs = ();
  3047.         }
  3048.         if($HOST_LUN eq "yes") {
  3049.             #logic to check which hosts can see all luns
  3050.             while ( my ($uuid, $value) = each(%luns) ) {
  3051.                 my @pairs = split(',',$value);
  3052.                         my $pair_count = @pairs;
  3053.                 my @hosts_to_luns = ();
  3054.                 for (my $x=0;$x < $pair_count;$x++) {
  3055.                     (my $hostname,my $vmhba) = split('_',$pairs[$x],2);
  3056.                     push @hosts_to_luns, $hostname;
  3057.                 }
  3058.                 #logic to figure out which hosts can not see this lun
  3059.                 my @intersection = ();
  3060.                 my @difference = ();
  3061.                 my %count = ();
  3062.                 foreach my $element (@hosts_to_luns, @hosts_seen) { $count{$element}++ }
  3063.                 foreach my $element (keys %count) {
  3064.                     push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element;
  3065.                 }
  3066.  
  3067.                 my $print_string = "";
  3068.                 if(@difference) {
  3069.                     foreach (@difference) {
  3070.                         $print_string .= $_." ";
  3071.                     }
  3072.                 }
  3073.                 if($print_string eq '') {
  3074.                     $print_string = "<td bgcolor=\"#66FF99\">Accessible by all hosts in this cluster</td>";
  3075.                 } else {
  3076.                     $print_string = "<td bgcolor=\"#FF6666\">".$print_string."</td>";
  3077.                 }
  3078.                 $lun_row_info{$uuid} .= $print_string;
  3079.                 @hosts_to_luns = ();
  3080.             }
  3081.            
  3082.             foreach my $lun ( sort keys %lun_row_info ) {
  3083.                         my $value = $lun_row_info{$lun};
  3084.                         $lunString .= "<tr><td>".$lun."</td>".$value."</tr>\n";
  3085.                 }
  3086.             (%luns,%lun_row_info) = ();
  3087.         }
  3088.         if($HOST_DATASTORE eq "yes") {
  3089.             #logic to check which hosts can see all datastores
  3090.             while ( my ($ds, $value) = each(%datastores) ) {
  3091.                 my @pairs = split(',',$value);
  3092.                 my $pair_count = @pairs;
  3093.                 my @hosts_to_datastores = ();
  3094.                 for (my $x=0;$x < $pair_count;$x++) {
  3095.                     (my $hostname,my $count) = split('_',$pairs[$x],2);
  3096.                     push @hosts_to_datastores, $hostname;
  3097.                 }
  3098.                 #logic to figure out which hosts can not see this datastore
  3099.                 my @intersection = ();
  3100.                 my @difference = ();
  3101.                 my %count = ();
  3102.                 foreach my $element (@hosts_to_datastores, @hosts_seen) { $count{$element}++ }
  3103.                 foreach my $element (keys %count) {
  3104.                     push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element;
  3105.                 }
  3106.  
  3107.                 my $print_string = "";
  3108.                 if(@difference) {
  3109.                     foreach (@difference) {
  3110.                         $print_string .= $_." ";
  3111.                     }
  3112.                 }
  3113.                 if($print_string eq '') {
  3114.                     $print_string = "<td bgcolor=\"#66FF99\">Accessible by all hosts in this cluster</td>";
  3115.                 } else {
  3116.                                         $print_string = "<td bgcolor=\"#FF6666\">".$print_string."</td>";
  3117.                 }
  3118.                 $datastore_row_info{$ds} .= $print_string;
  3119.                 @hosts_to_datastores = ();
  3120.             }
  3121.  
  3122.             for my $datastore ( sort keys %datastore_row_info ) {
  3123.                 my $value = $datastore_row_info{$datastore};
  3124.                 $datastoreString .= "<tr><td>".$datastore."</td>".$value."</tr>\n";
  3125.             }
  3126.             (%datastores,%datastore_row_info) = ();
  3127.         }
  3128.         if($HOST_PORTGROUP eq "yes") {
  3129.             for my $portgroup ( sort keys %portgroup_row_info ) {
  3130.                 my $value = $portgroup_row_info{$portgroup};
  3131.                 if($demo eq "no") {
  3132.                     $portgroupString .= "<tr><td>".$portgroup."</td>".$value."</tr>\n";
  3133.                 } else {
  3134.                     $portgroupString .= "<tr><td>demo_mode</td>".$value."</tr>\n";
  3135.                 }
  3136.             }          
  3137.             (%portgroup_row_info) = ();
  3138.         }
  3139.  
  3140.         ## Executed outside of the hosts ##
  3141.  
  3142.         ######################
  3143.                 # TASK
  3144.                 ######################
  3145.                 if($HOST_TASK eq "yes") {
  3146.                     my $taskMgr;
  3147.                         eval { $taskMgr = Vim::get_view(mo_ref => $sc->taskManager); };
  3148.                         if(!$@) {
  3149.                             my $tasks = Vim::get_views(mo_ref_array => $taskMgr->recentTask);
  3150.                                 foreach(@$tasks) {
  3151.                                     my $progress = $_->info->progress;
  3152.                                         if(!defined($progress)) {
  3153.                                             $progress = "COMPLETED";
  3154.                                         }
  3155.                                         $taskString .= "<tr><td>".$_->info->descriptionId."</td><td>".$_->info->queueTime."</td><td>".($_->info->startTime ? $_->info->startTime : "N/A")."</td><td>".($_->info->completeTime ? $_->info->completeTime : "N/A")."</td><td>".$progress."</td><td>".$_->info->state->val."</td></tr>\n";
  3156.                                 }
  3157.                         }
  3158.                 }
  3159.  
  3160.         @hosts_seen = ();
  3161.         @datastores_seen = ();
  3162.         @hosts_in_portgroups = ();
  3163.         &buildHostReport($cluster_name,$cluster_count,$type,$atype,$aversion);
  3164.     }  
  3165. }
  3166.  
  3167. sub buildHostReport {
  3168.         my ($cluster_name,$cluster_count,$type,$atype,$aversion) = @_;
  3169.  
  3170.         my ($hostTag,$hostTagShort,$table_host_conf) = ("","","");
  3171.  
  3172.     if($HOST_STATE eq "yes" && $stateString ne "") {
  3173.                 $hostTag = "ESX/ESXi State-$cluster_count";
  3174.                 $hostTagShort = "ESX/ESXi State";
  3175.  
  3176.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3177.  
  3178.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3179.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3180.                 $table_host_conf .= "<table border=\"1\">\n";
  3181.  
  3182.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3183.                         $table_host_conf .= "<tr><th>HOSTNAME</th><th>OVERALL STATUS</th><th>POWER STATE</th><th>BOOT TIME</th><th>UPTIME</th><th>HA STATE</th><th>CONNECTION STATE</th><th>MAINTENANCE MODE</th><th>STANDBY MODE</th><th>VMOTION ENABLED</th><th>VERSION</th></tr>\n";
  3184.                 } else {
  3185.                         $table_host_conf .= "<tr><th>HOSTNAME</th><th>OVERALL STATUS</th><th>POWER STATE</th><th>BOOT TIME</th><th>CONNECTION STATE</th><th>MAINTENANCE MODE</th><th>VMOTION ENABLED</th><th>VERSION</th></tr>\n";
  3186.                 }
  3187.  
  3188.                 $table_host_conf .= $stateString;
  3189.                 $table_host_conf .= "</table>\n";
  3190.                 $hostString .= "<br/>".$table_host_conf;
  3191.                 ($table_host_conf,$stateString) = ("","");
  3192.         }
  3193.     if($HOST_MGMT eq "yes" && $mgmtString ne "") {
  3194.                 $hostTag = "ESX/ESXi Management Info-$cluster_count";
  3195.                 $hostTagShort = "ESX/ESXi Management Info";
  3196.  
  3197.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3198.  
  3199.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3200.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3201.                 $table_host_conf .= "<table border=\"1\">\n";
  3202.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3203.                         $table_host_conf .= "<tr><th>HOSTNAME</th><th>vCenter</th><th>LOCKDOWN MODE ENABLED</th><th>COS VMDK</th><th>UUID</th><th>SERVICE CONSOLE MEM</th></tr>\n";
  3204.                 } else {
  3205.                         $table_host_conf .= "<tr><th>HOSTNAME</th><th>vCenter</th><th>LOCKDOWN MODE ENABLED</th><th>UUID</th><th>SERVICE CONSOLE MEM</th></tr>\n";
  3206.                 }
  3207.  
  3208.                 $table_host_conf .= $mgmtString;
  3209.                 $table_host_conf .= "</table>\n";
  3210.                 $hostString .= "<br/>".$table_host_conf;
  3211.                 ($table_host_conf,$mgmtString) = ("","");
  3212.         }
  3213.         if($HOST_HARDWARE_CONFIGURATION eq "yes" && $hardwareConfigurationString ne "") {
  3214.         $hostTag = "ESX/ESXi Hardware Configuration-$cluster_count";
  3215.             $hostTagShort = "ESX/ESXi Hardware Configuration";
  3216.  
  3217.         push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3218.  
  3219.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3220.             $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3221.             $table_host_conf .= "<table border=\"1\">\n";
  3222.         if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3223.             $table_host_conf .= "<tr><th>HOSTNAME</th><th>VENDOR</th><th>ADDITIONAL VENDOR INFO</th><th>MODEL</th><th>CPU INFO</th><th>SMC PRESENT</th><th>HT AVAILABLE</th><th>CPU SPEED</th><th>CPU USAGE</th><th>PROCESSOR SOCKETS</th><th>CORES PER SOCKET</th><th>LOGICAL CORES</th><th>MEMORY</th><th>MEMORY USAGE</th><th>NIC(s)</th><th>HBA(s)</th></tr>\n";
  3224.         } else {
  3225.                 $table_host_conf .= "<tr><th>HOSTNAME</th><th>VENDOR</th><th>ADDITIONAL VENDOR INFO</th><th>MODEL</th><th>CPU INFO</th><th>HT AVAILABLE</th><th>CPU SPEED</th><th>CPU USAGE</th><th>PROCESSOR SOCKETS</th><th>CORES PER SOCKET</th><th>LOGICAL CORES</th><th>MEMORY</th><th>MEMORY USAGE</th><th>NIC(s)</th><th>HBA(s)</th></tr>\n";
  3226.         }
  3227.  
  3228.         $table_host_conf .= $hardwareConfigurationString;
  3229.         $table_host_conf .= "</table>\n";
  3230.             $hostString .= "<br/>".$table_host_conf;
  3231.                 ($table_host_conf,$hardwareConfigurationString) = ("","");
  3232.     }
  3233.     if($HOST_HEALTH eq "yes" && $healthHardwareString ne "") {
  3234.         $hostTag = "ESX/ESXi Health Hardware Status-$cluster_count";
  3235.                 $hostTagShort = "ESX/ESXi Health Hardware Status";
  3236.  
  3237.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3238.  
  3239.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3240.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3241.                 $table_host_conf .= "<table border=\"1\">\n";
  3242.                 $table_host_conf .= "<tr><th>COMPONENT</th><th>STATUS</th></tr>\n";
  3243.  
  3244.         $table_host_conf .= $healthHardwareString;
  3245.         $table_host_conf .= "</table>\n";
  3246.                 $hostString .= "<br/>".$table_host_conf;
  3247.                 ($table_host_conf,$healthHardwareString) = ("","");
  3248.     }
  3249.     if($HOST_HEALTH eq "yes" && $healthSoftwareString ne "") {
  3250.         $hostTag = "ESX/ESXi Health Software Status-$cluster_count";
  3251.                 $hostTagShort = "ESX/ESXi Health Software Status";
  3252.  
  3253.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3254.  
  3255.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3256.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3257.                 $table_host_conf .= "<a href=\"javascript:showHide('div$cluster_count')\">Click here for more detail info</a>\n";
  3258.                 $table_host_conf .= "<div id=\"div$cluster_count\" style=\"display:none;thin solid;\">\n";
  3259.                 $table_host_conf .= "<table border=\"1\">\n";
  3260.                 $table_host_conf .= "<tr><th>SENSOR NAME</th><th>READING</th><th>STATUS</th></tr>\n";
  3261.        
  3262.         $table_host_conf .= $healthSoftwareString;
  3263.         $table_host_conf .= "</table>\n";
  3264.         $table_host_conf .= "</div>\n";
  3265.                 $hostString .= "<br/>".$table_host_conf;
  3266.                 ($table_host_conf,$healthSoftwareString) = ("","");
  3267.     }
  3268.     if($HOST_PERFORMANCE eq "yes" || $hostperformance eq "yes" && $hostPerfString ne "") {
  3269.         $hostTag = "ESX/ESXi Performance-$cluster_count";
  3270.                 $hostTagShort = "ESX/ESXi Performance";
  3271.  
  3272.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3273.  
  3274.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3275.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3276.                 $table_host_conf .= "<table border=\"1\">\n";
  3277.                 $table_host_conf .= "<tr><th>HOST</th><th>cpu.usagemhz.average</th><th>cpu.usage.average</th><th>mem.active.average</th><th>mem.usage.average</th></tr>\n";
  3278.  
  3279.         $table_host_conf .= $hostPerfString;
  3280.         $table_host_conf .= "</table>\n";
  3281.                 $hostString .= "<br/>".$table_host_conf;
  3282.                 ($table_host_conf,$hostPerfString) = ("","");
  3283.     }
  3284.     if($HOST_NIC eq "yes" && $nicString ne "") {
  3285.                 $hostTag = "ESX/ESXi NIC(s)-$cluster_count";
  3286.                 $hostTagShort = "ESX/ESXi NIC(s)";
  3287.  
  3288.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3289.  
  3290.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3291.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3292.                 $table_host_conf .= "<table border=\"1\">\n";
  3293.                 $table_host_conf .= "<tr><th>HOST</th><th>DEVICE</th><th>PCI</th><th>DRIVER</th><th>DUPLEX</th><th>SPEED</th><th>WOL ENABLED</th><th>MAC</th></tr>\n";
  3294.  
  3295.         $table_host_conf .= $nicString;
  3296.         $table_host_conf .= "</table>\n";
  3297.                 $hostString .= "<br/>".$table_host_conf;
  3298.                 ($table_host_conf,$nicString) = ("","");
  3299.         }
  3300.     if($HOST_HBA eq "yes" && $hbaString ne "") {
  3301.                 $hostTag = "ESX/ESXi HBA(s)-$cluster_count";
  3302.                 $hostTagShort = "ESX/ESXi HBA(s)";
  3303.  
  3304.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3305.  
  3306.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3307.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3308.                 $table_host_conf .= "<table border=\"1\">\n";
  3309.                 $table_host_conf .= "<tr><th>HOST</th><th>HBA TYPE</th><th>DEVICE</th><th>PCI</th><th>MODEL</th><th>DRIVER</th><th>STATUS</th><th>ADDITIONAL INFO</th></tr>\n";
  3310.        
  3311.         $table_host_conf .= $hbaString;
  3312.         $table_host_conf .= "</table>\n";
  3313.                 $hostString .= "<br/>".$table_host_conf;
  3314.                 ($table_host_conf,$hbaString) = ("","");
  3315.         }
  3316.     if($HOST_ISCSI eq "yes" && $iscsiString ne "" && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3317.                 $hostTag = "ESX/ESXi iSCSI-$cluster_count";
  3318.                 $hostTagShort = "ESX/ESXi iSCSI";
  3319.  
  3320.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3321.  
  3322.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3323.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3324.                 $table_host_conf .= "<table border=\"1\">\n";
  3325.                 $table_host_conf .= "<tr><th>HOST</th><th>VNIC</th><th>IP ADDRESS</th><th>NETMASK</th><th>MAC ADDRESS</th><th>MTU</th><th>TSO ENABLED</th><th>SPEED</th></th><th>PNIC</th><th>PORTGROUP</th><th>VSWITCH</th><th>SWITCH UUID</th><th>PATH STATUS</th></tr>\n";
  3326.  
  3327.                 $table_host_conf .= $iscsiString;
  3328.                 $table_host_conf .= "</table>\n";
  3329.                 $hostString .= "<br/>".$table_host_conf;
  3330.                 ($table_host_conf,$iscsiString) = ("","");
  3331.         }
  3332.     if($HOST_CAPABILITY eq "yes" && $capString ne "") {
  3333.         $hostTag = "ESX/ESXi Capabilitie(s)-$cluster_count";
  3334.                 $hostTagShort = "ESX/ESXi Capabilitie(s)";
  3335.  
  3336.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3337.  
  3338.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3339.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3340.         $table_host_conf .= "<table border=\"1\">\n";
  3341.  
  3342.         if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3343.             $table_host_conf .= "<tr><th>HOST</th><th>MAX RUNNING VMS SUPPORT</th><th>MAX VCPUS SUPPORT</th><th>VMFS VERSIONS SUPPORT</th><th>FT SUPPORT</th><th>IPMI SUPPORT</th><th>TPM SUPPORT</th><th>HV SUPPORT</th><th>IORM SUPPORT</th><th>DIRECTPATH G2 SUPPORT</th><th>STORAGE HW ACCELERATION SUPPORT</th><th>SSL THUMBPRINT AUTH SUPPORT</th></tr>\n";
  3344.         } elsif($aversion eq '4.1.0') {
  3345.             $table_host_conf .= "<tr><th>HOST</th><th>FT SUPPORT</th><th>IPMI SUPPORT</th><th>TPM SUPPORT</th><th>HV SUPPORT</th><th>IORM SUPPORT</th><th>DIRECTPATH G2 SUPPORT</th><th>STORAGE HW ACCELERATION SUPPORT</th><th>SSL THUMBPRINT AUTH SUPPORT</th></tr>\n";
  3346.         } else {
  3347.             $table_host_conf .= "<tr><th>HOST</th><th>FT SUPPORT</th><th>IPMI SUPPORT</th><th>TPM SUPPORT</th><th>HV SUPPORT</th><th>SSL THUMBPRINT AUTH SUPPORT</th></tr>\n";
  3348.         }
  3349.  
  3350.                 $table_host_conf .= $capString;
  3351.                 $table_host_conf .= "</table>\n";
  3352.                 $hostString .= "<br/>".$table_host_conf;
  3353.                 ($table_host_conf,$capString) = ("","");
  3354.     }
  3355.     if($HOST_CONFIGURATION eq "yes" && $configString ne "") {
  3356.         $hostTag = "ESX/ESXi Configuration(s)-$cluster_count";
  3357.                 $hostTagShort = "ESX/ESXi Configuration(s)";
  3358.  
  3359.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3360.  
  3361.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3362.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3363.  
  3364.         $table_host_conf .= $configString;
  3365.         #$table_host_conf .= "</table>\n";
  3366.                 $hostString .= "<br/>".$table_host_conf;
  3367.                 ($table_host_conf,$configString) = ("","");
  3368.     }
  3369.     if($HOST_ADVOPT eq "yes" && $advString ne "") {
  3370.         $hostTag = "ESX/ESXi Advanced Options-$cluster_count";
  3371.                 $hostTagShort = "ESX/ESXi Advanced Options";
  3372.  
  3373.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3374.  
  3375.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3376.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3377.                 $table_host_conf .= "<table border=\"1\">\n";
  3378.  
  3379.         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0') ) {
  3380.                         $table_host_conf .= "<tr><th>HOST</th><th>Disk.UseDeviceReset</th><th>Disk.UseLunReset</th><th>Disk.SchedNumReqOutstanding</th><th>Sc
  3381. si.ConflictRetries</th><th>NFS.MaxVolumes</th><th>SendBufferSize</th><th>ReceiveBufferSize</th><th>Net.TcpipHeapSize</th><th>NFS.HeartbeatFrequency</th><th>N
  3382. FS.HeartbeatTimeout</th><th>NFS.HeartbeatMaxFailures</th><th>VMkernel.Boot.techSupportMode</th><th>VMFS3.HardwareAcceleratedLocking</th><th>DataMover.Hardwar
  3383. eAcceleratedMove</th><th>DataMover.HardwareAcceleratedInit</th></tr>\n";
  3384.                 } else {
  3385.                         $table_host_conf .= "<tr><th>HOST</th><th>Disk.UseDeviceReset</th><th>Disk.UseLunReset</th><th>Disk.SchedNumReqOutstanding</th><th>Sc
  3386. si.ConflictRetries</th><th>NFS.MaxVolumes</th><th>SendBufferSize</th><th>ReceiveBufferSize</th><th>Net.TcpipHeapSize</th><th>NFS.HeartbeatFrequency</th><th>N
  3387. FS.HeartbeatTimeout</th><th>NFS.HeartbeatMaxFailures</th><th>VMkernel.Boot.techSupportMode</th></tr>\n";
  3388.                 }
  3389.  
  3390.                 $table_host_conf .= $advString;
  3391.                 $table_host_conf .= "</table>\n";
  3392.                 $hostString .= "<br/>".$table_host_conf;
  3393.                 ($table_host_conf,$advString) = ("","");
  3394.     }
  3395.     if($HOST_ADVOPT eq "yes" && $agentString ne "" && $atype eq "VirtualCenter"  && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3396.                 $hostTag = "ESX/ESXi Host Agent Settings-$cluster_count";
  3397.                 $hostTagShort = "ESX/ESXi Host Agent Settings";
  3398.  
  3399.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3400.  
  3401.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3402.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3403.                 $table_host_conf .= "<table border=\"1\">\n";
  3404.         $table_host_conf .= "<tr><th>HOST</th><th>AGENT VM DATASTORE</th><th>AGENT VM NETWORK</th></tr>\n";
  3405.                 $table_host_conf .= $agentString;
  3406.                 $table_host_conf .= "</table>\n";
  3407.                 $hostString .= "<br/>".$table_host_conf;
  3408.                 ($table_host_conf,$agentString) = ("","");
  3409.         }
  3410.     if($HOST_NUMA eq "yes" && $numaString ne "") {
  3411.         $hostTag = "ESX/ESXi NUMA-$cluster_count";
  3412.                 $hostTagShort = "ESX/ESXi NUMA";
  3413.  
  3414.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3415.  
  3416.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3417.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3418.                 $table_host_conf .= "<table border=\"1\">\n";
  3419.                 $table_host_conf .= "<tr><th>HOST</th><th># NODES</th><th>TYPE</th><th>NUMA NODE INFO</th></tr>\n";
  3420.    
  3421.         $table_host_conf .= $numaString;
  3422.         $table_host_conf .= "</table>\n";
  3423.                 $hostString .= "<br/>".$table_host_conf;
  3424.                 ($table_host_conf,$numaString) = ("","");
  3425.     }
  3426.     if($HOST_CDP eq "yes" && $cdpString ne "") {
  3427.                 $hostTag = "ESX/ESXi CDP-$cluster_count";
  3428.                 $hostTagShort = "ESX/ESXi CDP";
  3429.  
  3430.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3431.  
  3432.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3433.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3434.                 $table_host_conf .= "<table border=\"1\">\n";
  3435.                 $table_host_conf .= "<tr><th>HOST</th><th>DEVICE</th><th>MGMT ADDRESS</th><th>DEVICE ADDRESS</th><th>IP PREFIX</th><th>LOCATION</th><th>SYSTEM NAME</th><th>SYSTEM VERSION</th><th>SYSTEM OID</th><th>PLATFORM</th><th>DEVICE ID</th><th>CDP VER</th><th>FULL DUPLEX</th><th>MTU</th><th>TIMEOUT</th><th>TTL</th><th>VLAN ID</th><th>SAMPLES</th></tr>\n";
  3436.  
  3437.         $table_host_conf .= $cdpString;
  3438.         $table_host_conf .= "</table>\n";
  3439.                 $hostString .= "<br/>".$table_host_conf;
  3440.                 ($table_host_conf,$cdpString) = ("","");
  3441.         }
  3442.         if($HOST_DVS eq "yes" && $atype eq "VirtualCenter" && $dvsString ne "") {
  3443.                 $hostTag = "ESX/ESXi Distributed vSwitch-$cluster_count";
  3444.                 $hostTagShort = "ESX/ESXi Distributed vSwitch";
  3445.  
  3446.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3447.  
  3448.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3449.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3450.                 $table_host_conf .= "<table border=\"1\">\n";
  3451.                 $table_host_conf .= "<tr><th>NAME</th><th>DESCRIPTION</th><th>CONTACT INFO</th><th>VENDOR</th><th>VERSION</th><th>UUID</th><th>BUILD</th><th>
  3452. BUNDLE ID</th><th>BUNDLE BUILD</th><th>BUNDLE URL</th><th>FORWARDING CLASS</th><th>PORTS</th></tr>\n";
  3453.  
  3454.         $table_host_conf .= $dvsString;
  3455.         $table_host_conf .= "</table>\n";
  3456.                 $hostString .= "<br/>".$table_host_conf;
  3457.                 ($table_host_conf,$numaString) = ("","");
  3458.         }
  3459.         if($HOST_LUN eq "yes" && $lunString) {
  3460.                 $hostTag = "ESX/ESXi LUN(s)-$cluster_count";
  3461.                 $hostTagShort = "ESX/ESXi LUN(s)";
  3462.  
  3463.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3464.  
  3465.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3466.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3467.                 $table_host_conf .= "<table border=\"1\">\n";
  3468.  
  3469.         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3470.             $table_host_conf .= "<tr><th>VOLUME UUID</th><th>DATASTORE</th><th>DISK_NAME</th><th>DEVICE_NAME</th><th>QUEUE DEPTH</th><th>vSTORAGE SUPPORT</th><th>STATUS</th><th>VENDOR</th><th>MODEL</th><th>HOST(s) NOT ACCESSIBLE TO LUN</tr>\n";
  3471.         } else {
  3472.                     $table_host_conf .= "<tr><th>VOLUME UUID</th><th>DATASTORE</th><th>DISK_NAME</th><th>DEVICE_NAME</th><th>QUEUE DEPTH</th><th>STATUS</th><th>VENDOR</th><th>MODEL</th><th>HOST(s) NOT ACCESSIBLE TO LUN</tr>\n";
  3473.         }
  3474.  
  3475.         $table_host_conf .= $lunString;
  3476.         $table_host_conf .= "</table>\n";
  3477.                 $hostString .= "<br/>".$table_host_conf;
  3478.                 ($table_host_conf,$lunString) = ("","");
  3479.         }
  3480.     if($HOST_DATASTORE eq "yes" && $datastoreString ne "") {
  3481.                 $hostTag = "ESX/ESXi Datastore(s)-$cluster_count";
  3482.                 $hostTagShort = "ESX/ESXi Datastore(s)";
  3483.  
  3484.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3485.  
  3486.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3487.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3488.                 $table_host_conf .= "<table border=\"1\"><tr><td bgcolor=\"#CCCCCC\"><b>COLOR LEGEND</b></td><td bgcolor=\"$yellow\"><b>YELLOW < $YELLOW_WARN %</b></td><td bgcolor=\"$orange\"><b>ORANGE < $ORANGE_WARN %</b></td><td bgcolor=\"$red\"><b>RED < $RED_WARN %</b></td></tr></table>\n";
  3489.                 $table_host_conf .= "<table border=\"1\">\n";
  3490.  
  3491.         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3492.             $table_host_conf .= "<tr><th>DATASTORE</th><th># OF VMS</th><th>CAPACITY</th><th>CONSUMED</th><th>FREE</th><th>% FREE</th><th>BLOCK SIZE</th><th>VERSION</th><th>DS TYPE</th><th>MAINTENANCE MODE</th><th>IORM ENABLED</th><th>CONGESTION THRESHOLD</th><th>STATS AGGREGATION DIABLED</th><th>STATS COLLECTION ENABLED</th><th>HOST(s) NOT ACCESSIBLE TO DATASTORE</tr>\n";
  3493.         } else {
  3494.                     $table_host_conf .= "<tr><th>DATASTORE</th><th># OF VMS</th><th>CAPACITY</th><th>CONSUMED</th><th>FREE</th><th>% FREE</th><th>BLOCK SIZE</th><th>VERSION</th><th>DS TYPE</th><th>HOST(s) NOT ACCESSIBLE TO DATASTORE</tr>\n";
  3495.         }
  3496.  
  3497.         $table_host_conf .= $datastoreString;
  3498.         $table_host_conf .= "</table>\n";
  3499.                 $hostString .= "<br/>".$table_host_conf;
  3500.                 ($table_host_conf,$datastoreString) = ("","");
  3501.         }
  3502.     if($HOST_CACHE eq "yes" && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3503.                 $hostTag = "ESX/ESXi Cache Configuration-$cluster_count";
  3504.                 $hostTagShort = "ESX/ESXi Cache Configuration";
  3505.  
  3506.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3507.  
  3508.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3509.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3510.                 $table_host_conf .= "<table border=\"1\">\n";
  3511.                 $table_host_conf .= "<tr><th>HOST</th><th>CACHE DATASTORE</th><th>SWAPSIZE</th></tr>\n";
  3512.  
  3513.                 $table_host_conf .= $cacheString;
  3514.                 $table_host_conf .= "</table>\n";
  3515.                 $hostString .= "<br/>".$table_host_conf;
  3516.                 ($table_host_conf,$cacheString) = ("","");
  3517.         }
  3518.         if($HOST_PORTGROUP eq "yes" && $portgroupString ne "") {
  3519.                 $hostTag = "ESX/ESXi Portgroup(s)-$cluster_count";
  3520.                 $hostTagShort = "ESX/ESXi Portgroup(s)";
  3521.  
  3522.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3523.  
  3524.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3525.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3526.                 $table_host_conf .= "<table border=\"1\">\n";
  3527.                 $table_host_conf .= "<tr><th>PORTGROUP</th><th>HOST(s) NOT ACCESSIBLE TO PORTGROUP</th></tr>\n";
  3528.  
  3529.         $table_host_conf .= $portgroupString;
  3530.         $table_host_conf .= "</table>\n";
  3531.                 $hostString .= "<br/>".$table_host_conf;
  3532.                 ($table_host_conf,$portgroupString) = ("","");
  3533.         }
  3534.         if($HOST_MULTIPATH eq "yes" && $multipathString ne "") {
  3535.                 $hostTag = "ESX/ESXi Multipathing-$cluster_count";
  3536.                 $hostTagShort = "ESX/ESXi Multipathing";
  3537.  
  3538.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3539.  
  3540.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3541.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3542. ###DEBUG
  3543.                 #$table_host_conf .= "<table border=\"1\">\n";
  3544.  
  3545.         $table_host_conf .= $multipathString;
  3546.         $table_host_conf .= "</table>\n";
  3547.                 $hostString .= "<br/>".$table_host_conf;
  3548.                 ($table_host_conf,$multipathString) = ("","");
  3549.         }
  3550.         if($HOST_LOG eq "yes" && $logString ne "") {
  3551.                 $hostTag = "ESX/ESXi Hostd Logs-$cluster_count - Last $logcount lines";
  3552.                 $hostTagShort = "ESX/ESXi Hostd Logs - Last $logcount lines";
  3553.  
  3554.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3555.  
  3556.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3557.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3558.                 $table_host_conf .= "<table border=\"1\">\n";
  3559.  
  3560.         $table_host_conf .= $logString;
  3561.         $table_host_conf .= "</table>\n";
  3562.                 $hostString .= "<br/>".$table_host_conf;
  3563.                 ($table_host_conf,$logString) = ("","");
  3564.         }
  3565.     if($HOST_TASK eq "yes" && $taskString ne "") {
  3566.                 $hostTag = "ESX/ESXi Recent Tasks-$cluster_count";
  3567.                 $hostTagShort = "ESX/ESXi Recent Tasks";
  3568.  
  3569.                 push @host_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3570.  
  3571.                 $table_host_conf .= "<a name=\"$hostTag\"></a>\n";
  3572.                 $table_host_conf .= "<h3>$hostTagShort:</h3>\n";
  3573.                 $table_host_conf .= "<table border=\"1\">\n";
  3574.                 $table_host_conf .= "<tr><th>DESCRIPTION</th><th>QUEUE TIME</th><th>START TIME</th><th>COMPLETION TIME</th><th>PROGRESS</th><th>STATE</th></tr>\n";
  3575.    
  3576.         $table_host_conf .= $taskString;
  3577.         $table_host_conf .= "</table>\n";
  3578.                 $hostString .= "<br/>".$table_host_conf;
  3579.                 ($table_host_conf,$numaString) = ("","");
  3580.         }
  3581.  
  3582.     print REPORT_OUTPUT $hostString;
  3583.         $hostString = "";
  3584. }
  3585.  
  3586. sub buildVMReport {
  3587.         my ($cluster_name,$cluster_count,$type,$atype,$aversion) = @_;
  3588.         my ($hostTag,$hostTagShort,$table_vm_conf) = ("","","");
  3589.  
  3590.     if($VM_STATE eq "yes" && $vmstateString ne "") {
  3591.                 $hostTag = "VM State-$cluster_count";
  3592.                 $hostTagShort = "VM State";
  3593.  
  3594.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3595.  
  3596.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3597.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3598.                 $table_vm_conf .= "<table border=\"1\">\n";
  3599.  
  3600.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3601.                         $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>BOOTTIME</th><th>UPTIME</th><th>OVERALL STATUS</th><th>HA PROTECTED</th><th>APP HEARTBEAT</th><th>CONNECTION STATE</th><th>POWER STATE</th><th>CONSOLIDATION NEEDED</th></tr>\n";
  3602.                 } else {
  3603.                     $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>BOOTTIME</th><th>OVERALL STATUS</th><th>CONNECTION STATE</th><th>POWER STATE</th></tr>\n";
  3604.                 }
  3605.  
  3606.                 $table_vm_conf .= $vmstateString;
  3607.                 $table_vm_conf .= "</table>\n";
  3608.                 $vmString .= "<br/>".$table_vm_conf;
  3609.                 ($table_vm_conf,$vmstateString) = ("","");
  3610.         }
  3611.     if($VM_CONFIG eq "yes" && $vmconfigString ne "") {
  3612.                 $hostTag = "VM Configuration-$cluster_count";
  3613.                 $hostTagShort = "VM Configuration";
  3614.  
  3615.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3616.  
  3617.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3618.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3619.                 $table_vm_conf .= "<table border=\"1\">\n";
  3620.            
  3621.         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3622.             $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>vHW</th><th>HOSTNAME</th><th>UUID</th><th>FIRMWARE</th><th>OS</th><th># of vCPU</th><th>vMEM</th><th># of vDISK</th><th>vDISK</th><th># of vNIC</th><th>CPU RESERV</th><th>MEM RESERV</th><th>IS TEMPLATE</th></tr>\n";
  3623.         } else {
  3624.             $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>vHW</th><th>HOSTNAME</th><th>UUID</th><th>OS</th><th># of vCPU</th><th>vMEM</th><th># of vDISK</th><th>vDISK</th><th># of vNIC</th><th>CPU RESERV</th><th>MEM RESERV</th><th>IS TEMPLATE</th></tr>\n";
  3625.         }
  3626.  
  3627.         $table_vm_conf .= $vmconfigString;
  3628.         $table_vm_conf .= "</table>\n";
  3629.                 $vmString .= "<br/>".$table_vm_conf;
  3630.                 ($table_vm_conf,$vmconfigString) = ("","");
  3631.         }
  3632.     if($VM_STATS eq "yes" && $vmstatString ne "") {
  3633.         $hostTag = "VM Statistics-$cluster_count";
  3634.                 $hostTagShort = "VM Statistics";
  3635.  
  3636.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3637.  
  3638.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3639.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3640.                 $table_vm_conf .= "<table border=\"1\">\n";
  3641.  
  3642.         if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3643.             $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>CPU USAGE</th><th>MEM USAGE</th><th>MAX CPU USAGE</th><th>MAX MEM USAGE</th><th>ACTIVE MEM</th><th>HOST CONSUMED MEM</th><th>INITIAL MEM RESV OVERHEAD</th><th>INITIAL MEM SWAP RESV OVERHEAD</th><th>MEM OVERHEAD</th><th>MEM BALLON</th><th>COMPRESSED MEM</th></tr>\n";
  3644.         } else {
  3645.             $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>CPU USAGE</th><th>MEM USAGE</th><th>MAX CPU USAGE</th><th>MAX MEM USAGE</th><th>ACTIVE MEM</th><th>HOST CONSUMED MEM</th><th>MEM OVERHEAD</th><th>MEM BALLON</th></tr>\n";
  3646.         }
  3647.    
  3648.         $table_vm_conf .= $vmstatString;
  3649.         $table_vm_conf .= "</table>\n";
  3650.                 $vmString .= "<br/>".$table_vm_conf;
  3651.                 ($table_vm_conf,$vmstatString) = ("","");  
  3652.     }
  3653.     if($VM_RESOURCE_ALLOCATION eq "yes" && $vmrscString ne "") {
  3654.         $hostTag = "VM Resource Allocation-$cluster_count";
  3655.                 $hostTagShort = "VM Resource Allocation";
  3656.  
  3657.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3658.  
  3659.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3660.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3661.                 $table_vm_conf .= "<table border=\"1\">\n";
  3662.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>LAST MODIFIED</th><th>CPU RESERVATION</th><th>CPU LIMITS</th><th>CPU SHARE</th><th>CPU SHARE LEVEL</th><th>CPU EXPANDABLE RESERVATION</th><th>CPU OVERHEAD LIMIT</th><th>MEM RESERVATION</th><th>MEM LIMITS</th><th>MEM SHARE</th><th>MEM SHARE LEVEL</th><th>MEM EXPANDABLE RESERVATION</th><th>MEM OVERHEAD LIMIT</th></tr>\n";
  3663.  
  3664.                 $table_vm_conf .= $vmrscString;
  3665.                 $table_vm_conf .= "</table>\n";
  3666.                 $vmString .= "<br/>".$table_vm_conf;
  3667.                 ($table_vm_conf,$vmrscString) = ("","");
  3668.     }
  3669.     if($VM_PERFORMANCE eq "yes" || $vmperformance eq "yes" && $vmPerfString ne "") {
  3670.         $hostTag = "VM Performance-$cluster_count";
  3671.                 $hostTagShort = "VM Performance";
  3672.  
  3673.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3674.  
  3675.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3676.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3677.                 $table_vm_conf .= "<table border=\"1\">\n";
  3678.                 $table_vm_conf .= "<tr><th>VM</th><th>cpu.usagemhz.average</th><th>cpu.usage.average</th><th>cpu.ready.summation</th><th>mem.active.average</th><th>mem.usage.average</th><th>cpu.vmmemctl.average</th</tr>\n";
  3679.  
  3680.         $table_vm_conf .= $vmPerfString;
  3681.         $table_vm_conf .= "</table>\n";
  3682.                 $vmString .= "<br/>".$table_vm_conf;
  3683.                 ($table_vm_conf,$vmPerfString) = ("","");
  3684.     }
  3685.     if($VM_FT eq "yes" && $vmftString ne "") {
  3686.         $hostTag = "VM Fault Tolerance-$cluster_count";
  3687.                 $hostTagShort = "VM Fault Tolerance";
  3688.  
  3689.         push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3690.  
  3691.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3692.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3693.                 $table_vm_conf .= "<table border=\"1\">\n";
  3694.         $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>FT STATE</th><th>ROLE</th><th>INSTANCE UUIDS</th><th>FT SECONDARY LATENCY</th><th>FT BANDWIDTH</th></tr>\n";
  3695.  
  3696.         $table_vm_conf .= $vmftString;
  3697.         $table_vm_conf .= "</table>\n";
  3698.                 $vmString .= "<br/>".$table_vm_conf;
  3699.                 ($table_vm_conf,$vmftString) = ("","");
  3700.     }
  3701.     if($VM_EZT eq "yes" && $vmeztString ne "" && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3702.                 $hostTag = "VM Eagerzeroed Thick (EZT) Provisioned-$cluster_count";
  3703.                 $hostTagShort = "VM Eagerzeroed Thick (EZT) Provisioned";
  3704.  
  3705.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3706.  
  3707.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3708.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3709.                 $table_vm_conf .= "<table border=\"1\">\n";
  3710.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>LABEL</th><th>EZT VMDK(s)</th><th>CAPACITY</th></tr>\n";
  3711.  
  3712.                 $table_vm_conf .= $vmeztString;
  3713.                 $table_vm_conf .= "</table>\n";
  3714.                 $vmString .= "<br/>".$table_vm_conf;
  3715.                 ($table_vm_conf,$vmeztString) = ("","");
  3716.         }
  3717.     if($VM_THIN eq "yes" && $vmthinString ne "") {
  3718.                 $hostTag = "VM Thin Provisioned-$cluster_count";
  3719.                 $hostTagShort = "VM Thin Provisioned";
  3720.  
  3721.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3722.  
  3723.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3724.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3725.                 $table_vm_conf .= "<table border=\"1\">\n";
  3726.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>LABEL</th><th>THIN VMDK(s)</th><th>CAPACITY</th></tr>\n";
  3727.  
  3728.         $table_vm_conf .= $vmthinString;
  3729.         $table_vm_conf .= "</table>\n";
  3730.                 $vmString .= "<br/>".$table_vm_conf;
  3731.                 ($table_vm_conf,$vmthinString) = ("","");
  3732.         }
  3733.     if($VM_DEVICE eq "yes" && $vmdeviceString ne "") {
  3734.                 $hostTag = "VM Device(s)-$cluster_count";
  3735.                 $hostTagShort = "VM Device(s)";
  3736.  
  3737.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3738.  
  3739.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3740.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3741.                 $table_vm_conf .= "<table border=\"1\">\n";
  3742.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>OS</th><th>CDROM</th><th>CONTROLLER</th><th>DISK</th><th>ETHERNET CARD</th><th>FLOPPY</th><th>KEYBOARD</th><th>VIDEO CARD</th><th>VMCI</th><th>VMIROM</th><th>PARALLEL PORT</th><th>PCI PASSTHROUGH</th><th>POINTING DEVICE</th><th>SCSI PASSTHROUGH</th><th>SERIAL PORT</th><th>SOUND CARD</th><th>USB</th></tr>\n";
  3743.  
  3744.                 $table_vm_conf .= $vmdeviceString;
  3745.                 $table_vm_conf .= "</table>\n";
  3746.                 $vmString .= "<br/>".$table_vm_conf;
  3747.                 ($table_vm_conf,$vmdeviceString) = ("","");
  3748.         }
  3749.     if($VM_STORAGE eq "yes" && $vmstorageString ne "") {
  3750.         $hostTag = "VM Storage-$cluster_count";
  3751.                 $hostTagShort = "VM Storage";
  3752.  
  3753.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3754.  
  3755.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3756.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3757.         $table_vm_conf .= "<table border=\"1\"><tr><td bgcolor=\"#CCCCCC\"><b>COLOR LEGEND</b></td><td bgcolor=\"$yellow\"><b>YELLOW < $YELLOW_WARN %</b></td><td bgcolor=\"$orange\"><b>ORANGE < $ORANGE_WARN %</b></td><td bgcolor=\"$red\"><b>RED < $RED_WARN %</b></td></tr></table>\n";
  3758.                 $table_vm_conf .= "<table border=\"1\">\n";
  3759.         $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th><table border=\"1\"><tr><td><b>DISK INFO</b></td><td><b>FREE SPACE</b></td><td><b>CAPACITY</b></td><td><b>% FREE</b></td></tr></table></th></tr>\n";
  3760.  
  3761.         $table_vm_conf .= $vmstorageString;
  3762.         $table_vm_conf .= "</table>\n";
  3763.                 $vmString .= "<br/>".$table_vm_conf;
  3764.                 ($table_vm_conf,$vmstorageString) = ("","");
  3765.         }
  3766.         if($VM_NETWORK eq "yes" && $vmnetworkString ne "") {
  3767.         $hostTag = "VM Network-$cluster_count";
  3768.                 $hostTagShort = "VM Network";
  3769.  
  3770.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3771.  
  3772.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3773.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3774.                 $table_vm_conf .= "<table border=\"1\">\n";
  3775.         $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>IP ADDRESS(s)</th><th>MAC ADDRESS(s)</th><th>PORTGROUP(s)</th><th>CONNECTED</th></tr>\n";
  3776.  
  3777.         $table_vm_conf .= $vmnetworkString;
  3778.         $table_vm_conf .= "</table>\n";
  3779.                 $vmString .= "<br/>".$table_vm_conf;
  3780.                 ($table_vm_conf,$vmnetworkString) = ("","");
  3781.         }
  3782.     if($VM_SNAPSHOT eq "yes" && $vmsnapString ne "") {
  3783.                 $hostTag = "VM Snapshots-$cluster_count";
  3784.                 $hostTagShort = "VM Snapshots";
  3785.  
  3786.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3787.  
  3788.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3789.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3790.                 $table_vm_conf .= "<table border=\"1\">\n";
  3791.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>SNAPSHOT NAME</th><th>SNAPSHOT DESC</th><th>CREATED</th><th>STATE</th><th>QUIESCED</th></tr>\n";
  3792.  
  3793.         $table_vm_conf .= $vmsnapString;
  3794.         $table_vm_conf .= "</table>\n";
  3795.                 $vmString .= "<br/>".$table_vm_conf;
  3796.                 ($table_vm_conf,$vmsnapString) = ("","");
  3797.         }
  3798.     if($VM_DELTA eq "yes" && $vmdeltaString ne "") {
  3799.         $hostTag = "VM Deltas-$cluster_count";
  3800.                 $hostTagShort = "VM Deltas";
  3801.  
  3802.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3803.  
  3804.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3805.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3806.         $table_vm_conf .= "<table border=\"1\"><tr><td bgcolor=\"#CCCCCC\"><b>COLOR LEGEND</b></td><td bgcolor=\"$yellow\"><b>YELLOW > $SNAPSHOT_YELLOW_WARN days</b></td><td bgcolor=\"$orange\"><b>ORANGE > $SNAPSHOT_ORANGE_WARN days</b></td><td bgcolor=\"$red\"><b>RED > $SNAPSHOT_RED_WARN days</b></td></tr></table>\n";
  3807.                 $table_vm_conf .= "<table border=\"1\">\n";
  3808.         $table_vm_conf .= "<tr><th>DATASTORE</th><th>VM DELTA</th><th>AGE</th><th>SIZE</th><th>CREATED</th></tr>\n";
  3809.        
  3810.         $table_vm_conf .= $vmdeltaString;
  3811.         $table_vm_conf .= "</table>\n";
  3812.                 $vmString .= "<br/>".$table_vm_conf;
  3813.                 ($table_vm_conf,$vmdeltaString) = ("","");
  3814.     }
  3815.     if($VM_CDROM eq "yes" && $vmcdString ne "") {
  3816.                 $hostTag = "VM Mounted CD-ROM-$cluster_count";
  3817.                 $hostTagShort = "VM Mounted CD-ROM";
  3818.  
  3819.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3820.  
  3821.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3822.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3823.                 $table_vm_conf .= "<table border=\"1\">\n";
  3824.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>ISO</th></tr>\n";
  3825.  
  3826.         $table_vm_conf .= $vmcdString;
  3827.         $table_vm_conf .= "</table>\n";
  3828.                 $vmString .= "<br/>".$table_vm_conf;
  3829.                 ($table_vm_conf,$vmcdString) = ("","");
  3830.         }
  3831.     if($VM_FLOPPY eq "yes" && $vmflpString ne "") {
  3832.                 $hostTag = "VM Mounted Floppy-$cluster_count";
  3833.                 $hostTagShort = "VM Mounted Floppy";
  3834.  
  3835.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3836.  
  3837.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3838.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3839.                 $table_vm_conf .= "<table border=\"1\">\n";
  3840.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>IMG</th></tr>\n";
  3841.  
  3842.         $table_vm_conf .= $vmflpString;
  3843.         $table_vm_conf .= "</table>\n";
  3844.                 $vmString .= "<br/>".$table_vm_conf;
  3845.                 ($table_vm_conf,$vmflpString) = ("","");
  3846.         }
  3847.     if($VM_TOOL eq "yes" && $vmtoolString) {
  3848.                 $hostTag = "VM VMware Tools-$cluster_count";
  3849.                 $hostTagShort = "VM VMware Tools";
  3850.  
  3851.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3852.  
  3853.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3854.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3855.                 $table_vm_conf .= "<table border=\"1\">\n";
  3856.         $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>VERSION</th><th>RUNNING STATUS</th><th>VERSION STATUS</th><th>UPGRADE POLICY</th><th>SYNC TIME W/HOST</th></tr>\n";
  3857.  
  3858.         $table_vm_conf .= $vmtoolString;
  3859.         $table_vm_conf .= "</table>\n";
  3860.                 $vmString .= "<br/>".$table_vm_conf;
  3861.                 ($table_vm_conf,$vmtoolString) = ("","");
  3862.     }
  3863.     if($VM_RDM eq "yes" && $vmrdmString ne "") {
  3864.                 $hostTag = "VM RDMs-$cluster_count";
  3865.                 $hostTagShort = "VM RDMs";
  3866.  
  3867.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3868.  
  3869.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3870.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3871.                 $table_vm_conf .= "<table border=\"1\">\n";
  3872.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>COMPAT MODE</th><th>DEVICE</th><th>DISK MODE</th><th>LUN UUID</th><th>VIRTUAL DISK UUID</th></tr>\n";
  3873.  
  3874.         $table_vm_conf .= $vmrdmString;
  3875.         $table_vm_conf .= "</table>\n";
  3876.                 $vmString .= "<br/>".$table_vm_conf;
  3877.                 ($table_vm_conf,$vmrdmString) = ("","");
  3878.         }
  3879.     if($VM_NPIV eq "yes" && $vmnpivString ne "") {
  3880.                 $hostTag = "VM NPIV-$cluster_count";
  3881.                 $hostTagShort = "VM NPIV";
  3882.  
  3883.                 push @vm_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3884.  
  3885.                 $table_vm_conf .= "<a name=\"$hostTag\"></a>\n";
  3886.                 $table_vm_conf .= "<h3>$hostTagShort:</h3>\n";
  3887.                 $table_vm_conf .= "<table border=\"1\">\n";
  3888.                 $table_vm_conf .= "<tr><th>HOST</th><th>VM</th><th>NODE WWN</th><th>PORT WWN</th><th>GENERATED FROM</th><th>DESIRED NODE WWN</th><th>DESIRED PORT WWN</th></tr>\n";
  3889.  
  3890.                 $table_vm_conf .= $vmnpivString;
  3891.                 $table_vm_conf .= "</table>\n";
  3892.                 $vmString .= "<br/>".$table_vm_conf;
  3893.                 ($table_vm_conf,$vmnpivString) = ("","");
  3894.         }
  3895.  
  3896.     print REPORT_OUTPUT $vmString;
  3897.         $vmString = "";
  3898. }
  3899.  
  3900. sub printClusterSummary {
  3901.     my ($local_cluster,$cluster_count,$atype,$aversion) = @_;
  3902.  
  3903.     my $cluster_name = $local_cluster->name;
  3904.         my $cluster_health = $local_cluster->overallStatus->val;
  3905.         my $cluster_host_cnt = $local_cluster->summary->numHosts;
  3906.         my $cluster_avail_host = $local_cluster->summary->numEffectiveHosts;
  3907.         my $cluster_cpu_cnt = prettyPrintData($local_cluster->summary->totalCpu,'MHZ');
  3908.         my $cluster_mem_cnt = prettyPrintData($local_cluster->summary->totalMemory,'B');
  3909.         my $cluster_avail_cpu = prettyPrintData($local_cluster->summary->effectiveCpu,'MHZ');
  3910.         my $cluster_avail_mem = prettyPrintData($local_cluster->summary->effectiveMemory,'M');
  3911.         my $cluster_drs = $local_cluster->configuration->drsConfig->enabled;
  3912.         my $cluster_ha = $local_cluster->configuration->dasConfig->enabled;
  3913.         my $cluster_dpm = $local_cluster->configurationEx->dpmConfigInfo->enabled;
  3914.         my $cluster_vm_mon = $local_cluster->configuration->dasConfig->vmMonitoring;
  3915.         my $cluster_host_mon = $local_cluster->configuration->dasConfig->hostMonitoring;
  3916.     my $vmotions = $local_cluster->summary->numVmotions;
  3917.         my ($mem_perc_string,$cpu_perc_string,$evc,$spbm,$hbDSPolicy) = ("","","DISABLED","N/A","N/A");
  3918.     my $curr_bal = ($local_cluster->summary->currentBalance ? ($local_cluster->summary->currentBalance/1000) : "N/A");
  3919.     my $tar_bal = ($local_cluster->summary->targetBalance ? ($local_cluster->summary->targetBalance/1000) : "N/A");
  3920.  
  3921.     if($local_cluster->summary->currentEVCModeKey) {
  3922.         $evc = $local_cluster->summary->currentEVCModeKey;
  3923.     }
  3924.  
  3925.     if(($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  3926.         if(defined($local_cluster->configurationEx->spbmEnabled)) {
  3927.             $spbm = $local_cluster->configurationEx->spbmEnabled ? "YES" : "NO";
  3928.         }
  3929.         if(defined($local_cluster->configurationEx->dasConfig->hBDatastoreCandidatePolicy)) {
  3930.             $hbDSPolicy = $local_cluster->configurationEx->dasConfig->hBDatastoreCandidatePolicy;
  3931.         }
  3932.     }
  3933.  
  3934.     ###########################
  3935.         # CLUSTER SUMMARY
  3936.         ###########################
  3937.  
  3938.     push @cluster_jump_tags,"CL<a href=\"#$cluster_name\">Cluster: $cluster_name</a><br/>\n";
  3939.    
  3940.     my $cluster_start .= "<a name=\"$cluster_name\"></a>\n";
  3941.     $cluster_start .= "<h2>Cluster: $cluster_name</h2>\n";
  3942.     my ($hostTag,$hostTagShort) = ("","");
  3943.  
  3944.     ###########################
  3945.         # SUMMARY
  3946.         ###########################
  3947.         if($CLUSTER_SUMMARY eq "yes") {
  3948.         $hostTag = "Cluster Summary-$cluster_name";
  3949.         $hostTagShort = "Cluster Summary";
  3950.         push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  3951.  
  3952.                 $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  3953.                 $cluster_start .= "<h3>Cluster Summary:</h3>\n";
  3954.         $cluster_start .= "<table border=\"1\">\n";
  3955.         $cluster_start .= "<tr><th>CLUSTER HEALTH</th><th>AVAILABLE HOST(s)</th><th># OF VMS</th><th>VM-TO-HOST RATIO</th><th>CURRENT BALANCE</th><th>TARGET BALANCE</th><th>AVAILABLE CPU</th><th>AVAILABLE MEM</th><th>DRS ENABLED</th><th>HA ENABLED</th><th>DPM ENABLED</th><th>EVC ENABLED</th><th>SPBM ENABLED</th><th># OF vMOTIONS</th></tr>\n";
  3956.  
  3957.         my $rp = Vim::get_view(mo_ref => $local_cluster->resourcePool, properties => ['vm']);
  3958.         my $vms = Vim::get_views(mo_ref_array => $rp->{'vm'}, properties => ['name']);
  3959.         my $num_of_vms = 0;
  3960.         if(@$vms ne 0) { $num_of_vms = @$vms; }
  3961.  
  3962.         my $vm_host_ratio = "N/A";
  3963.         if($cluster_avail_host eq 1 && ($num_of_vms ne 0 || $num_of_vms eq 1)) {
  3964.             $vm_host_ratio = $num_of_vms
  3965.         } elsif($num_of_vms eq 1) {
  3966.             $vm_host_ratio = $num_of_vms
  3967.         } elsif($num_of_vms ne 0 && $cluster_avail_host ne 0) {
  3968.             $vm_host_ratio = int($num_of_vms/$cluster_avail_host);
  3969.         } else {
  3970.             $vm_host_ratio =  $num_of_vms;
  3971.         }
  3972.  
  3973.         $cluster_start .= "<tr>";
  3974.         if($cluster_health eq 'gray' ) { $cluster_start .= "<td bgcolor=gray>UNKNOWN"; }
  3975.             if($cluster_health eq 'green' ) { $cluster_start .= "<td bgcolor=$green>CLUSTER OK"; }
  3976.             if($cluster_health eq 'red' ) { $cluster_start .= "<td bgcolor=red>CLUSTER HAS PROBLEM"; }
  3977.             if($cluster_health eq 'yellow' ) { $cluster_start .= "<td bgcolor=yellow>CLUSTER MIGHT HAVE PROBLEM"; }
  3978.         $cluster_start .= "<td>".$cluster_avail_host."/".$cluster_host_cnt."</td>";
  3979.         $cluster_start .= "<td>".$num_of_vms."</td>";
  3980.         $cluster_start .= "<td>".$vm_host_ratio."</td>";
  3981.         $cluster_start .= "<td>".$curr_bal."</td>";
  3982.                 $cluster_start .= "<td>".$tar_bal."</td>";
  3983.         $cluster_start .= "<td>".$cluster_avail_cpu."</td>";
  3984.         $cluster_start .= "<td>".$cluster_avail_mem."</td>";
  3985.         $cluster_start .= "<td>".(($cluster_drs) ? "YES" : "NO")."</td>";
  3986.         $cluster_start .= "<td>".(($cluster_ha) ? "YES" : "NO")."</td>";
  3987.         $cluster_start .= "<td>".(($cluster_dpm) ? "YES" : "NO")."</td>";
  3988.         $cluster_start .= "<td>".$evc."</td>";
  3989.         $cluster_start .= "<td>".$spbm."</td>";
  3990.         $cluster_start .= "<td>".$vmotions."</td>";
  3991.         $cluster_start .= "</tr>\n</table>\n";
  3992.     }
  3993.  
  3994.     ###########################
  3995.     # CLUSTER PERFORMANCE
  3996.     ###########################
  3997.     if($CLUSTER_PERFORMANCE eq "yes" || $clusterperformance eq "yes") {
  3998.         my $clusterPerfString = &getCpuAndMemPerf($local_cluster);
  3999.         $cluster_start .= $clusterPerfString;
  4000.     }
  4001.  
  4002.     ###########################
  4003.         # PRINT HA INFO
  4004.         ###########################
  4005.     if($cluster_ha && $CLUSTER_HA eq "yes") {
  4006.         $hostTag = "HA Configurations-$cluster_name";
  4007.                 $hostTagShort = "HA Configurations";
  4008.  
  4009.                 push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4010.  
  4011.                 $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4012.         $cluster_start .= "<h3>HA Configurations</h3>\n";
  4013.         $cluster_start .= "<table border=\"1\">\n";
  4014.         $cluster_start .= "<tr><th>FAILOVER LEVEL</th><th>ADMISSION CONTROL ENABLED</th><th>ISOLATION RESPONSE</th><th>RESTART PRIORITY</th><th>VM MONITORING</th><th>HOST MONITORING</th><th>HB DATASTORE POLICY</tr>\n";
  4015.  
  4016.         if(defined($local_cluster->configuration->dasConfig->admissionControlPolicy)) {
  4017.                         my $admissionControlPolicy = $local_cluster->configuration->dasConfig->admissionControlPolicy;
  4018.                         if($admissionControlPolicy->isa('ClusterFailoverHostAdmissionControlPolicy')) {
  4019.                                 if($admissionControlPolicy->failoverHosts) {
  4020.                                         my $failoverHosts = $admissionControlPolicy->failoverHosts;
  4021.                                         my $failoverHostString = "";
  4022.                                         foreach(@$failoverHosts) {
  4023.                                                 my $fhost = Vim::get_view(mo_ref => $_, properties => ['name']);
  4024.                                                 $failoverHostString .= $fhost->{'name'} . "<br/>";
  4025.                                         }
  4026.                                         $cluster_start .= "<td>".$failoverHostString."</td>";
  4027.                                 } else {
  4028.                                         $cluster_start .= "<td>N/A</td>";
  4029.                                 }
  4030.                         }elsif($admissionControlPolicy->isa('ClusterFailoverLevelAdmissionControlPolicy')) {
  4031.                                 $cluster_start .= "<td>".$admissionControlPolicy->failoverLevel."</td>";
  4032.                         }elsif($admissionControlPolicy->isa('ClusterFailoverResourcesAdmissionControlPolicy')) {
  4033.                                 $cluster_start .= "<td>".$admissionControlPolicy->cpuFailoverResourcesPercent."% CPU -- ".$admissionControlPolicy->memoryFailoverResourcesPercent." %MEM "."</td>";
  4034.                         } else {
  4035.                                 $cluster_start .= "<td>N/A</td>";
  4036.                         }
  4037.                 } else {
  4038.                         $cluster_start .= "<td>N/A</td>";
  4039.                 }
  4040.                 $cluster_start .= "<td>".(($local_cluster->configuration->dasConfig->admissionControlEnabled) ? "YES" : "NO")."</td>";
  4041.                 $cluster_start .= "<td>".$local_cluster->configuration->dasConfig->defaultVmSettings->isolationResponse."</td>";
  4042.                 $cluster_start .= "<td>".$local_cluster->configuration->dasConfig->defaultVmSettings->restartPriority."</td>";
  4043.                 $cluster_start .= "<td>".$cluster_vm_mon."</td>";
  4044.                 $cluster_start .= "<td>".$cluster_host_mon."</td>";
  4045.         $cluster_start .= "<td>".$hbDSPolicy."</td>";
  4046.                 $cluster_start .= "</table>\n";
  4047.  
  4048.         my $haAdvInfo;
  4049.         eval { $haAdvInfo = $local_cluster->RetrieveDasAdvancedRuntimeInfo(); };
  4050.         if(!$@) {
  4051.             if($haAdvInfo) {
  4052.                 my @configIssues = ();
  4053.  
  4054.                 ## HA ADV INFO ##
  4055.                 $cluster_start .= "<h3>HA Advanced Runtime Info</h3>\n";
  4056.                 $cluster_start .= "<table border=\"1\">\n";
  4057.                 $cluster_start .= "<tr><th>SLOT SIZE</th><th>TOTAL SLOTS IN CLUSTER</th><th>USED SLOTS</th><th>AVAILABLE SLOTS</th><th>TOTAL POWERED ON VMS</th><th>TOTAL HOSTS</th><th>TOTAL GOOD HOSTS</th></tr>\n";
  4058.  
  4059.                 if($haAdvInfo->isa('ClusterDasFailoverLevelAdvancedRuntimeInfo')) {
  4060.                                         $cluster_start .= "<td>".($haAdvInfo->slotInfo->cpuMHz ? $haAdvInfo->slotInfo->cpuMHz : "N/A"). " MHz -- ".($haAdvInfo->slotInfo->numVcpus ? $haAdvInfo->slotInfo->numVcpus : "N/A"). " vCPUs -- ".($haAdvInfo->slotInfo->memoryMB ? $haAdvInfo->slotInfo->memoryMB : "N/A")." MB</td>";
  4061.                                         $cluster_start .= "<td>".$haAdvInfo->totalSlots."</td>";
  4062.                                         $cluster_start .= "<td>".$haAdvInfo->usedSlots."</td>";
  4063.                                         $cluster_start .= "<td>".$haAdvInfo->unreservedSlots."</td>";
  4064.                                         $cluster_start .= "<td>".$haAdvInfo->totalVms."</td>";
  4065.                                         $cluster_start .= "<td>".$haAdvInfo->totalHosts."</td>";
  4066.                                         $cluster_start .= "<td>".$haAdvInfo->totalGoodHosts."</td>";
  4067.                                 } else {
  4068.                                         $cluster_start .= "<td>N/A</td>";
  4069.                                         $cluster_start .= "<td>N/A</td>";
  4070.                                         $cluster_start .= "<td>N/A</td>";
  4071.                                         $cluster_start .= "<td>N/A</td>";
  4072.                                         $cluster_start .= "<td>N/A</td>";
  4073.                                         $cluster_start .= "<td>N/A</td>";
  4074.                                         $cluster_start .= "<td>N/A</td>";
  4075.                                 }
  4076.                                 $cluster_start .= "</table>\n";        
  4077.  
  4078.                 ## HA HEARTBEAT DATASTORE ##
  4079.                 if(($aversion eq '5.0.0' || $aversion eq '5.1.0') && $haAdvInfo->heartbeatDatastoreInfo) {
  4080.                     my $hahbInfo = $haAdvInfo->heartbeatDatastoreInfo;
  4081.  
  4082.                     $hostTag = "Heartbeat Datastores-$cluster_name";
  4083.                                         $hostTagShort = "Heartbeat Datastores";
  4084.  
  4085.                                         push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4086.  
  4087.                                         $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4088.                                         $cluster_start .= "<h3>Heartbeat Datastores</h3>\n";
  4089.                                         $cluster_start .= "<table border=\"1\">\n";
  4090.                                         $cluster_start .= "<tr><th>DATASTORE</th><th>HOSTS MOUNTED</th></tr>\n";
  4091.  
  4092.                                         foreach(@$hahbInfo) {
  4093.                                                 my $hbDSName = Vim::get_view(mo_ref => $_->datastore, properties => ['name']);
  4094.                                                 my $hbHostMount = Vim::get_views(mo_ref_array=> $_->hosts, properties => ['name']);
  4095.                         $cluster_start .= "<tr><td>".$hbDSName->{'name'}."</td><td>".@$hbHostMount."</td></tr>";       
  4096.                                         }
  4097.                                         $cluster_start .= "</table>\n";
  4098.                 }
  4099.    
  4100.                 ## HA HOSTS INFO ##
  4101.                 if($haAdvInfo->dasHostInfo && $haAdvInfo->dasHostInfo->hostDasState) {
  4102.                     $cluster_start .= "<h3>HA Host Info</h3>\n";
  4103.                                 $cluster_start .= "<table border=\"1\">\n";
  4104.                     $cluster_start .= "<tr><th>HA PRIMARY HOSTS</th><th>HA SECONDARY HOSTS</th><th>NODE STATES</th></tr>\n";
  4105.  
  4106.                     my ($nodeStates,$primHosts,$secondHosts,$dasstring) = ("","","","");
  4107.                     my %primary = ();
  4108.                
  4109.                     $cluster_start .= "<tr>";  
  4110.                     if($haAdvInfo->dasHostInfo->primaryHosts) {
  4111.                         my $dashosts = $haAdvInfo->dasHostInfo->primaryHosts;
  4112.                         foreach my $dasHost (@$dashosts) {
  4113.                             if($demo eq "yes") {
  4114.                                 $dasHost = $host_name; 
  4115.                             }
  4116.                             $primHosts .= $dasHost."<br/>";
  4117.                             $primary{$dasHost} = "yes";
  4118.                         }
  4119.                         $cluster_start .= "<td>".$primHosts."</td>";
  4120.                     }
  4121.  
  4122.                     if($haAdvInfo->dasHostInfo->hostDasState) {
  4123.                         $dasstring .= "<td><table border=\"1\"><th>NODE</th><th>CONFIG STATE</th><th>RUN STATE</th>";
  4124.                         my $dasstates = $haAdvInfo->dasHostInfo->hostDasState; 
  4125.                         foreach(@$dasstates) {
  4126.                             my $dasHost;
  4127.                             if($demo eq "yes") {
  4128.                                 $dasHost = $host_name;
  4129.                             } else {
  4130.                                 $dasHost = $_->name;
  4131.                             }
  4132.                             $dasstring .= "<tr><td>".$dasHost."</td><td>".$_->configState."</td><td>".$_->runtimeState."</td></tr>\n";
  4133.                             if(!$primary{$dasHost}) {
  4134.                                 $secondHosts .= $dasHost."<br/>";
  4135.                             }
  4136.  
  4137.                             my $tmpHostMoRef = Vim::get_view(mo_ref => $_->host);
  4138.                             if($tmpHostMoRef->configIssue) {
  4139.                                 my $hostConfigIssues = $tmpHostMoRef->configIssue;
  4140.                                 foreach(@$hostConfigIssues) {
  4141.                                     my $issue = $tmpHostMoRef->name . ";" . ($_->fullFormattedMessage ? $_->fullFormattedMessage : "N/A");
  4142.                                     push @configIssues, $issue;
  4143.                                 }
  4144.                             }
  4145.                         }
  4146.                    
  4147.                         $cluster_start .= "<td>".$secondHosts."</td>"; 
  4148.                         $cluster_start .= $dasstring;
  4149.                         $cluster_start .= "</table></td>";
  4150.                     }
  4151.                     $cluster_start .= "</tr>";
  4152.  
  4153.                     $cluster_start .= "</table>\n";
  4154.                     %primary = ();
  4155.                                 }
  4156.  
  4157.                                 if($local_cluster->configIssue) {
  4158.                                         my $clusterConfigIssues = $local_cluster->configIssue;
  4159.                                         foreach(@$clusterConfigIssues) {
  4160.                                                 my $issue = $local_cluster->name . ";" . ($_->fullFormattedMessage ? $_->fullFormattedMessage : "N/A");
  4161.                                                 push @configIssues, $issue;
  4162.                                         }
  4163.                                 }
  4164.  
  4165.                 ## HA CONFIGURATION ISSUE##
  4166.                 if(@configIssues) {
  4167.                     $cluster_start .= "<h3>HA Configuration Issues</h3>\n";
  4168.                                         $cluster_start .= "<table border=\"1\">\n";
  4169.                                         $cluster_start .= "<tr><th>ENTITY</th><th>HA ISSUE</th></tr>\n";
  4170.  
  4171.                     foreach(@configIssues) {
  4172.                         my ($configIssueEntity,$configIssueMsg) = split(';',$_);
  4173.                         $cluster_start .= "<tr><td>".$configIssueEntity."</td><td>".$configIssueMsg."</td></tr>\n";
  4174.                     }
  4175.                     $cluster_start .= "</table></td>";
  4176.                 }
  4177.  
  4178.                 ## HA ADV OPTIONS ##
  4179.                 if($local_cluster->configurationEx->dasConfig->option) {
  4180.                     $cluster_start .= "<h3>HA Advanced Configurations</h3>\n";
  4181.                                 $cluster_start .= "<table border=\"1\">\n";
  4182.                                 $cluster_start .= "<tr><th>ATTRIBUTE</th><th>VALUE</th></tr>\n";
  4183.  
  4184.                     my $haadv_string = "";
  4185.                
  4186.                     my $advHAOptions = $local_cluster->configurationEx->dasConfig->option;
  4187.                     foreach(@$advHAOptions) {
  4188.                         $haadv_string .= "<tr><td>".$_->key."</td><td>".$_->value."</td></tr>\n";
  4189.                     }
  4190.                     $cluster_start .= $haadv_string;
  4191.                     $cluster_start .= "</table>\n";
  4192.                 }
  4193.             }
  4194.         }
  4195.  
  4196.     }
  4197.  
  4198.     ###########################
  4199.         # PRINT DRS INFO
  4200.         ###########################
  4201.         if($cluster_drs && $CLUSTER_DRS eq "yes") {
  4202.         $hostTag = "DRS Configurations-$cluster_name";
  4203.                 $hostTagShort = "DRS Configurations";
  4204.  
  4205.                 push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4206.  
  4207.                 $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4208.         $cluster_start .= "<h3>DRS Configurations</h3>\n";
  4209.         $cluster_start .= "<table border=\"1\">\n";
  4210.         $cluster_start .= "<tr><th>DRS BEHAVIOR</th><th>VMOTION RATE</th></tr>\n";
  4211.  
  4212.         $cluster_start .= "<tr><td>".$local_cluster->configuration->drsConfig->defaultVmBehavior->val."</td>";
  4213.         $cluster_start .= "<td>".$local_cluster->configuration->drsConfig->vmotionRate."</td>";
  4214.         $cluster_start .= "</tr></table>\n";
  4215.  
  4216.         ## DRS ADV OPTIONS ##
  4217.                 if($local_cluster->configurationEx->drsConfig->option) {
  4218.                         $cluster_start .= "<h3>DRS Advanced Configurations</h3>\n";
  4219.                         $cluster_start .= "<table border=\"1\">\n";
  4220.                         $cluster_start .= "<tr><th>ATTRIBUTE</th><th>VALUE</th></tr>\n";
  4221.  
  4222.                         my $drsadv_string = "";
  4223.  
  4224.                     my $advHAOptions = $local_cluster->configurationEx->drsConfig->option;
  4225.                         foreach(@$advHAOptions) {
  4226.                             $drsadv_string .= "<tr><td>".$_->key."</td><td>".$_->value."</td></tr>\n";
  4227.                         }
  4228.                     $cluster_start .= $drsadv_string;
  4229.                         $cluster_start .= "</table>\n";
  4230.                 }
  4231.     }
  4232.  
  4233.     ###########################
  4234.         # PRINT DPM INFO
  4235.         ###########################
  4236.         if($cluster_dpm && $CLUSTER_DPM eq "yes") {
  4237.         $hostTag = "DPM Configurations-$cluster_name";
  4238.                 $hostTagShort = "DPM Configurations";
  4239.  
  4240.                 push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4241.  
  4242.                 $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4243.         $cluster_start .= "<h3>DPM Configurations</h3>\n";
  4244.                 $cluster_start .= "<table border=\"1\">\n";
  4245.         $cluster_start .= "<tr><th>DPM BEHAVIOR</th></tr><tr>\n";
  4246.  
  4247.         $cluster_start .= "<td>".$local_cluster->configurationEx->dpmConfigInfo->defaultDpmBehavior->val."</td>";
  4248.         $cluster_start .= "</tr></table>\n";
  4249.     }
  4250.  
  4251.     ###########################
  4252.     # AFFINITY RULES
  4253.     ###########################
  4254.     if($CLUSTER_AFFINITY eq "yes") {
  4255.         if($local_cluster->configurationEx->rule) {
  4256.             my $rules = $local_cluster->configurationEx->rule;
  4257.  
  4258.             $hostTag = "Affinity Rules-$cluster_name";
  4259.                     $hostTagShort = "Affinity Rules";
  4260.  
  4261.                     push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4262.  
  4263.                     $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4264.             $cluster_start .= "<h3>Affinity Rules:</h3>\n";
  4265.             $cluster_start .= "<table border=\"1\">\n";
  4266.             if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  4267.                 $cluster_start .= "<tr><th>RULE NAME</th><th>RULE TYPE</th><th>ENABLED</th><th>VM(s)</th><th>COMPLIANT</th><th>MANDATORY</th><th>USER CREATED</th></tr>\n";
  4268.             } else {
  4269.                 $cluster_start .= "<tr><th>RULE NAME</th><th>RULE TYPE</th><th>ENABLED</th><th>VM(s)</th></tr>\n";
  4270.             }
  4271.  
  4272.             foreach(sort {$a->name cmp $b->name} @$rules) {
  4273.                 my $rule = $_;
  4274.                             my $is_enabled = $rule->enabled;
  4275.                             my $rule_name = $rule->name;
  4276.                             my $rule_type = "CLUSTER-RULE";
  4277.                 my $compliant;
  4278.  
  4279.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  4280.                     if($rule->inCompliance) {
  4281.                         $compliant = "<td bgcolor=\"$green\">YES</td>";
  4282.                     } else {
  4283.                         $compliant = "<td bgcolor=\"$red\">NO</td>";
  4284.                     }
  4285.                 }
  4286.  
  4287.                             if(ref($rule) eq 'ClusterAffinityRuleSpec') {
  4288.                                     $rule_type = "AFFINITY";
  4289.                             }
  4290.                             elsif (ref($rule) eq 'ClusterAntiAffinityRuleSpec') {
  4291.                                     $rule_type = "ANTI-AFFINITY";
  4292.                             }
  4293.                 my $listOfVMs = Vim::get_views(mo_ref_array => $_->{'vm'}, properties => ['name']);
  4294.                 my $listOfVmsString = "";
  4295.                 foreach(@$listOfVMs) {
  4296.                     $listOfVmsString .= $_->{'name'}."<br/>";
  4297.                 }
  4298.                 if($aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  4299.                     $cluster_start .= "<tr><td>".$rule_name."</td><td>".$rule_type."</td><td>".(($is_enabled) ? "YES" : "NO")."</td><td>".$listOfVmsString."</td>".$compliant."<td>".($rule->mandatory ? "YES" : "NO")."</td><td>".($rule->userCreated ? "YES" : "NO")."</td></tr>\n";
  4300.                 } else {
  4301.                     $cluster_start .= "<tr><td>".$rule_name."</td><td>".$rule_type."</td><td>".(($is_enabled) ? "YES" : "NO")."</td><td>".$listOfVmsString."</td></tr>\n";
  4302.                 }
  4303.             }
  4304.             $cluster_start .= "</table>\n";
  4305.         }
  4306.     }
  4307.  
  4308.     ###########################
  4309.         # AFFINITY GROUP RULES
  4310.         ###########################
  4311.     if($CLUSTER_GROUP eq "yes" && $aversion eq '4.1.0' || ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  4312.         if($local_cluster->configurationEx->group) {
  4313.                         my $groups = $local_cluster->configurationEx->group;
  4314.  
  4315.                         $hostTag = "Affinity Group Rules-$cluster_name";
  4316.                         $hostTagShort = "Affinity Group Rules";
  4317.  
  4318.                         push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4319.  
  4320.                         $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4321.                         $cluster_start .= "<h3>Affinity Group Rules:</h3>\n";
  4322.             my ($drsHostsGroupString,$drsVMGroupString) = ("","");         
  4323.  
  4324.             foreach(sort {$a->name cmp $b->name} @$groups) {
  4325.                 if($_->isa('ClusterHostGroup')) {
  4326.                     my $listOfHosts = Vim::get_views(mo_ref_array => $_->host, properties => ['name']);
  4327.                     my $listOfHostsString = "";
  4328.                     foreach(@$listOfHosts) {
  4329.                                             $listOfHostsString .= $_->{'name'}."<br/>";
  4330.                                     }  
  4331.                     $drsHostsGroupString .= "<tr><td>".$_->name."</td><td>".$listOfHostsString."</td></tr>\n";
  4332.                 }elsif($_->isa('ClusterVmGroup')) {
  4333.                     my $listOfVms = Vim::get_views(mo_ref_array => $_->vm, properties => ['name']);
  4334.                                         my $listOfVmsString = "";
  4335.                                         foreach(@$listOfVms) {
  4336.                                                 $listOfVmsString .= $_->{'name'}."<br/>";
  4337.                                         }
  4338.                     $drsVMGroupString .= "<tr><td>".$_->name."</td><td>".$listOfVmsString."</td></tr>\n";
  4339.                 }
  4340.             }
  4341.  
  4342.             #HOST GROUP
  4343.             if($drsHostsGroupString ne "") {
  4344.                 $cluster_start .= "<table border=\"1\">\n";
  4345.                 $cluster_start .= "<tr><th>RULE NAME</th><th>HOST(s)</th></tr>\n";
  4346.                 $cluster_start .= $drsHostsGroupString;
  4347.                 $cluster_start .= "</table><br/>\n";
  4348.             }  
  4349.  
  4350.             #VM GROUP
  4351.             if($drsVMGroupString ne "") {
  4352.                             $cluster_start .= "<table border=\"1\">\n";
  4353.                             $cluster_start .= "<tr><th>RULE NAME</th><th>VM(s)</th></tr>\n";
  4354.                 $cluster_start .= $drsVMGroupString;
  4355.                             $cluster_start .= "</table><br/>\n";
  4356.             }
  4357.                 }
  4358.  
  4359.     }
  4360.  
  4361.     ###########################
  4362.     # RESOURCE POOLS
  4363.     ###########################
  4364.     my ($resource_pool_string,$vapp_string) = ("","");
  4365.  
  4366.     if($CLUSTER_VAPP eq "yes" || $CLUSTER_RP eq "yes") {
  4367.         my $root_rp = Vim::get_view (mo_ref => $local_cluster->resourcePool);
  4368.         my $resourcePools = $root_rp->resourcePool;
  4369.        
  4370.         foreach(@$resourcePools) {
  4371.             my $rp = Vim::get_view(mo_ref => $_);
  4372.  
  4373.             if($rp->isa('VirtualApp')) {
  4374.                         my $vapp_name = $rp->name;
  4375.                             my $anno = ($rp->vAppConfig->annotation ? $rp->vAppConfig->annotation : "N/A");
  4376.  
  4377.                             my $ec = $rp->vAppConfig->entityConfig;
  4378.                             my $vm_vapp_string = "";
  4379.                             foreach(@$ec) {
  4380.                                         my $order = $_->startOrder;
  4381.                                     my $tag = $_->tag;
  4382.                                 $vm_vapp_string .= "<tr><td>".$tag."</td><td>".$order."</td></tr>\n";
  4383.                                 }
  4384.                                 $vapp_string .= "<tr><th colspan=2>".$vapp_name."</th><tr>\n";
  4385.                                 $vapp_string .= "<tr><th>VM</th><th>START ORDER</th></tr>\n";
  4386.                             $vapp_string .= $vm_vapp_string."</tr>\n";
  4387.                     } else {
  4388.                                 my $rp_name = $rp->name;
  4389.                             my $rp_status = $rp->summary->runtime->overallStatus->val;
  4390.                             if($rp_status eq 'gray') { $rp_status = "<td bgcolor=\"gray\">UNKNOWN</td>"; }
  4391.                                 elsif($rp_status eq 'green') { $rp_status = "<td bgcolor=\"$green\">GREEN</td>";  }
  4392.                             elsif($rp_status eq 'red') { $rp_status = "<td bgcolor=\"$red\">RED</td>"; }
  4393.                             elsif($rp_status eq 'yellow') { $rp_status = "<td bcolor=\"$yellow\">YELLOW</td>"; }
  4394.                                 my $rp_cpu_use = prettyPrintData($rp->summary->runtime->cpu->overallUsage,'MHZ');
  4395.                             my $rp_cpu_max = prettyPrintData($rp->summary->runtime->cpu->maxUsage,'MHZ');
  4396.                             my $rp_cpu_lim = prettyPrintData($rp->summary->config->cpuAllocation->limit,'MHZ');
  4397.                             my $rp_cpu_rsv = prettyPrintData($rp->summary->config->cpuAllocation->reservation,'MHZ');
  4398.                                 my $rp_mem_use = prettyPrintData($rp->summary->runtime->memory->overallUsage,'B');
  4399.                                 my $rp_mem_max = prettyPrintData($rp->summary->runtime->memory->maxUsage,'B');
  4400.                             my $rp_mem_lim = prettyPrintData($rp->summary->config->cpuAllocation->limit,'M');
  4401.                             my $rp_mem_rsv = prettyPrintData($rp->summary->config->cpuAllocation->reservation,'M');
  4402.                 my ($rp_cpu_shares,$rp_mem_shares) = ("N/A","N/A");
  4403.                 if($rp->summary->config->cpuAllocation) {
  4404.                     $rp_cpu_shares = ($rp->summary->config->cpuAllocation->shares->shares ? $rp->summary->config->cpuAllocation->shares->shares : "N/A");
  4405.                 }
  4406.                 if($rp->summary->config->memoryAllocation) {
  4407.                     $rp_mem_shares = ($rp->summary->config->memoryAllocation->shares->shares ? $rp->summary->config->memoryAllocation->shares->shares : "N/A");
  4408.                 }
  4409.  
  4410.                 my $vmInRp = 0;
  4411.                 if($rp->vm) {
  4412.                     my $vmsInRp = Vim::get_views(mo_ref_array => $rp->vm, properties => ['name']);
  4413.                     $vmInRp = scalar(@$vmsInRp);
  4414.                 }
  4415.  
  4416.                 my ($cpuUnitsPerVM,$memUnitsPerVM) = ("N/A","N/A");
  4417.  
  4418.                 if($vmInRp != 0 && $rp_cpu_shares ne "N/A") {
  4419.                     $cpuUnitsPerVM = floor($rp_cpu_shares/$vmInRp);
  4420.                 }
  4421.                 if($vmInRp != 0 && $rp_mem_shares ne "N/A") {
  4422.                     $memUnitsPerVM = floor($rp_mem_shares/$vmInRp);
  4423.                                 }
  4424.                
  4425.                                 $resource_pool_string .= "<tr><td>".$rp_name."</td>";
  4426.                 $resource_pool_string .= $rp_status;
  4427.                 $resource_pool_string .= "<td>".$vmInRp."</td>";
  4428.                 $resource_pool_string .= "<td>".$rp_cpu_shares."</td>";
  4429.                 $resource_pool_string .= "<td>".$cpuUnitsPerVM."</td>";
  4430.                 $resource_pool_string .= "<td>".$rp_mem_shares."</td>";
  4431.                 $resource_pool_string .= "<td>".$memUnitsPerVM."</td>";
  4432.                 $resource_pool_string .= "<td>".$rp_cpu_lim."</td>";
  4433.                 $resource_pool_string .= "<td>".$rp_cpu_rsv."</td>";
  4434.                 $resource_pool_string .= "<td>".$rp_mem_lim."</td>";
  4435.                 $resource_pool_string .= "<td>".$rp_mem_rsv."</td>";
  4436.                 $resource_pool_string .= "<td>".$rp_cpu_use."</td>";
  4437.                 $resource_pool_string .= "<td>".$rp_cpu_max."</td>";
  4438.                 $resource_pool_string .= "<td>".$rp_mem_use."</td>";
  4439.                 $resource_pool_string .= "<td>".$rp_mem_max."</td></tr>\n";
  4440.                         }
  4441.         }
  4442.     }
  4443.  
  4444.     if($CLUSTER_RP eq "yes") {
  4445.         if($resource_pool_string ne "") {
  4446.             $hostTag = "Resource Pool(s)-$cluster_name";
  4447.                     $hostTagShort = "Resource Pool(s)";
  4448.  
  4449.                     push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4450.  
  4451.                     $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4452.             $cluster_start .= "<h3>Resource Pool(s):</h3>\n";
  4453.             $cluster_start .= "<table border=\"1\">\n";
  4454.             $cluster_start .= "<tr><th>POOL NAME</th><th>STATUS</th><th># of VM(s)</th><th>CPU SHARES</th><th>CPU UNITS PER/VM</th><th>MEM SHARES</th><th>MEM UNITS PER/VM</th><th>CPU LIMIT</th><th>CPU RESERVATION</th><th>MEM LIMIT</th><th>MEM RESERVATION</th><th>CPU USAGE</th><th>CPU MAX</th><th>MEM USAGE</th><th>MEM MAX</th></tr>\n";
  4455.  
  4456.             $cluster_start .= $resource_pool_string;
  4457.             $cluster_start .= "</table>\n";
  4458.         }
  4459.     }
  4460.  
  4461.     ###########################
  4462.     # VAPPS
  4463.     ###########################
  4464.     if($CLUSTER_VAPP eq "yes") {
  4465.         if($vapp_string ne "") {
  4466.             $hostTag = "vApp(s)-$cluster_name";
  4467.                         $hostTagShort = "vApp(s)";
  4468.  
  4469.                         push @cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4470.  
  4471.                         $cluster_start .= "<a name=\"$hostTag\"></a>\n";
  4472.             $cluster_start .= "<h3>vApp(s):</h3>\n";
  4473.                     $cluster_start .= "<table border=\"1\">\n";
  4474.  
  4475.             $cluster_start .= $vapp_string;
  4476.             $cluster_start .= "</table>\n";
  4477.         }  
  4478.     }
  4479.    
  4480.     #search datastore for delta files
  4481.     if($VM_DELTA eq "yes") {
  4482.         my $datastores = Vim::get_views(mo_ref_array => $local_cluster->datastore);
  4483.         foreach my $datastore (@$datastores) {
  4484.             if($datastore->summary->accessible) {
  4485.                 my $dsbrowser = Vim::get_view(mo_ref => $datastore->browser);
  4486.                 my $ds_path = "[" . $datastore->info->name . "]";
  4487.                 my $file_query = FileQueryFlags->new(fileOwner => 0, fileSize => 1,fileType => 0,modification => 1);
  4488.                 my $searchSpec = HostDatastoreBrowserSearchSpec->new(details => $file_query,matchPattern => ["*.vmsn", "*-delta.vmdk"]);
  4489.                 my $search_res = $dsbrowser->SearchDatastoreSubFolders(datastorePath => $ds_path,searchSpec => $searchSpec);
  4490.                 if ($search_res) {
  4491.                     foreach my $result (@$search_res) {
  4492.                         my $files = $result->file;
  4493.                         if($files) {
  4494.                             foreach my $file (@$files) {
  4495.                                 if($file->path =~ /-delta.vmdk/ ) {
  4496.                                     my ($vm_snapshot_date,$vm_snapshot_time) = split('T',$file->modification);
  4497.                                     my $todays_date = giveMeDate('YMD');
  4498.                                     chomp($todays_date);
  4499.                                     my $diff = days_between($vm_snapshot_date, $todays_date);
  4500.                                     my $snap_time = $vm_snapshot_date." ".$vm_snapshot_time;
  4501.                                     my $size = &prettyPrintData($file->fileSize,'B');
  4502.  
  4503.                                     my $snap_color_string = "";
  4504.                                     $snap_color_string = "<td>".$result->folderPath."</td><td>".$file->path."</td>";
  4505.                                     if($diff > $SNAPSHOT_YELLOW_WARN) {
  4506.                                         if($diff > $SNAPSHOT_RED_WARN) {
  4507.                                              $snap_color_string .= "<td bgcolor=\"$red\">".$diff." days old</td>";
  4508.                                         }elsif($diff > $SNAPSHOT_ORANGE_WARN) {
  4509.                                              $snap_color_string .= "<td bgcolor=\"$orange\">".$diff." days old</td>";
  4510.                                         }elsif($diff > $SNAPSHOT_YELLOW_WARN) {
  4511.                                              $snap_color_string .= "<td bgcolor=\"$yellow\">".$diff." days old</td>";
  4512.                                         }
  4513.                                         $snap_color_string .= "<td>".$size."</td><td>".$snap_time."</td>";
  4514.                                         push @vmdeltas,$snap_color_string;
  4515.                                     }
  4516.                                 }
  4517.                             }
  4518.                         }
  4519.                     }
  4520.                 }
  4521.             }
  4522.         }
  4523.     }
  4524.  
  4525.         print REPORT_OUTPUT "<br/>".$cluster_start;
  4526. }
  4527.  
  4528. sub printDatacenterSummary {
  4529.         my ($local_datacenter,$dc_count,$atype,$aversion) = @_;
  4530.  
  4531.     my $datacenter_name = $local_datacenter->name;
  4532.  
  4533.     push @datastore_cluster_jump_tags,"CL<a href=\"#$datacenter_name\">Datacenter: $datacenter_name</a><br/>\n";   
  4534.  
  4535.     my $datacenter_start .= "<a name=\"$datacenter_name\"></a>\n";
  4536.     $datacenter_start .= "<h2>Datacenter: $datacenter_name</h2>\n";
  4537.     my ($hostTag,$hostTagShort) = ("","");
  4538.  
  4539.     my ($storagePods,$dvs);
  4540.  
  4541.     if($DATASTORE_CLUSTER_SUMMARY eq "yes" || $DATASTORE_CLUSTER_POD_CONFIG eq "yes" || $DATASTORE_CLUSTER_POD_ADV_CONFIG eq "yes" || $DATASTORE_CLUSTER_POD_STORAGE eq "yes") {
  4542.         $storagePods = Vim::find_entity_views(view_type => 'StoragePod', begin_entity => $local_datacenter);
  4543.     }
  4544.  
  4545.     if($DVS_SUMMARY eq "yes" || $DVS_CAPABILITY eq "yes" || $DVS_CONFIG eq "yes") {
  4546.         $dvs = Vim::find_entity_views(view_type => 'DistributedVirtualSwitch', begin_entity => $local_datacenter);
  4547.     }
  4548.  
  4549.     ###############
  4550.     # POD SUMMARY
  4551.     ###############
  4552.     if($DATASTORE_CLUSTER_SUMMARY eq "yes" && @$storagePods gt 0) {
  4553.         $hostTag = "Datastore Cluster Summary-$datacenter_name";
  4554.         $hostTagShort = "Datastore Cluster Summary";
  4555.         push @datastore_cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4556.         $datacenter_start .= "<a name=\"$hostTag\"></a>\n";
  4557.         $datacenter_start .= "<h3>Datastore Cluster Summary:</h3>\n";
  4558.         $datacenter_start .= "<table border=\"1\">\n";
  4559.         $datacenter_start .= "<tr><th>STORAGE POD NAME</th><th>NUMBER OF DATASTORES</th><th>NUMBER OF VMS</th><th>CAPACITY</th><th>FREE SPACE</th><th>LARGEST DATASTORE FREE SPACE</th></tr>\n";
  4560.  
  4561.         foreach my $pod (@$storagePods) {
  4562.             if(defined($pod->summary)) {
  4563.                 my @podDatastores = ();
  4564.                 my ($podDSCount,$podVMCount) = (0,0);
  4565.                 foreach my $ds ( @{$pod->childEntity} ) {
  4566.                                 my $child_view = Vim::get_view(mo_ref => $ds);
  4567.  
  4568.                                 if($child_view->isa("Datastore")) {
  4569.                                         push @podDatastores, $child_view;
  4570.                         my $vmsperds = Vim::get_views(mo_ref_array => $child_view->vm, properties => ['name']);
  4571.                         $podVMCount += @$vmsperds;
  4572.                         $podDSCount++;
  4573.                                 }
  4574.                         }
  4575.  
  4576.                 # find the largest datastore
  4577.                 my $largestDatastoreSize = 0;
  4578.                 my $largestDatastoreName = "";
  4579.                 foreach(@podDatastores) {
  4580.                     if($_->summary->freeSpace gt $largestDatastoreSize) {
  4581.                         $largestDatastoreSize = $_->summary->freeSpace;
  4582.                         $largestDatastoreName = $_->name;
  4583.                     }
  4584.                 }
  4585.  
  4586.                 $datacenter_start .= "<tr><td>" . $pod->name . "</td><td>" . $podDSCount . "</td><td>" . $podVMCount . "</td><td>" . &prettyPrintData($pod->summary->capacity,'B') . "</td><td>" . &prettyPrintData($pod->summary->freeSpace,'B') . "</td><td>" . &prettyPrintData($largestDatastoreSize,'B') . " (" . $largestDatastoreName . ")</td></tr>\n";
  4587.             }
  4588.         }
  4589.         $datacenter_start .= "</table>\n";
  4590.     }
  4591.  
  4592.     ###############
  4593.     # POD CONFIG
  4594.     ###############
  4595.     if($DATASTORE_CLUSTER_POD_CONFIG eq "yes" && @$storagePods gt 0) {
  4596.         $hostTag = "Datastore Cluster Pod Config-$datacenter_name";
  4597.                 $hostTagShort = "Datastore Cluster Pod Config";
  4598.                 push @datastore_cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4599.                 $datacenter_start .= "<a name=\"$hostTag\"></a>\n";
  4600.                 $datacenter_start .= "<h3>Datastore Cluster Pod Config:</h3>\n";
  4601.                 $datacenter_start .= "<table border=\"1\">\n";
  4602.         $datacenter_start .= "<tr><th>STORAGE POD NAME</th><th>SDRS ENABLED</th><th>IO BALANCE ENABLED</th><th>IO BALANCE LATENCY THRESHOLD</th><th>IO LOAD BALANCE THRESHOLD</th><th>IO BALANCE INTERVAL</th><th>LOAD BALANCE SPACE UTILIZATION DIFFERENCE</th><th>SPACE UTILIZATION THRESHOLD</th><th>ENABLE INTRA-VM AFFINITY</th><th>DEFAULT VM BEHAVIOR</th></tr>\n";
  4603.    
  4604.         foreach my $pod (@$storagePods) {
  4605.             if(defined($pod->podStorageDrsEntry)) {
  4606.                 my ($ioLatThres,$ioLBThres,$ioLBInt,$minSpaceUtiDiff,$spaceUtilDiff,$defIntraVMAff) = ("N/A","N/A","N/A","N/A","N/A","N/A");
  4607.  
  4608.                 my $podConfig = $pod->podStorageDrsEntry->storageDrsConfig->podConfig;
  4609.                 if(defined($podConfig->ioLoadBalanceConfig)) {
  4610.                     if($podConfig->ioLoadBalanceConfig->ioLatencyThreshold) {
  4611.                         $ioLatThres = $podConfig->ioLoadBalanceConfig->ioLatencyThreshold;
  4612.                     }
  4613.                     if($podConfig->ioLoadBalanceConfig->ioLoadImbalanceThreshold) {
  4614.                         $ioLBThres = $podConfig->ioLoadBalanceConfig->ioLoadImbalanceThreshold;
  4615.                     }
  4616.                 }
  4617.                 if($podConfig->loadBalanceInterval) {
  4618.                     my $ioLBIntInMin = $podConfig->loadBalanceInterval;
  4619.                     $ioLBInt = ($ioLBIntInMin / 60);
  4620.                 }
  4621.                 if(defined($podConfig->spaceLoadBalanceConfig)) {
  4622.                     if($podConfig->spaceLoadBalanceConfig->minSpaceUtilizationDifference) {
  4623.                         $minSpaceUtiDiff = $podConfig->spaceLoadBalanceConfig->minSpaceUtilizationDifference;
  4624.                     }
  4625.                     if($podConfig->spaceLoadBalanceConfig->spaceUtilizationThreshold) {
  4626.                         $spaceUtilDiff = $podConfig->spaceLoadBalanceConfig->spaceUtilizationThreshold;
  4627.                     }
  4628.                 }
  4629.                 if($podConfig->defaultIntraVmAffinity) {
  4630.                     $defIntraVMAff = (($podConfig->defaultIntraVmAffinity) ? "YES" : "NO");
  4631.                 }
  4632.            
  4633.  
  4634.                 $datacenter_start .= "<tr><td>".$pod->name."</td><td>".(($podConfig->enabled) ? "YES" : "NO")."</td><td>".(($podConfig->ioLoadBalanceEnabled) ? "YES" : "NO")."</td><td>".$ioLatThres."ms</td><td>".$ioLBThres."</td><td>".$ioLBInt."hr</td><td>".$minSpaceUtiDiff."%</td><td>".$spaceUtilDiff."%</td><td>".$defIntraVMAff."</td><td>".$podConfig->defaultVmBehavior."</td></tr>";
  4635.             }
  4636.         }
  4637.         $datacenter_start .= "</table>\n";
  4638.     }
  4639.  
  4640.     ##################
  4641.     # POD ADV OPTIONS
  4642.     ##################
  4643.     if($DATASTORE_CLUSTER_POD_ADV_CONFIG eq "yes" && @$storagePods gt 0) {
  4644.                 $hostTag = "Datastore Cluster Pod Advanced Configurations-$datacenter_name";
  4645.                 $hostTagShort = "Datastore Cluster Pod Advanced Configurations";
  4646.                 push @datastore_cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4647.                 $datacenter_start .= "<a name=\"$hostTag\"></a>\n";
  4648.                 $datacenter_start .= "<h3>Datastore Cluster Pod Advanced Configurations:</h3>\n";
  4649.                 $datacenter_start .= "<table border=\"1\">\n";
  4650.                 $datacenter_start .= "<tr><th>STORAGE POD NAME</th><th>ADVANCED CONFIGURATIONS</th>\n";
  4651.  
  4652.         foreach my $pod (@$storagePods) {
  4653.                         if(defined($pod->podStorageDrsEntry)) {
  4654.                 my $podConfig = $pod->podStorageDrsEntry->storageDrsConfig->podConfig;
  4655.                 if($podConfig->option) {
  4656.                     my $podrules_string = "";
  4657.                     my $podRules = $podConfig->option;
  4658.                     foreach(@$podRules) {
  4659.                         my $podkey = defined($_->key) ? $_->key : "N/A";
  4660.                         my $podval = defined($_->value) ? $_->value : "N/A";
  4661.                         $podrules_string .=  $podkey . " = " . $podval . "<br>";
  4662.                     }
  4663.                     $datacenter_start .= "<tr><td>" . $pod->name . "</td><td>" . $podrules_string . "</td></tr>\n";
  4664.                 }
  4665.             }
  4666.         }
  4667.         $datacenter_start .= "</table>\n";
  4668.     }
  4669.  
  4670.     ##################
  4671.         # POD STORAGE
  4672.         ##################
  4673.     if($DATASTORE_CLUSTER_POD_STORAGE eq "yes" && @$storagePods gt 0) {
  4674.         $hostTag = "Datastore Cluster Pod Storage-$datacenter_name";
  4675.                 $hostTagShort = "Datastore Cluster Pod Storage";
  4676.                 push @datastore_cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4677.                 $datacenter_start .= "<a name=\"$hostTag\"></a>\n";
  4678.                 $datacenter_start .= "<h3>Datastore Cluster Pod Storage:</h3>\n";
  4679.                 $datacenter_start .= "<table border=\"1\">\n";
  4680.                 $datacenter_start .= "<tr><th>STORAGE POD NAME</th><th>DATASTORES</th><th>MAINTENANCE MODE</th>\n";
  4681.  
  4682.         foreach my $pod (@$storagePods) {
  4683.                         if(defined($pod->summary)) {
  4684.                 my @podDatastores = ();
  4685.                                 my $podDSCount = 0;
  4686.                                 foreach my $ds ( @{$pod->childEntity} ) {
  4687.                                         my $child_view = Vim::get_view(mo_ref => $ds, properties => ['name','summary.maintenanceMode']);
  4688.  
  4689.                                         if($child_view->isa("Datastore")) {
  4690.                                                 push @podDatastores, $child_view;
  4691.                                         }
  4692.                                 }
  4693.  
  4694.                 my ($podDSString,$podDSMMString) = ("","");
  4695.                                 foreach(@podDatastores) {
  4696.                     $podDSString .= $_->{'name'} . "<br>";
  4697.                     $podDSMMString .= $_->{'summary.maintenanceMode'} . "<br>";
  4698.                                 }
  4699.                                 $datacenter_start .= "<tr><td>" . $pod->name . "</td><td>" . $podDSString . "</td><td>" . $podDSMMString . "</td></tr>\n";
  4700.             }
  4701.         }
  4702.         $datacenter_start .= "</table>\n";
  4703.     }
  4704.  
  4705.     ##############
  4706.     # DVS SUMMARY
  4707.     ##############
  4708.     if($DVS_SUMMARY eq "yes" && @$dvs gt 0) {
  4709.         $hostTag = "DVS Summary-$datacenter_name";
  4710.                 $hostTagShort = "DVS Summary";
  4711.                 push @datastore_cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4712.                 $datacenter_start .= "<a name=\"$hostTag\"></a>\n";
  4713.                 $datacenter_start .= "<h3>DVS Summary:</h3>\n";
  4714.                 $datacenter_start .= "<table border=\"1\">\n";
  4715.                 $datacenter_start .= "<tr><th>DVS NAME</th><th># OF PORTS</th><th>VENDOR</th><th>VERSION</th><th>BUILD</th><th>UUID</th></tr>\n";
  4716.  
  4717.         foreach my $dvSwitch (@$dvs) {
  4718.             $datacenter_start .= "<tr>";
  4719.             $datacenter_start .= "<td>".$dvSwitch->summary->name."</td>";
  4720.             $datacenter_start .= "<td>".$dvSwitch->summary->numPorts."</td>";
  4721.             $datacenter_start .= "<td>".($dvSwitch->summary->productInfo->vendor ? $dvSwitch->summary->productInfo->vendor : "N/A")."</td>";
  4722.             $datacenter_start .= "<td>".($dvSwitch->summary->productInfo->version ? $dvSwitch->summary->productInfo->version : "N/A")."</td>";
  4723.             $datacenter_start .= "<td>".($dvSwitch->summary->productInfo->build ? $dvSwitch->summary->productInfo->build : "N/A")."</td>";
  4724.             $datacenter_start .= "<td>".$dvSwitch->summary->uuid."</td>";
  4725.             $datacenter_start .= "</tr>\n";
  4726.         }
  4727.         $datacenter_start .= "</table>\n";
  4728.     }
  4729.     #################
  4730.     # DVS CAPABILITY
  4731.     #################
  4732.     if($DVS_CAPABILITY && @$dvs gt 0) {
  4733.         $hostTag = "DVS Capability-$datacenter_name";
  4734.                 $hostTagShort = "DVS Capability";
  4735.                 push @datastore_cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4736.                 $datacenter_start .= "<a name=\"$hostTag\"></a>\n";
  4737.                 $datacenter_start .= "<h3>DVS Capability:</h3>\n";
  4738.                 $datacenter_start .= "<table border=\"1\">\n";
  4739.                 $datacenter_start .= "<tr><th>DVS NAME</th><th>NIOC SUPPORT</th><th>QOS SUPPORT</th><th>DIRECT PATH GEN2 SUPPORT</th><th>DEFINE NETWORK RSC POOLS SUPPORT</th><th>NETWORK RSC POOL HIGH SHARE VAL</th><th>NIC TEAMING POLICY</th></tr>";
  4740.  
  4741.         my ($niocSup,$qosSup,$defNetRscPoolSup,$netRscPoolShareVal,$dp2Sup,$nicTeam) = ("N/A","N/A","N/A","N/A","N/A","N/A",);
  4742.  
  4743.         foreach my $dvSwitch (@$dvs) {
  4744.             if($dvSwitch->capability->featuresSupported) {
  4745.                 my $dvFeatures = $dvSwitch->capability->featuresSupported;
  4746.                 $niocSup = $dvFeatures->networkResourceManagementCapability->networkResourceManagementSupported ? "YES" : "NO";
  4747.                 $qosSup = $dvFeatures->networkResourceManagementCapability->qosSupported ? "YES" : "NO";
  4748.                 $defNetRscPoolSup = $dvFeatures->networkResourceManagementCapability->userDefinedNetworkResourcePoolsSupported ? "YES" : "NO";
  4749.                 $netRscPoolShareVal = $dvFeatures->networkResourceManagementCapability->networkResourcePoolHighShareValue ? $dvFeatures->networkResourceManagementCapability->networkResourcePoolHighShareValue : "N/A";
  4750.                 $dp2Sup = $dvFeatures->vmDirectPathGen2Supported ? "YES" : "NO";
  4751.                 $nicTeam = $dvFeatures->nicTeamingPolicy ? join('<br>',@{$dvFeatures->nicTeamingPolicy}) : "N/A";
  4752.             }
  4753.             $datacenter_start .= "<tr>";
  4754.             $datacenter_start .= "<td>".$dvSwitch->summary->name."</td>";
  4755.             $datacenter_start .= "<td>".$niocSup."</td>";
  4756.             $datacenter_start .= "<td>".$qosSup."</td>";
  4757.             $datacenter_start .= "<td>".$dp2Sup."</td>";
  4758.             $datacenter_start .= "<td>".$defNetRscPoolSup."</td>";
  4759.             $datacenter_start .= "<td>".$netRscPoolShareVal."</td>";
  4760.             $datacenter_start .= "<td>".$nicTeam."</td>";
  4761.             $datacenter_start .= "</tr>\n";
  4762.         }
  4763.         $datacenter_start .= "</table>\n";
  4764.     }
  4765.     ##############
  4766.         # DVS CONFIG
  4767.         ##############
  4768.         if($DVS_CONFIG eq "yes" && @$dvs gt 0) {
  4769.                 $hostTag = "DVS Config-$datacenter_name";
  4770.                 $hostTagShort = "DVS Config";
  4771.                 push @datastore_cluster_jump_tags,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#$hostTag\">$hostTagShort</a><br/>\n";
  4772.                 $datacenter_start .= "<a name=\"$hostTag\"></a>\n";
  4773.                 $datacenter_start .= "<h3>DVS Config:</h3>\n";
  4774.                 $datacenter_start .= "<table border=\"1\">\n";
  4775.                 $datacenter_start .= "<tr><th>DVS NAME</th><th>SWITCH ADDRESS</th><th>MAX PORTS</th><th>STANDALONE PORTS</th><th>MTU</th><th>NIOC ENABLED</th><th>LDP OPERATION</th><th>LDP PROTOCOL</th><th>ACTIVE FLOW TIMEOUT</th><th>IDLE FLOW TIMEOUT</th><th>INTERNAL FLOW ONLY</th><th>SAMPLE RATE</th><th>EXT KEY</th><th>CONFIG VERSION</th><th>DESCRIPTION</th><th>CREATE TIME</th></tr>\n";
  4776.  
  4777.                 foreach my $dvSwitch (@$dvs) {
  4778.             my ($mtu,$ldpOp,$ldpPro,$activeFlowTimeout,$idleFlowTimeout,$intFlowOnly,$sampleRate) = ("N/A","N/A","N/A","N/A","N/A","N/A");
  4779.             if($dvSwitch->config->isa('VMwareDVSConfigInfo')) {
  4780.                                 $mtu = $dvSwitch->config->maxMtu;
  4781.                 $ldpOp = $dvSwitch->config->linkDiscoveryProtocolConfig->operation ? $dvSwitch->config->linkDiscoveryProtocolConfig->operation : "N/A";
  4782.                 $ldpPro = $dvSwitch->config->linkDiscoveryProtocolConfig->protocol ? $dvSwitch->config->linkDiscoveryProtocolConfig->protocol : "N/A";
  4783.                 $activeFlowTimeout = $dvSwitch->config->ipfixConfig->activeFlowTimeout ? $dvSwitch->config->ipfixConfig->activeFlowTimeout : "N/A";
  4784.                 $idleFlowTimeout = $dvSwitch->config->ipfixConfig->idleFlowTimeout ? $dvSwitch->config->ipfixConfig->idleFlowTimeout : "N/A";
  4785.                 $intFlowOnly = $dvSwitch->config->ipfixConfig->internalFlowsOnly ? "YES" : "NO";
  4786.                 $sampleRate = $dvSwitch->config->ipfixConfig->samplingRate ? $dvSwitch->config->ipfixConfig->samplingRate : "N/A";
  4787.                
  4788.                         }
  4789.  
  4790.                         $datacenter_start .= "<tr>";
  4791.                         $datacenter_start .= "<td>".$dvSwitch->summary->name."</td>";
  4792.             $datacenter_start .= "<td>".($dvSwitch->config->switchIpAddress ? $dvSwitch->config->switchIpAddress : "N/A")."</td>";
  4793.             $datacenter_start .= "<td>".$dvSwitch->config->maxPorts."</td>";
  4794.             $datacenter_start .= "<td>".$dvSwitch->config->numStandalonePorts."</td>";
  4795.             $datacenter_start .= "<td>".$mtu."</td>";
  4796.             $datacenter_start .= "<td>".($dvSwitch->config->networkResourceManagementEnabled ? "YES" : "NO")."</td>";
  4797.             $datacenter_start .= "<td>".$ldpOp."</td>";
  4798.             $datacenter_start .= "<td>".$ldpPro."</td>";
  4799.             $datacenter_start .= "<td>".$activeFlowTimeout." sec</td>";
  4800.             $datacenter_start .= "<td>".$idleFlowTimeout." sec</td>";
  4801.             $datacenter_start .= "<td>".$intFlowOnly."</td>";
  4802.             $datacenter_start .= "<td>".$sampleRate."</td>";
  4803.             $datacenter_start .= "<td>".($dvSwitch->config->extensionKey ? $dvSwitch->config->extensionKey : "N/A")."</td>";
  4804.             $datacenter_start .= "<td>".$dvSwitch->config->configVersion."</td>";
  4805.             $datacenter_start .= "<td>".($dvSwitch->config->description ? $dvSwitch->config->description : "N/A")."</td>";
  4806.             $datacenter_start .= "<td>".$dvSwitch->config->createTime."</td>";
  4807.                         $datacenter_start .= "</tr>\n";
  4808.                 }
  4809.                 $datacenter_start .= "</table>\n";
  4810.         }
  4811.  
  4812.     print REPORT_OUTPUT "<br/>".$datacenter_start;
  4813. }
  4814.  
  4815. sub processOptions {
  4816.     my ($type,$hostType,$conf) = @_;
  4817.  
  4818.     if(defined($conf)) {
  4819.         &processConf($conf);
  4820.         &setConf();
  4821.     }
  4822.  
  4823.     if($type eq 'host' && $hostType eq 'HostAgent') {
  4824.         $host_view = Vim::find_entity_views(view_type => 'HostSystem');
  4825.         unless($host_view) {
  4826.             Util::disconnect();
  4827.             die "ESX/ESXi host was not found\n";
  4828.         }
  4829.     }elsif($type eq 'cluster' && $hostType eq 'VirtualCenter') {
  4830.         $cluster_view = Vim::find_entity_view(view_type => 'ClusterComputeResource',filter => { name => $clusterInput });
  4831.         unless($cluster_view) {
  4832.             Util::disconnect();
  4833.                         die "Error: Unable to find Cluster: \"$clusterInput\"!\n";
  4834.             exit 1;
  4835.         }
  4836.     }elsif($type eq 'datacenter' && $hostType eq 'VirtualCenter') {
  4837.         $datacenter_view = Vim::find_entity_view(view_type => 'Datacenter',filter => { name => $datacenterInput});
  4838.         unless($datacenter_view) {
  4839.             Util::disconnect();
  4840.                         die "Error: Unable to find Datacenter: \"$datacenterInput\"!\n";
  4841.             exit 1;
  4842.         }
  4843.         my $CCR = Vim::find_entity_views(view_type => 'ClusterComputeResource', begin_entity => $datacenter_view);
  4844.                 my $CR = Vim::find_entity_views(view_type => 'ComputeResource', begin_entity => $datacenter_view);
  4845.                 my @list = (@$CCR,@$CR);
  4846.                 my %seen = ();
  4847.                 my @unique = grep { ! $seen{$_->name} ++ } @list;
  4848.                 $cluster_views = \@unique;
  4849.     }elsif($type eq 'vcenter' && $hostType eq 'VirtualCenter') {
  4850.         my $CCR = Vim::find_entity_views(view_type => 'ClusterComputeResource');
  4851.                 my $CR = Vim::find_entity_views(view_type => 'ComputeResource');
  4852.                 my @list = (@$CCR,@$CR);
  4853.                 my %seen = ();
  4854.                 my @unique = grep { ! $seen{$_->name} ++ } @list;
  4855.                 $cluster_views = \@unique;
  4856.     }
  4857. }
  4858.  
  4859. sub processConf {
  4860.     my ($conf) = @_;
  4861.    
  4862.     my @goodparams = qw(
  4863. EMAIL_HOST
  4864. EMAIL_DOMAIN
  4865. EMAIL_TO
  4866. EMAIL_FROM
  4867. YELLOW_WARN
  4868. ORANGE_WARN
  4869. RED_WARN
  4870. SNAPSHOT_YELLOW_WARN
  4871. SNAPSHOT_ORANGE_WARN
  4872. SNAPSHOT_RED_WARN
  4873. SYSTEM_LICENSE
  4874. SYSTEM_FEATURE
  4875. SYSTEM_PERMISSION
  4876. SYSTEM_SESSION
  4877. SYSTEM_HOST_PROFILE
  4878. SYSTEM_PLUGIN
  4879. DVS_SUMMARY
  4880. DVS_CAPABILITY
  4881. DVS_CONFIG
  4882. DATASTORE_CLUSTER_SUMMARY
  4883. DATASTORE_CLUSTER_POD_CONFIG
  4884. CLUSTER_SUMMARY
  4885. CLUSTER_PERFORMANCE
  4886. CLUSTER_HA
  4887. CLUSTER_DRS
  4888. CLUSTER_DPM
  4889. CLUSTER_AFFINITY
  4890. CLUSTER_GROUP
  4891. CLUSTER_RP
  4892. CLUSTER_VAPP
  4893. HOST_HARDWARE_CONFIGURATION
  4894. HOST_MGMT
  4895. HOST_STATE
  4896. HOST_HEALTH
  4897. HOST_PERFORMANCE
  4898. HOST_NIC
  4899. HOST_HBA
  4900. HOST_CAPABILITY
  4901. HOST_CONFIGURATION
  4902. HOST_VMOTION
  4903. HOST_GATEWAY
  4904. HOST_ISCSI
  4905. HOST_IPV6
  4906. HOST_FT
  4907. HOST_SSL
  4908. HOST_DNS
  4909. HOST_UPTIME
  4910. HOST_DIAGONISTIC
  4911. HOST_AUTH_SERVICE
  4912. HOST_SERVICE
  4913. HOST_NTP
  4914. HOST_VSWIF
  4915. HOST_VMKERNEL
  4916. HOST_VSWITCH
  4917. HOST_SNMP
  4918. HOST_FIREWALL
  4919. HOST_POWER
  4920. HOST_FEATURE_VERSION
  4921. HOST_ADVOPT
  4922. HOST_AGENT
  4923. HOST_NUMA
  4924. HOST_CDP
  4925. HOST_LUN
  4926. HOST_DATASTORE
  4927. HOST_CACHE
  4928. HOST_MULTIPATH
  4929. HOST_PORTGROUP
  4930. HOST_DVS
  4931. HOST_LOG
  4932. HOST_TASK
  4933. VM_STATE
  4934. VM_CONFIG
  4935. VM_STATS
  4936. VM_RESOURCE_ALLOCATION
  4937. VM_PERFORMANCE
  4938. VM_FT
  4939. VM_EZT
  4940. VM_THIN
  4941. VM_DEVICE
  4942. VM_STORAGE
  4943. VM_NETWORK
  4944. VM_SNAPSHOT
  4945. VM_DELTA
  4946. VM_CDROM
  4947. VM_FLOPPY
  4948. VM_RDM
  4949. VM_NPIV
  4950. VM_TOOL
  4951. VPX_SETTING
  4952. VMW_APP
  4953. );
  4954.  
  4955.     open(CONFIG, "$conf") || die "Error: Couldn't open the $conf!";
  4956.         while (<CONFIG>) {
  4957.             chomp;
  4958.                 s/#.*//; # Remove comments
  4959.             s/^\s+//; # Remove opening whitespace
  4960.                 s/\s+$//;  # Remove closing whitespace
  4961.                 next unless length;
  4962.                 my ($key, $value) = split(/\s*=\s*/, $_, 2);
  4963.                 if( grep $key eq $_,  @goodparams ) {
  4964.                     $value =~ s/"//g;
  4965.             if($key eq "EMAIL_TO") {
  4966.                 @EMAIL_TO = ();
  4967.                 @EMAIL_TO = split(',',$value);
  4968.             } else {
  4969.                             $configurations{$key} = $value;
  4970.             }
  4971.                 }
  4972.         }
  4973.     close(CONFIG);
  4974. }
  4975.  
  4976. sub processAdditionalConf {
  4977.     if($hostlist) {
  4978.         &processSubFiles($hostlist);
  4979.     }
  4980.     if($vmlist) {
  4981.         &processSubFiles($vmlist);
  4982.     }
  4983. }
  4984.  
  4985. sub processSubFiles {
  4986.     my ($config_input) = @_;
  4987.  
  4988.     open(CONFIG, "$config_input") || die "Error: Couldn't open the $config_input!";
  4989.         while (<CONFIG>) {
  4990.                 chomp;
  4991.                 s/#.*//; # Remove comments
  4992.                 s/^\s+//; # Remove opening whitespace
  4993.                 s/\s+$//;  # Remove closing whitespace
  4994.                 next unless length;
  4995.         if($hostlist) {
  4996.             $hostlists{$_} = "yes";
  4997.         }
  4998.         if($vmlist) {
  4999.             $vmlists{$_} = "yes";
  5000.         }
  5001.         }
  5002.         close(CONFIG);
  5003. }
  5004.  
  5005. sub setConf {
  5006.     $EMAIL_HOST=(($configurations{'EMAIL_HOST'}) ? $configurations{'EMAIL_HOST'} : 'emailserver');
  5007.     $EMAIL_DOMAIN=(($configurations{'EMAIL_DOMAIN'}) ? $configurations{'EMAIL_DOMAIN'} : 'localhost.localdomain');
  5008.     #@EMAIL_TO=(($configurations{'EMAIL_TO'}) ? $configurations{'EMAIL_TO'} : 'william@primp-industries.com.com');
  5009.     $EMAIL_FROM=(($configurations{'EMAIL_FROM'}) ? $configurations{'EMAIL_FROM'} : 'vMA@primp-industries.com.com');
  5010.     $YELLOW_WARN=(($configurations{'YELLOW_WARN'}) ? $configurations{'YELLOW_WARN'} : 30);
  5011.     $ORANGE_WARN=(($configurations{'ORANGE_WARN'}) ? $configurations{'ORANGE_WARN'} : 15);
  5012.     $RED_WARN=(($configurations{'RED_WARN'}) ? $configurations{'RED_WARN'} : 10);
  5013.     $SNAPSHOT_YELLOW_WARN=(($configurations{'SNAPSHOT_YELLOW_WARN'}) ? $configurations{'SNAPSHOT_YELLOW_WARN'} : 15);
  5014.     $SNAPSHOT_ORANGE_WARN=(($configurations{'SNAPSHOT_ORANGE_WARN'}) ? $configurations{'SNAPSHOT_ORANGE_WARN'} : 30);
  5015.     $SNAPSHOT_RED_WARN=(($configurations{'SNAPSHOT_RED_WARN'}) ? $configurations{'SNAPSHOT_RED_WARN'} : 60);
  5016.     $SYSTEM_LICENSE=(($configurations{'SYSTEM_LICENSE'}) ? $configurations{'SYSTEM_LICENSE'} : "yes");
  5017.     $SYSTEM_FEATURE=(($configurations{'SYSTEM_FEATURE'}) ? $configurations{'SYSTEM_FEATURE'} : "yes");
  5018.     $SYSTEM_PERMISSION=(($configurations{'SYSTEM_PERMISSION'}) ? $configurations{'SYSTEM_PERMISSION'} : "yes");
  5019.     $SYSTEM_SESSION=(($configurations{'SYSTEM_SESSION'}) ? $configurations{'SYSTEM_SESSION'} : "yes");
  5020.     $SYSTEM_HOST_PROFILE=(($configurations{'SYSTEM_HOST_PROFILE'}) ? $configurations{'SYSTEM_HOST_PROFILE'} : "yes");
  5021.     $SYSTEM_PLUGIN=(($configurations{'SYSTEM_PLUGIN'}) ? $configurations{'SYSTEM_PLUGIN'} : "yes");
  5022.     $DVS_SUMMARY=(($configurations{'DVS_SUMMARY'}) ? $configurations{'DVS_SUMMARY'} : "yes");
  5023.     $DVS_CAPABILITY=(($configurations{'DVS_CAPABILITY'}) ? $configurations{'DVS_CAPABILITY'} : "yes");
  5024.     $DVS_CONFIG=(($configurations{'DVS_CONFIG'}) ? $configurations{'DVS_CONFIG'} : "yes");
  5025.     $DATASTORE_CLUSTER_SUMMARY=(($configurations{'DATASTORE_CLUSTER_SUMMARY'}) ? $configurations{'DATASTORE_CLUSTER_SUMMARY'} : "yes");
  5026.     $DATASTORE_CLUSTER_POD_CONFIG=(($configurations{'DATASTORE_CLUSTER_POD_CONFIG'}) ? $configurations{'DATASTORE_CLUSTER_POD_CONFIG'} : "yes");
  5027.     $DATASTORE_CLUSTER_POD_ADV_CONFIG=(($configurations{'DATASTORE_CLUSTER_POD_ADV_CONFIG'}) ? $configurations{'DATASTORE_CLUSTER_POD_ADV_CONFIG'} : "yes");
  5028.     $DATASTORE_CLUSTER_POD_STORAGE=(($configurations{'DATASTORE_CLUSTER_POD_STORAGE'}) ? $configurations{'DATASTORE_CLUSTER_POD_STORAGE'} : "yes");
  5029.     $CLUSTER_SUMMARY=(($configurations{'CLUSTER_SUMMARY'}) ? $configurations{'CLUSTER_SUMMARY'} : "yes");
  5030.     $CLUSTER_PERFORMANCE=(($configurations{'CLUSTER_PERFORMANCE'}) ? $configurations{'CLUSTER_PERFORMANCE'} : "yes");
  5031.     $CLUSTER_HA=(($configurations{'CLUSTER_HA'}) ? $configurations{'CLUSTER_HA'} : "yes");
  5032.     $CLUSTER_DRS=(($configurations{'CLUSTER_DRS'}) ? $configurations{'CLUSTER_DRS'} : "yes");
  5033.     $CLUSTER_DPM=(($configurations{'CLUSTER_DPM'}) ? $configurations{'CLUSTER_DPM'} : "yes");
  5034.     $CLUSTER_AFFINITY=(($configurations{'CLUSTER_AFFINITY'}) ? $configurations{'CLUSTER_AFFINITY'} : "yes");
  5035.     $CLUSTER_GROUP=(($configurations{'CLUSTER_GROUP'}) ? $configurations{'CLUSTER_GROUP'} : "yes");
  5036.     $CLUSTER_RP=(($configurations{'CLUSTER_RP'}) ? $configurations{'CLUSTER_RP'} : "yes");
  5037.     $CLUSTER_VAPP=(($configurations{'CLUSTER_VAPP'}) ? $configurations{'CLUSTER_VAPP'} : "yes");
  5038.     $HOST_HARDWARE_CONFIGURATION=(($configurations{'HOST_HARDWARE_CONFIGURATION'}) ? $configurations{'HOST_HARDWARE_CONFIGURATION'} : "yes");
  5039.     $HOST_MGMT=(($configurations{'HOST_MGMT'}) ? $configurations{'HOST_MGMT'} : "yes");
  5040.     $HOST_STATE=(($configurations{'HOST_STATE'}) ? $configurations{'HOST_STATE'} : "yes");
  5041.     $HOST_HEALTH=(($configurations{'HOST_HEALTH'}) ? $configurations{'HOST_HEALTH'} : "yes");
  5042.     $HOST_PERFORMANCE=(($configurations{'HOST_PERFORMANCE'}) ? $configurations{'HOST_PERFORMANCE'} : "yes");
  5043.     $HOST_NIC=(($configurations{'HOST_NIC'}) ? $configurations{'HOST_NIC'} : "yes");
  5044.     $HOST_HBA=(($configurations{'HOST_HBA'} ? $configurations{'HOST_HBA'} : "yes"));
  5045.     $HOST_CAPABILITY=(($configurations{'HOST_CAPABILITY'} ? $configurations{'HOST_CAPABILITY'} : "yes"));
  5046.     $HOST_CONFIGURATION=(($configurations{'HOST_CONFIGURATION'}) ? $configurations{'HOST_CONFIGURATION'} : "yes");
  5047.     $HOST_VMOTION=(($configurations{'HOST_VMOTION'}) ? $configurations{'HOST_VMOTION'} : "yes");
  5048.     $HOST_GATEWAY=(($configurations{'HOST_GATEWAY'}) ? $configurations{'HOST_GATEWAY'} : "yes");
  5049.     $HOST_ISCSI=(($configurations{'HOST_ISCSI'}) ? $configurations{'HOST_ISCSI'} : "yes");
  5050.     $HOST_IPV6=(($configurations{'HOST_IPV6'}) ? $configurations{'HOST_IPV6'} : "yes");
  5051.     $HOST_FT=(($configurations{'HOST_FT'}) ? $configurations{'HOST_FT'} : "yes");
  5052.     $HOST_SSL=(($configurations{'HOST_SSL'}) ? $configurations{'HOST_SSL'} : "yes");
  5053.     $HOST_DNS=(($configurations{'HOST_DNS'}) ? $configurations{'HOST_DNS'} : "yes");
  5054.     $HOST_UPTIME=(($configurations{'HOST_UPTIME'}) ? $configurations{'HOST_UPTIME'} : "yes");
  5055.     $HOST_DIAGONISTIC=(($configurations{'HOST_DIAGONISTIC'}) ? $configurations{'HOST_DIAGONISTIC'} : "yes");
  5056.     $HOST_AUTH_SERVICE=(($configurations{'HOST_AUTH_SERVICE'}) ? $configurations{'HOST_AUTH_SERVICE'} : "yes");
  5057.     $HOST_SERVICE=(($configurations{'HOST_SERVICE'}) ? $configurations{'HOST_SERVICE'} : "yes");
  5058.     $HOST_NTP=(($configurations{'HOST_NTP'}) ? $configurations{'HOST_NTP'} : "yes");
  5059.     $HOST_VSWIF=(($configurations{'HOST_VSWIF'}) ? $configurations{'HOST_VSWIF'} : "yes");
  5060.     $HOST_VMKERNEL=(($configurations{'HOST_VMKERNEL'}) ? $configurations{'HOST_VMKERNEL'} : "yes");
  5061.     $HOST_VSWITCH=(($configurations{'HOST_VSWITCH'}) ? $configurations{'HOST_VSWITCH'} : "yes");
  5062.     $HOST_SNMP=(($configurations{'HOST_SNMP'}) ? $configurations{'HOST_SNMP'} : "yes");
  5063.     $HOST_FIREWALL=(($configurations{'HOST_FIREWALL'}) ? $configurations{'HOST_FIREWALL'} : "yes");
  5064.     $HOST_POWER=(($configurations{'HOST_POWER'}) ? $configurations{'HOST_POWER'} : "yes");
  5065.     $HOST_FEATURE_VERSION=(($configurations{'HOST_FEATURE_VERSION'}) ? $configurations{'HOST_FEATURE_VERSION'} : "yes");
  5066.     $HOST_ADVOPT=(($configurations{'HOST_ADVOPT'}) ? $configurations{'HOST_ADVOPT'} : "yes");
  5067.     $HOST_AGENT=(($configurations{'HOST_AGENT'}) ? $configurations{'HOST_AGENT'} : "yes");
  5068.     $HOST_NUMA=(($configurations{'HOST_NUMA'}) ? $configurations{'HOST_NUMA'} : "yes");
  5069.     $HOST_CDP=(($configurations{'HOST_CDP'}) ? $configurations{'HOST_CDP'} : "yes");
  5070.     $HOST_LUN=(($configurations{'HOST_LUN'}) ? $configurations{'HOST_LUN'} : "yes");
  5071.     $HOST_DATASTORE=(($configurations{'HOST_DATASTORE'}) ? $configurations{'HOST_DATASTORE'} : "yes");
  5072.     $HOST_CACHE=(($configurations{'HOST_CACHE'}) ? $configurations{'HOST_CACHE'} : "yes");
  5073.     $HOST_MULTIPATH=(($configurations{'HOST_MULTIPATH'}) ? $configurations{'HOST_MULTIPATH'} : "yes");
  5074.     $HOST_PORTGROUP=(($configurations{'HOST_PORTGROUP'}) ? $configurations{'HOST_PORTGROUP'} : "yes");
  5075.     $HOST_DVS=(($configurations{'HOST_DVS'}) ? $configurations{'HOST_DVS'} : "yes");
  5076.     $HOST_LOG=(($configurations{'HOST_LOG'}) ? $configurations{'HOST_LOG'} : "yes");
  5077.     $HOST_TASK=(($configurations{'HOST_TASK'}) ? $configurations{'HOST_TASK'} : "yes");
  5078.     $VM_STATE=(($configurations{'VM_STATE'}) ? $configurations{'VM_STATE'} : "yes");
  5079.     $VM_CONFIG=(($configurations{'VM_CONFIG'}) ? $configurations{'VM_CONFIG'} : "yes");
  5080.     $VM_STATS=(($configurations{'VM_STATS'}) ? $configurations{'VM_STATS'} : "yes");
  5081.     $VM_RESOURCE_ALLOCATION=(($configurations{'VM_RESOURCE_ALLOCATION'}) ? $configurations{'VM_RESOURCE_ALLOCATION'} : "yes");
  5082.     $VM_PERFORMANCE=(($configurations{'VM_PERFORMANCE'}) ? $configurations{'VM_PERFORMANCE'} : "yes");
  5083.     $VM_FT=(($configurations{'VM_FT'}) ? $configurations{'VM_FT'} : "yes");
  5084.     $VM_EZT=(($configurations{'VM_EZT'}) ? $configurations{'VM_EZT'} : "yes");
  5085.     $VM_THIN=(($configurations{'VM_THIN'}) ? $configurations{'VM_THIN'} : "yes");
  5086.     $VM_DEVICE=(($configurations{'VM_DEVICE'}) ? $configurations{'VM_DEVICE'} : "yes");
  5087.     $VM_STORAGE=(($configurations{'VM_STORAGE'}) ? $configurations{'VM_STORAGE'} : "yes");
  5088.     $VM_NETWORK=(($configurations{'VM_NETWORK'}) ? $configurations{'VM_NETWORK'} : "yes");
  5089.     $VM_SNAPSHOT=(($configurations{'VM_SNAPSHOT'}) ? $configurations{'VM_SNAPSHOT'} : "yes");
  5090.     $VM_DELTA=(($configurations{'VM_DELTA'}) ? $configurations{'VM_DELTA'} : "yes");
  5091.     $VM_CDROM=(($configurations{'VM_CDROM'}) ? $configurations{'VM_CDROM'} : "yes");
  5092.     $VM_FLOPPY=(($configurations{'VM_FLOPPY'}) ? $configurations{'VM_FLOPPY'} : "yes");
  5093.     $VM_RDM=(($configurations{'VM_RDM'}) ? $configurations{'VM_RDM'} : "yes");
  5094.     $VM_NPIV=(($configurations{'VM_NPIV'}) ? $configurations{'VM_NPIV'} : "yes");
  5095.     $VM_TOOL=(($configurations{'VM_TOOL'}) ? $configurations{'VM_TOOL'} : "yes");
  5096.     $VMW_APP=(($configurations{'VMW_APP'}) ? $configurations{'VMW_APP'} : "yes");
  5097.         $VPX_SETTING=(($configurations{'VPX_SETTING'}) ? $configurations{'VPX_SETTING'} : "yes");
  5098. }
  5099.  
  5100. sub getCpuAndMemPerf {
  5101.         my ($entity_view) = @_;
  5102.     my $returnString = "";
  5103.  
  5104.         my @metrics;
  5105.         my %metricResults = ();
  5106.  
  5107.         if($entity_view->isa('ClusterComputeResource')) {
  5108.                 @metrics = qw(cpu.usage.average cpu.usagemhz.average mem.consumed.average mem.active.average);
  5109.         }elsif($entity_view->isa('HostSystem')) {
  5110.                 @metrics = qw(cpu.usage.average cpu.usagemhz.average mem.usage.average mem.active.average);
  5111.         }elsif($entity_view->isa('VirtualMachine')) {
  5112.                 @metrics = qw(cpu.usage.average cpu.usagemhz.average mem.usage.average mem.active.average cpu.ready.summation cpu.vmmemctl.average);
  5113.         }
  5114.  
  5115.         my $entity_name = $entity_view->name;
  5116.  
  5117.         #get performance manager
  5118.         my $perfMgr = Vim::get_view(mo_ref => $service_content->perfManager);
  5119.  
  5120.         #get performance counters
  5121.         my $perfCounterInfo = $perfMgr->perfCounter;
  5122.  
  5123.         #grab all counter defs
  5124.         my %allCounterDefintions = ();
  5125.         foreach(@$perfCounterInfo) {
  5126.                 $allCounterDefintions{$_->key} = $_;
  5127.         }
  5128.  
  5129.         my @metricIDs = ();
  5130.  
  5131.         #get available metrics from entity
  5132.         my $availmetricid = $perfMgr->QueryAvailablePerfMetric(entity => $entity_view);
  5133.  
  5134.         foreach(sort {$a->counterId cmp $b->counterId} @$availmetricid) {
  5135.                 if($allCounterDefintions{$_->counterId}) {
  5136.                         my $metric = $allCounterDefintions{$_->counterId};
  5137.                         my $groupInfo = $metric->groupInfo->key;
  5138.                         my $nameInfo = $metric->nameInfo->key;
  5139.                         my $instance = $_->instance;
  5140.                         my $key = $metric->key;
  5141.                         my $rolluptype = $metric->rollupType->val;
  5142.                         my $statstype = $metric->statsType->val;
  5143.                         my $unitInfo = $metric->unitInfo->key;
  5144.  
  5145.                         #e.g. cpu.usage.average
  5146.                         my $vmwInternalName = $groupInfo . "." . $nameInfo . "." . $rolluptype;
  5147.  
  5148.                         foreach(@metrics) {
  5149.                                 if($_ eq $vmwInternalName) {
  5150.                                         #print $groupInfo . "\t" . $nameInfo . "\t" . $rolluptype . "\t" . $statstype . "\t" . $unitInfo . "\n";
  5151.                                         my $metricId = PerfMetricId->new(counterId => $key, instance => '*');
  5152.                                         if(! grep(/^$key/,@metricIDs)) {
  5153.                                                 push @metricIDs,$metricId;
  5154.                                         }
  5155.                                 }
  5156.                         }
  5157.                 }
  5158.         }
  5159.         my $intervalIds = &get_available_intervals(perfmgr_view => $perfMgr, entity => $entity_view);
  5160.  
  5161.         my $perfQuerySpec = PerfQuerySpec->new(entity => $entity_view, maxSample => 10, intervalId => shift(@$intervalIds), metricId => \@metricIDs);
  5162.  
  5163.         my $metrics;
  5164.         eval {
  5165.                 $metrics = $perfMgr->QueryPerf(querySpec => [$perfQuerySpec]);
  5166.         };
  5167.         if(!$@) {
  5168.                 my %uniqueInstances = ();
  5169.                 foreach(@$metrics) {
  5170.                         my $perfValues = $_->value;
  5171.                         foreach(@$perfValues) {
  5172.                                 my $object = $_->id->instance ? $_->id->instance : "TOTAL";
  5173.                                 #if($object eq "TOTAL") {
  5174.                                         my ($numOfCounters,$sumOfCounters,$res) = (0,0,0);
  5175.                                         my $values = $_->value;
  5176.                                         my $metricRef = $allCounterDefintions{$_->id->counterId};
  5177.                                         my $unitString = $metricRef->unitInfo->label;
  5178.                                         my $unitInfo = $metricRef->unitInfo->key;
  5179.                                         my $groupInfo = $metricRef->groupInfo->key;
  5180.                                         my $nameInfo = $metricRef->nameInfo->key;
  5181.                                         my $rollupType = $metricRef->rollupType->val;
  5182.                                         my $factor = 1;
  5183.                                         if($unitInfo eq 'percent') { $factor = 100; }
  5184.  
  5185.                                         foreach(@$values) {
  5186.                                                 #if($rollupType eq 'average') {
  5187.                                                         $res = &average($_)/$factor;
  5188.                                                         $res = &restrict_num_decimal_digits($res,3);
  5189.                                                 #}
  5190.                                         }
  5191.                                         my $internalID = $groupInfo . "." . $nameInfo . "." . $rollupType;
  5192.                                         $metricResults{$internalID} = $res . "\t" . $unitString . "\n";
  5193.                                 #}
  5194.                         }
  5195.                 }
  5196.         }
  5197.  
  5198.         my ($cpuAvg,$cpuAvgPer,$memAvg,$memAvgPer,$ballonAvg,$readyAvg) = (0,0,0,0,0,0);
  5199.  
  5200.         for my $key ( sort keys %metricResults ) {
  5201.                 if($key eq 'cpu.usage.average') {
  5202.                         $cpuAvgPer = $metricResults{$key};
  5203.                 }elsif($key eq 'cpu.usagemhz.average') {
  5204.                         $cpuAvg = $metricResults{$key};
  5205.                 }elsif($key eq 'mem.usage.average' || $key eq 'mem.consumed.average') {
  5206.             if($entity_view->isa('ClusterComputeResource') && $key eq 'mem.consumed.average') {
  5207.                             $memAvgPer = $metricResults{$key};
  5208.             }elsif(!$entity_view->isa('ClusterComputeResource') && $key eq 'mem.usage.average'){
  5209.                 $memAvgPer = $metricResults{$key};
  5210.             }
  5211.                 }elsif($key eq 'mem.active.average') {
  5212.                         $memAvg = $metricResults{$key};
  5213.                 }elsif($key eq 'cpu.ready.summation') {
  5214.                         $readyAvg = $metricResults{$key};
  5215.                 }elsif($key eq 'cpu.vmmemctl.average') {
  5216.                         $ballonAvg = $metricResults{$key};
  5217.                 }
  5218.         }
  5219.  
  5220.     my ($perfString,$hostTag,$hostTagShort) = ("","","");
  5221.  
  5222.     if($entity_view->isa('ClusterComputeResource')) {
  5223.             $perfString .= "<h3>Cluster Performance</h3>\n";
  5224.             $perfString .= "<table border=\"1\">\n";
  5225.         $perfString .= "<tr><th>cpu.usagemhz.average</th><th>cpu.usage.average</th><th>mem.active.average</th><th>mem.consumed.average</th></tr>\n";
  5226.  
  5227.                 $perfString .= "<td>" . $cpuAvg . "</td>\n";
  5228.         $perfString .= "<td>" . $cpuAvgPer . "</td>\n";
  5229.         $perfString .= "<td>" . $memAvg . "</td>\n";
  5230.         $perfString .= "<td>" . $memAvgPer . "</td>\n";
  5231.         $perfString .= "</table>\n";
  5232.         } elsif($entity_view->isa('HostSystem')) {
  5233.         my $hostsystem_name = $entity_view->name;
  5234.         if($demo eq "yes") { $hostsystem_name = $host_name; }
  5235.                 $perfString .= "<tr><td>" . $hostsystem_name . "</td><td>" . $cpuAvg . "</td><td>" . $cpuAvgPer . "</td><td>" . $memAvg . "</td><td>" . $memAvgPer . "</tr>\n";
  5236.         } else {
  5237.                 $perfString .= "<tr><td>" . $entity_view->name . "</td><td>" . $cpuAvg . "</td><td>" . $cpuAvgPer . "</td><td>" . $readyAvg . "</td><td>" . $memAvg . "</td><td>" . $memAvgPer . "</td><td>" . $ballonAvg . "</tr>\n";
  5238.         }
  5239.     return $perfString;
  5240. }
  5241.  
  5242. #VMware's viperformance.pl function
  5243. sub get_available_intervals {
  5244.    my %args = @_;
  5245.    my $perfmgr_view = $args{perfmgr_view};
  5246.    my $entity = $args{entity};
  5247.  
  5248.    my $historical_intervals = $perfmgr_view->historicalInterval;
  5249.    my $provider_summary = $perfmgr_view->QueryPerfProviderSummary(entity => $entity);
  5250.    my @intervals;
  5251.    if ($provider_summary->refreshRate) {
  5252.       if($provider_summary->refreshRate != -1) {
  5253.         push @intervals, $provider_summary->refreshRate;
  5254.       }
  5255.    }
  5256.    foreach (@$historical_intervals) {
  5257.       if($_->samplingPeriod != -1) {
  5258.         push @intervals, $_->samplingPeriod;
  5259.       }
  5260.    }
  5261.    return \@intervals;
  5262. }
  5263.  
  5264. sub average {
  5265.    my @arr = @_;
  5266.    my $n = 0;
  5267.    my $avg = 0;
  5268.  
  5269.    foreach(@arr) {
  5270.         $avg += $_;
  5271.         $n += 1;
  5272.    }
  5273.    return $avg ? $avg/$n : 0;
  5274. }
  5275.  
  5276. sub FindPortGroupbyKey {
  5277.    my ($network, $vSwitch, $key) = @_;
  5278.    my $portGroups = $network->networkInfo->portgroup;
  5279.    foreach my $pg (@$portGroups) {
  5280.       return $pg if (($pg->vswitch eq $vSwitch) && ($key eq $pg->key));
  5281.    }
  5282.    return undef;
  5283. }
  5284.  
  5285. sub find_by_key {
  5286.    my ($list, $key) = @_;
  5287.  
  5288.    foreach my $item (@$list) {
  5289.       if ($key eq $item->key) {
  5290.          return $item;
  5291.       }
  5292.    }
  5293.  
  5294.    return undef;
  5295. }
  5296.  
  5297. sub get_pci_string {
  5298.    my $hba = shift;
  5299.    my $pciString = defined($hba) ? $hba->pci : "";
  5300.    # defect 173631
  5301.    if ($pciString =~ /([a-fA-F0-9]+):([a-fA-F0-9]+)\.([a-fA-F0-9]+)$/) {
  5302.       $pciString = hexstr_to_int($1)
  5303.                    . ":" . hexstr_to_int($2)
  5304.                    . "." . hexstr_to_int($3);
  5305.    }
  5306.    return $pciString
  5307. }
  5308.  
  5309. sub hexstr_to_int {
  5310.     my ($hexstr) = @_;
  5311.     die "Invalid hex string: $hexstr"
  5312.     if $hexstr !~ /^[0-9A-Fa-f]{1,8}$/;
  5313.     my $num = hex($hexstr);
  5314.     return $num >> 31 ? $num - 2 ** 32 : $num;
  5315. }
  5316.  
  5317. sub getSnapshotTree {
  5318.     my ($host,$vm,$ref,$tree) = @_;
  5319.  
  5320.     my $head = " ";
  5321.     foreach my $node (@$tree) {
  5322.         $head = ($ref->value eq $node->snapshot->value) ? " " : " " if (defined $ref);
  5323.         my $quiesced = ($node->quiesced) ? "YES" : "NO";
  5324.                 my $desc = $node->description;
  5325.         if($desc eq "" ) { $desc = "NO DESCRIPTION"; }
  5326.         push @vmsnapshots,"<td>".$host."</td><td>".$vm."</td><td>".$node->name."</td><td>".$desc."</td><td>".$node->createTime."</td><td>".$node->state->val."</td><td>".$quiesced."</td>";
  5327.  
  5328.         &getSnapshotTree($host, $vm, $ref, $node->childSnapshotList);
  5329.     }
  5330.     return;
  5331. }
  5332.  
  5333. sub startReport {
  5334.     print "Generating VMware vSphere Health Report v$version \"$report\" ...\n\n";
  5335.     print "This can take a few minutes depending on the size of your environment. \nGet a cup of coffee/tea/beer and check out http://www.virtuallyghetto.com\n\n";
  5336.  
  5337.     if($demo eq "yes") {
  5338.                 $host_name = "DEMO-HOST.primp-industries.com";
  5339.         }
  5340.  
  5341.     $start_time = time();
  5342.         open(REPORT_OUTPUT, ">$report");
  5343.    
  5344.     $my_time = "Date: ".giveMeDate('MDYHMS');
  5345.     my $html_start = <<HTML_START;
  5346. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  5347. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5348. <html xmlns="http://www.w3.org/1999/xhtml">
  5349. <head>
  5350. <meta name="author" content="William Lam"/>
  5351. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5352. <title>VMware vSphere Health Check Report v$version - $my_time ($system_name)</title>
  5353. <style type="text/css">
  5354. <!--
  5355. body {
  5356.     background: rgb(47,109,161);
  5357.     margin: 0;
  5358.     padding: 0;
  5359.     font: 10px normal Verdana, Arial, Helvetica, sans-serif;
  5360.     color: #444;
  5361. }
  5362. a:link { color: blue; }
  5363. a:visited { color: blue; }
  5364. a:hover { color: blue; }
  5365. a:active { color: blue; }
  5366. .author a:link { color: white; }
  5367. .author a:visited { color: white; }
  5368. .author a:hover { color: blue; }
  5369. .author a:active { color: white; }
  5370. th { font-weight:white; background-color:#CCCCCC; }
  5371. h1 {
  5372.     font-size: 3em;
  5373.     margin: 20px 0;
  5374.     color: white;
  5375. }
  5376. div.tabcontainer {
  5377.     width: 95%;
  5378.     height: 100%;
  5379.     margin: 10px auto;
  5380. }
  5381. ul.tabnav {
  5382.     list-style-type: none;
  5383.     margin: 0;
  5384.     padding: 0;
  5385.     width: 100%;
  5386.     overflow: hidden;
  5387.     border-top: none;
  5388.     clear: both;
  5389.     float: left;
  5390.     width: 100%;
  5391.     -moz-border-radius-bottomright: 5px;
  5392.     -khtml-border-radius-bottomright: 5px;
  5393.     -webkit-border-bottom-right-radius: 5px;
  5394.     -moz-border-radius-bottomleft: 5px;
  5395.     -khtml-border-radius-bottomleft: 5px;
  5396.     -webkit-border-bottom-left-radius: 5px;
  5397. }
  5398.  
  5399. ul.tabnav li {
  5400.     float: left;
  5401.     margin: 0;
  5402.     padding: 0;
  5403.     height: 31px;
  5404.     line-height: 31px;
  5405.     border: 1px solid #999;
  5406.     border-left: none;
  5407.     margin-bottom: -1px;
  5408.     overflow: hidden;
  5409.     position: relative;
  5410.     background: #ccc;
  5411.     font-weight: bold;
  5412. }
  5413. ul.tabnav li a {
  5414.     text-decoration: none;
  5415.     color: #000;
  5416.     display: block;
  5417.     font-size: 1.2em;
  5418.     padding: 0 20px;
  5419.     border: 1px solid #fff;
  5420.     outline: none;
  5421. }
  5422.  
  5423. ul.tabnav a:hover {
  5424.     background: #3E86BE;
  5425. }
  5426.  
  5427. div.tabcontents {
  5428. HTML_START
  5429.  
  5430. if($printerfriendly eq "no") {
  5431.     $html_start .= <<HTML_START;
  5432.         height: 550px;
  5433. HTML_START
  5434. }
  5435.  
  5436. $html_start .= <<HTML_START;
  5437.     background: #fff;
  5438.     overflow: hidden;
  5439.     border-top: 1px solid #011;
  5440.     padding: 20px;
  5441.     padding-bottom:30px;
  5442. }
  5443.  
  5444. div.tabcontents {
  5445.     float: left;
  5446.     width: 95%;
  5447.     overflow-y: hidden;
  5448.     padding: 20px;
  5449.     font-size: 1.2em;
  5450. }
  5451.  
  5452. div.content {
  5453.     float: left;
  5454.     width: 100%;
  5455.     height: 100%;
  5456.     overflow: -moz-scrollbars-vertical;
  5457.     overflow: auto;
  5458.     padding: 20px;
  5459. }
  5460.  
  5461. div.tabcontents div.content h2 {
  5462.     margin-top: 3px;
  5463.     font-weight: normal;
  5464.     padding-bottom: 10px;
  5465.     border-bottom: 1px dashed #ddd;
  5466.     font-size: 1.8em;
  5467. }
  5468. .author {
  5469.     font-weight: bold;
  5470.     font-size: small;
  5471.     clear: both;
  5472.     display: block;
  5473.     padding: 10px 0;
  5474.     text-align:center;
  5475.     color:white;
  5476. }
  5477. //-->
  5478. </style>
  5479.  
  5480. <script language="JavaScript">
  5481. visibleDiv = "";
  5482. function showHide(elementid,qstring){
  5483.   if (document.getElementById(elementid).style.display == 'none'){
  5484.     document.getElementById(elementid).style.display = '';
  5485.     if(visibleDiv != ""){
  5486.       if(visibleDiv != elementid){
  5487.         document.getElementById(visibleDiv).style.display = 'none';
  5488.       }
  5489.     }
  5490.     visibleDiv = elementid;
  5491.   } else {
  5492.     document.getElementById(elementid).style.display = 'none';
  5493.   }
  5494. }
  5495. </script>
  5496.  
  5497. </head>
  5498.  
  5499. HTML_START
  5500.  
  5501.     print REPORT_OUTPUT $html_start;
  5502. }
  5503.  
  5504. sub endReport {
  5505.     my $html_end = <<HTML_END;
  5506. <div class="author"><span class="author"Author: <b><a href="http://www.linkedin.com/in/lamwilliam">William Lam</a></b><br/>
  5507. <a href="http://www.virtuallyghetto.com">http://www.virtuallyghetto.com</a><br/>
  5508. Generated using: <b><a href="http://communities.vmware.com/docs/DOC-9842">vmwarevSphereHealthCheck.pl</a></b><br/>
  5509. Support us by donating <b><a href="http://www.virtuallyghetto.com/p/how-you-can-help.html">here</a></b><br/>
  5510. Primp Industries&#0153;
  5511. </span>
  5512. </div>
  5513. </html>
  5514. HTML_END
  5515.  
  5516.         print REPORT_OUTPUT $html_end;
  5517.         close(REPORT_OUTPUT);
  5518.    
  5519.     my @lines;
  5520.         my ($datastore_cluster_jump_string,$cluster_jump_string,$host_jump_string,$vm_jump_string) = ("","","","");
  5521.         tie @lines, 'Tie::File', $report or die;
  5522.         for(@lines) {
  5523.                 if (/<!-- insert cluster jump -->/) {
  5524.                         foreach (@cluster_jump_tags) {
  5525.                                 if( ($_ =~ /^CL/) ) {
  5526.                                         my $tmp_cluster_string = substr($_,2);
  5527.                                         $cluster_jump_string .= $tmp_cluster_string;
  5528.                                 }
  5529.                                 else {
  5530.                                         $cluster_jump_string .= $_;
  5531.                                 }
  5532.                         }
  5533.                         $_ = "\n$cluster_jump_string";
  5534.                         last;
  5535.                 }
  5536.         }
  5537.     for(@lines) {
  5538.                 if (/<!-- insert datastore cluster jump -->/) {
  5539.                         foreach (@datastore_cluster_jump_tags) {
  5540.                                 if( ($_ =~ /^CL/) ) {
  5541.                                         my $tmp_datastore_cluster_string = substr($_,2);
  5542.                                         $datastore_cluster_jump_string .= $tmp_datastore_cluster_string;
  5543.                                 }
  5544.                                 else {
  5545.                                         $datastore_cluster_jump_string .= $_;
  5546.                                 }
  5547.                         }
  5548.                         $_ = "\n$datastore_cluster_jump_string";
  5549.                         last;
  5550.                 }
  5551.         }
  5552.     for(@lines) {
  5553.         if (/<!-- insert host jump -->/) {
  5554.                         foreach (@host_jump_tags) {
  5555.                                 if( ($_ =~ /^CL/) ) {
  5556.                                         my $tmp_host_string = substr($_,2);
  5557.                                         $host_jump_string .= $tmp_host_string;
  5558.                                 }
  5559.                                 else {
  5560.                                         $host_jump_string .= $_;
  5561.                                 }
  5562.                         }
  5563.                         $_ = "\n$host_jump_string";
  5564.                         last;
  5565.                 }
  5566.     }
  5567.     for(@lines) {
  5568.                 if (/<!-- insert vm jump -->/) {
  5569.                         foreach (@vm_jump_tags) {
  5570.                                 if( ($_ =~ /^CL/) ) {
  5571.                                         my $tmp_host_string = substr($_,2);
  5572.                                         $vm_jump_string .= $tmp_host_string;
  5573.                                 }
  5574.                                 else {
  5575.                                         $vm_jump_string .= $_;
  5576.                                 }
  5577.                         }
  5578.                         $_ = "\n$vm_jump_string";
  5579.                         last;
  5580.                 }
  5581.         }
  5582.  
  5583.         untie @lines;
  5584.  
  5585.  
  5586.     my $end_time = time();
  5587.         my $run_time = $end_time - $start_time;
  5588.         print "\nStart Time: ",&formatTime(str => scalar localtime($start_time)),"\n";
  5589.         print "End   Time: ",&formatTime(str => scalar localtime($end_time)),"\n";
  5590.  
  5591.         if ($run_time < 60) {
  5592.                 print "Duration  : ",$run_time," Seconds\n\n";
  5593.         }
  5594.         else {
  5595.                 print "Duration  : ",&restrict_num_decimal_digits($run_time/60,2)," Minutes\n\n";
  5596.         }
  5597. }
  5598.  
  5599. sub startBody {
  5600.         my ($type,$aversion) = @_;
  5601.  
  5602.         my $body_start = <<BODY_START;
  5603.  
  5604. <body>
  5605.  
  5606. <div class="tabcontainer">
  5607.         <h1>VMware vSphere Health Check Report v$version</h1>
  5608.         <ul class="tabnav">
  5609.                 <li><a href="#tab1">System Summary</a></li>
  5610. BODY_START
  5611.                 if($type eq 'VirtualCenter' && $VPX_SETTING eq "yes") {
  5612.                         $body_start .= <<BODY_START;
  5613.                 <li><a href="#tab5">vCenter Settings</a></li>
  5614. BODY_START
  5615.                 }
  5616.                 if($type eq 'VirtualCenter' && $VMW_APP eq "yes") {
  5617.                         $body_start .= <<BODY_START;
  5618.                 <li><a href="#tab6">VMware/3rd Party Applications</a></li>
  5619. BODY_START
  5620.                 }
  5621.                 if($type eq 'VirtualCenter' && ($aversion eq '5.0.0' || $aversion eq '5.1.0')) {
  5622.                         $body_start .= <<BODY_START;
  5623.                 <li><a href="#tab7">Datacenter</a></li>
  5624. BODY_START
  5625.                 }
  5626.                 if($type eq 'VirtualCenter') {
  5627.                         $body_start .= <<BODY_START;
  5628.                 <li><a href="#tab2">Cluster</a></li>
  5629. BODY_START
  5630.                 }
  5631.                 $body_start .= <<BODY_START;
  5632.                 <li><a href="#tab3">Hosts</a></li>
  5633.                 <li><a href="#tab4">Virtual Machines</a></li>
  5634.         </ul>
  5635.         <div class="tabcontents">
  5636. BODY_START
  5637.  
  5638.         print REPORT_OUTPUT $body_start;
  5639. }
  5640.  
  5641. sub endBody {
  5642.         my $body_end = <<BODY_END;
  5643.  
  5644.         </div>
  5645. </div>
  5646. </body>
  5647. BODY_END
  5648.  
  5649.         print REPORT_OUTPUT $body_end;
  5650. }
  5651.  
  5652. sub validateSystem {
  5653.     my ($ver) = @_;
  5654.  
  5655.     if(!grep(/$ver/,@supportedVersion)) {
  5656.         Util::disconnect();
  5657.         print "Error: This script only supports vSphere \"@supportedVersion\" or greater!\n\n";
  5658.         exit 1;
  5659.     }
  5660. }
  5661.  
  5662. # restrict the number of digits after the decimal point
  5663. #http://guymal.com/mycode/perl_restrict_digits.shtml
  5664. sub restrict_num_decimal_digits {
  5665.         my $num=shift;#the number to work on
  5666.         my $digs_to_cut=shift;# the number of digits after
  5667.  
  5668.         if ($num=~/\d+\.(\d){$digs_to_cut,}/) {
  5669.                 $num=sprintf("%.".($digs_to_cut-1)."f", $num);
  5670.         }
  5671.         return $num;
  5672. }
  5673.  
  5674. #http://www.infocopter.com/perl/format-time.html
  5675. sub formatTime(%) {
  5676.         my %args = @_;
  5677.         $args{'str'} ||= ''; # e.g. Mon Jul 3 12:59:28 2006
  5678.  
  5679.         my @elems = ();
  5680.         foreach (split / /, $args{'str'}) {
  5681.                 next unless $_;
  5682.                 push(@elems, $_);
  5683.         }
  5684.  
  5685.         my ($weekday, $month, $mday, $time, $yyyy) = split / /, join(' ', @elems);
  5686.  
  5687.         my %months = (  Jan => 1, Feb => 2, Mar => 3, Apr =>  4, May =>  5, Jun =>  6,
  5688.                         Jul => 7, Aug => 8, Sep => 9, Oct => 10, Nov => 11, Dec => 12 );
  5689.  
  5690.         my $s  = substr($time, 6,2);
  5691.         my $m  = substr($time, 3,2);
  5692.         my $h  = substr($time, 0, 2);
  5693.         my $dd = sprintf('%02d', $mday);
  5694.  
  5695.         my $mm_num = sprintf('%02d', $months{$month});
  5696.  
  5697.         my $formatted = "$mm_num\-$dd\-$yyyy $h:$m:$s";
  5698.         #my $formatted = "$yyyy$mm_num$dd$h$m$s";
  5699.  
  5700.         $formatted;
  5701. }
  5702.  
  5703. #http://www.bryantmcgill.com/Shazam_Perl_Module/Subroutines/utils_convert_bytes_to_optimal_unit.html
  5704. sub prettyPrintData{
  5705.         my($bytes,$type) = @_;
  5706.  
  5707.         return '' if ($bytes eq '' || $type eq '');
  5708.         return 0 if ($bytes <= 0);
  5709.  
  5710.         my($size);
  5711.  
  5712.         if($type eq 'B') {
  5713.                 $size = $bytes . ' Bytes' if ($bytes < 1024);
  5714.                 $size = sprintf("%.2f", ($bytes/1024)) . ' KB' if ($bytes >= 1024 && $bytes < 1048576);
  5715.                 $size = sprintf("%.2f", ($bytes/1048576)) . ' MB' if ($bytes >= 1048576 && $bytes < 1073741824);
  5716.                 $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776);
  5717.                 $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776);
  5718.         }
  5719.     elsif($type eq 'K') {
  5720.         $bytes = $bytes * (1024);
  5721.         $size = sprintf("%.2f", ($bytes/1048576)) . ' MB' if ($bytes >= 1048576 && $bytes < 1073741824);
  5722.                 $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776);
  5723.                 $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776);
  5724.     }
  5725.         elsif($type eq 'M') {
  5726.                 $bytes = $bytes * (1048576);
  5727.                 $size = sprintf("%.2f", ($bytes/1048576)) . ' MB' if ($bytes >= 1048576 && $bytes < 1073741824);
  5728.                 $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776);
  5729.                 $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776);
  5730.         }
  5731.  
  5732.         elsif($type eq 'G') {
  5733.                 $bytes = $bytes * (1073741824);
  5734.                 $size = sprintf("%.2f", ($bytes/1073741824)) . ' GB' if ($bytes >= 1073741824 && $bytes < 1099511627776);
  5735.                 $size = sprintf("%.2f", ($bytes/1099511627776)) . ' TB' if ($bytes >= 1099511627776);
  5736.         }
  5737.         elsif($type eq 'MHZ') {
  5738.                 $size = sprintf("%.2f", ($bytes/1e-06)) . ' MHz' if ($bytes >= 1e-06 && $bytes < 0.001);
  5739.                 $size = sprintf("%.2f", ($bytes*0.001)) . ' GHz' if ($bytes >= 0.001);
  5740.         }
  5741.  
  5742.         return $size;
  5743. }
  5744.  
  5745. sub getColor {
  5746.         my ($val) = @_;
  5747.         my $color_string = "";
  5748.         if($val < $RED_WARN) { $color_string = "<td bgcolor=\"$red\">".$val." %</td>"; }
  5749.         elsif($val < $ORANGE_WARN) { $color_string = "<td bgcolor=\"$orange\">".$val." %</td>"; }
  5750.         elsif($val < $YELLOW_WARN) { $color_string = "<td bgcolor=\"$yellow\">".$val." %</td>"; }
  5751.         else { $color_string = "<td>".$val." %</td>"; }
  5752.  
  5753.         return $color_string;
  5754. }
  5755.  
  5756. # http://andrewcantino.com/class/l2.html
  5757. sub power {
  5758.      my ($i,$t);
  5759.      my ($n, $p) = @_;
  5760.      $t = $n;
  5761.      for(my $i = 1; $i < $p; $i++) {
  5762.           $t = $t * $n;
  5763.      }
  5764.      return $t;
  5765. }
  5766.  
  5767. #http://www.perlmonks.org/?node_id=17057
  5768. sub days_between {
  5769.     my ($start, $end) = @_;
  5770.     my ($y1, $m1, $d1) = split ("-", $start);
  5771.     my ($y2, $m2, $d2) = split ("-", $end);
  5772.     my $diff = mktime(0,0,0, $d2-1, $m2-1, $y2 - 1900) -  mktime(0,0,0, $d1-1, $m1-1, $y1 - 1900);
  5773.     return $diff / (60*60*24);
  5774. }
  5775.  
  5776. sub getUptime {
  5777.     my ($uptime) = @_;
  5778.  
  5779.     my @parts = gmtime($uptime);
  5780.  
  5781.     return $parts[7] . " days " . $parts[2] . " hours " . $parts[1] . " mins " . $parts[0] . " secs ";
  5782. }
  5783.  
  5784. sub giveMeDate {
  5785.         my ($date_format) = @_;
  5786.         my %dttime = ();
  5787.         my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  5788.  
  5789.         ### begin_: initialize DateTime number formats
  5790.         $dttime{year }  = sprintf "%04d",($year + 1900);  ## four digits to specify the year
  5791.         $dttime{mon  }  = sprintf "%02d",($mon + 1);      ## zeropad months
  5792.         $dttime{mday }  = sprintf "%02d",$mday;           ## zeropad day of the month
  5793.         $dttime{wday }  = sprintf "%02d",$wday + 1;       ## zeropad day of week; sunday = 1;
  5794.         $dttime{yday }  = sprintf "%02d",$yday;           ## zeropad nth day of the year
  5795.         $dttime{hour }  = sprintf "%02d",$hour;           ## zeropad hour
  5796.         $dttime{min  }  = sprintf "%02d",$min;            ## zeropad minutes
  5797.         $dttime{sec  }  = sprintf "%02d",$sec;            ## zeropad seconds
  5798.         $dttime{isdst}  = $isdst;
  5799.  
  5800.         if($date_format eq 'MDYHMS') {
  5801.                 $my_time = "$dttime{mon}-$dttime{mday}-$dttime{year} $dttime{hour}:$dttime{min}:$dttime{sec}";
  5802.         }
  5803.         elsif ($date_format eq 'YMD') {
  5804.                 $my_time = "$dttime{year}-$dttime{mon}-$dttime{mday}";
  5805.         }
  5806.         return $my_time;
  5807. }
Add Comment
Please, Sign In to add comment