Hi , I am planning to extract performance data(cpu,net,storage,ram) of all vms and host and push to mysql ,but I don't how to do it .Anyone can guide me ?I appreciate . following is my code ,...
See more...
Hi , I am planning to extract performance data(cpu,net,storage,ram) of all vms and host and push to mysql ,but I don't how to do it .Anyone can guide me ?I appreciate . following is my code ,only can show vms : #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use DBI;
5 use utf8;
6 use VMware::VIRuntime;
7 use VMware::VILib;
8
9
10 my %opts = (
11 cluster => {
12 type =>"=s" ,
13 help => "Enter the Cluster name" ,
14 required => 1,
15 }
16
17 );
18
19 #connect the host
20 Opts::add_options(%opts);
21 Opts::parse();
22 Opts::validate();
23 Util::connect();
24
25 #script start
26 my $cluster = Vim::find_entity_views (view_type =>'ClusterComputeResource',
27 properties => ['name'],
28 filter =>{'name' =>Opts::get_option('cluster')});
29
30 my $vms = Vim::find_entity_views( view_type=>'VirtualMachine',
31 properties => ['name']);
32 #begin_entity => $cluster );
33
34 foreach my $vm ( @{$vms || []} ) {
35 print "Name:" .$vm->name "\n";
36 }
37
38 my $hosts = Vim::find_entity_views( view_type=>'HostSystem',
39 properties => ['name']);
40
41 foreach my $host ( @{$hosts || []} ) {
42 print "Name:" .$host->name ."\n";
43 }
44
45 Util::disconnect;