Get use of the resources of all virtual machines in a cluster

Hello

I have developed a measure of capacity management report that collects all the use of the resources of the virtual machines in a datacenter. The function that collects it looks like this:

def hostMemoryConsumed =]

def memoryConsumed = 0.0f

def memoryGranted = 0.0f

VMs. each() {}

VM->

try {}

memoryConsumed += vm.host.memory.consumed.current.average / 1024.0f<----- how="" to="" do="" this="" to="" get="" from="">

memoryGranted += vm.host.memory.capacity.current.average / 1024.0f

}

{} catch (NullPointerException e)

}

VMS is a function of type parameter VMS VMW

The works above for virtual machines in the data center, but I need it to be after cluster. I can find a cluster of virtual machines, but I'm having trouble with referring to specific values for example consumed memory and capacity.

If I change the type parameter: VMW Cluster how the metric reference would look like (see the try {})?

I don't think that a query will help me.

Thanks in advance

Erik Alm

If you want to do for a cluster, you can just get the list of virtual machines in a cluster of first and passing in your script.  If you have a function for a VMWCluster you can add a parameter for "vmwCluster" that is underneath and it should give you a table (topologyObjects) that has all the virtual machines in the cluster.

QS = server.get ("QueryService") / / query Service

tquery = qs.createStatement("!) (' VMWVirtualMachine where esxServer.parent.name = "+" ' "+ vmwCluster +" "" ") .setQueryTopologyObjects (true);

topologyObjects = qs.executeStatement (tquery) .getTopologyObjects)

Tags: Dell Tech

Similar Questions

  • Get-file provides an account of all virtual machines in the folder structure.

    Hi all

    Tried a few searches in the community, but impossible to find exactly what I was looking for.  We have a configuration folder structure in vCenter.  We have some companies that we bought over time and we set up a folder, separate them with a top-level folder and folders nested for different types of virtual machine below, something like:

    CompanyX

    -Mail servers

    -Web servers

    -DB servers

    For the purposes of internal billing, asked me to get a count of all virtual machines for each company.  I can get the count for virtual machines directly in the "CompanyX" folder, but it does not include virtual machines in subfolders.  This is the script I used so far:

    Write-Output "VM enumeration for CompanyX VMware environment Total: $((Get-dossier 'CompanyX' |)). "(Get-VM) .count) | out-file "D:\ScriptResults\CompanyX.txt" - append

    As I said, that works very well for the virtual machines in the head in the parent folder, but it does not go down to the next layer.  Is there a way to get folder do that?

    I am a novice PowerShell/PowerCLI, so forgive me if I'm missing something obvious.

    Thank you

    Bob

    Hi Bob,

    I don't know if it was different in previous versions, but in the latest PowerCLI version 4.1 U1 if you

    Get-file "CompanyX" | Get - VM

    It will retrieve the VM in the top folder and all subfolders. You can easily check this with:

    Get-file "CompanyX" | Get - VM | Select-Object - Property Name, folder

    If you only want the virtual machine in the top folder you can use:

    Get-file "CompanyX" - NoRecursion. Get - VM

    The following script will get the VM number for all companies and write the result to a .csv file.

    $ExcludeFolders = "Discovered virtual machine","other folder to exclude"
    Get-Folder vm | Get-Folder -NoRecursion | `
    Where-Object {$ExcludeFolders -notcontains $_.Name } | `
    ForEach-Object {
      $Folder = $_
      $Report = "" | Select-Object -Property Company,"Number of VM's"
      $Report.Company = $Folder.Name
      $Report."Number of VM's" = ($Folder | Get-VM | Measure-Object).Count
      $Report
    } | Export-Csv -Path CompanyVMsCount.csv -NoTypeInformation -UseCulture 
    

    If there is high records of the page you want to exclude from the list you can add them to the $ExcludeFolders variable in the first line of the script. The second line of the script gets all the 'vm' top of the folders page. The third line filter unwanted records. A few lines create the output objects. And the last line written objects in a .csv file.

    I added the Measure-Object cmdlet for the ($Folder |) Get - VM | Measure - Object). Account because otherwise you will get an error if the number is 0 or 1.

    Best regards, Robert

  • Access to the network in all virtual machines lost after that put 8.1 to level.

    Today, I upgraded my host computer to Windows 64-bit Pro 8.1. I did the upgrade through the Windows store. There are no errors or problems during the upgrade.

    However: The host machine equipped with a Qualcomm E2200 network adapter, and it runs the 'Killer' Network Manager software called at startup. After the 8.1 update, when the machine did its last restart, Qualcomm Network Manager opened with a message that the LSP has not mapped correctly. I clicked 'YES' to remap it. Probably a stupid move on my part.

    Thereafter, I lost all network connectivity in all my virtual machines. I have virtual machines for Windows 8, Windows 8.1 RTM (not the preview) and Ubuntu 12.04 LTS. ALL of them have lost the network.

    The host computer has no network problem and works well after the upgrade.

    Any ideas or suggestions to reset network connections in virtual machines?

    All virtual machines are set to use NAT.

    Oh I have to say also that the host computer is running VMware Workstation 10 and everything was fine and dandy, has never had problems at all until this upgrade/LSP remap thing. I have install VMware Tools in the VM of Windows 8.1, with no effect at all.

    Thank you.

    -J

    Two things, I'll try:

    1. go in the virtual network editor and restore settings. The culprit is probably the VMNet to NAT configuration.

    2. If this does not work, it seems that the virtual card for NAT does not somehow. The simplest workaround is to uninstall and reinstall the workstation.

  • Is no vmdk file, but the script says, all virtual machines backed up Ok!

    Hello everyone;

    Please excuse any lack of details because this is the first time that I write. I've scoured internet for days now trying to find no matter how much detail that could help me solve the problem. I'm new in the world of script ESXi and ghettoVCB.

    My intention is to run several tasks on a schedule. Each type of backup (quarterly, monthly, weekly, daily and multiple) runs at a specific time. The planning section works very well.

    I'm hoping to solve this urgent backup, I should be able to solve reboot.

    Here is the command I use:

    /vmfs/volumes/datastore1/ghettoVCB.sh w /tmp/ghettoVCB-work.multiple f/vmfs/volumes/datastore1/vmlist-Multiple g/vmfs/volumes/datastore1/vmconfig-DataSet1-multiple-l /vmfs/volumes/datastore1/ghettoVCB_logs/ghettoVCB.Multiple_Backup.log

    vmconfig-DataSet1-multiple contains:

    # Multiple backups - rotation County 6

    #

    VM_BACKUP_VOLUME = / vmfs/volumes/Vault2-DataSet1/URANUS/Multiple

    DISK_BACKUP_FORMAT = thin

    VM_BACKUP_ROTATION_COUNT = 6

    POWER_VM_DOWN_BEFORE_BACKUP = 0

    ENABLE_HARD_POWER_OFF = 0

    ITER_TO_WAIT_SHUTDOWN = 4

    POWER_DOWN_TIMEOUT = 5

    SNAPSHOT_TIMEOUT = 15

    ENABLE_COMPRESSION = 0

    VM_SNAPSHOT_MEMORY = 0

    VM_SNAPSHOT_QUIESCE = 0

    VMDK_FILES_TO_BACKUP =

    Vmlist-multiple contains 1 server is listed:

    # List all virtual machines that are backed up several times a day

    HEAT

    The log indicates that the backup was successful - but it has not been the case. Backup size should be approximately 8 GB. However, when you look at the output folder, only the following files are here:


    HEAT.vmx

    STATUS.ok

    Question is now - where are the vmdk files that should be present?

    Output (-d debug) can be found here: http://pastebin.com/hMGphTL3

    So, here is what I observed:

    When you run the script, the snapshot only takes a few seconds to create and delete then. I'm seeing happens on the list of the tasks of vSphere Rencent (screenshot attached).

    If I create a snapshot manually - it will take much more time to create and delete a snapshot. The difference here is 6 minutes, and 4 seconds using the script create a snapshot manually.

    So my presumption is that he is not actually create the snapshot, although vSphere said it is being created. So why is it the case?

    Help, please.

    ADDENDUM:

    If I run the following:

    ./ghettoVCB.sh m HEAT

    The backup is successful.

    Your said he clearly did not config file to back up all files hard.

    VMDK_FILES_TO_BACKUP =

    I expect to see something like this if you want all the hard files

    VMDK_FILES_TO_BACKUP = "all".

  • The list of all virtual machines with more than 2 virtual disks

    Hello.

    I want to list all virtual machines in a data center vCenter, who got more than 2 virtual disks. Here's the workflow, I am working on that:

    1 get the view of data center

    2. get the Cluster Data Center view like the 'begine_entity '.

    3. for each view cluster overview the VirtualMachine bit cluster seen as 'begin_entity '.

    4. for each VM view, this information: VirtualMachine-> config-> hardware-> device of

    Above information is a table.

    I need help in order to extract information from this table disk, then run an if condition where the VM who got more than 2 discs should print.

    Could help you. I wrote the script to the point 4. just need advice for the posterior.

    Thank you.

    You can try one of the following values-

    1 If ($vm-> {'summary.config.numVirtualDisks'} > 2) {...}

    2 $diskCnt = grep {$_-> isa ('VirtualDisk')} @{$vm-> {'config.hardware.device'}};

    The above assumes that you've got your $vm with a filter property as follows:

    $vms = Vim::find_entity_views (view_type-online 'VirtualMachine'), the properties-online ['summary.config.numVirtualDisks', 'name', 'config.hardware.device'];

    my $vm foreach (@{$vms}) {}

    ...

    }

  • The list of all virtual machines to a host group in Virtual Machine port group

    Ladies and gentlemen,

    I would like to create a powershell script to list all my virtual machines to a host, but a group of Machine virtual PortGroup... It is possible...? I see only found Internet see the VirtualPortGroup of the host...

    Thanks in advance & looks

    All your VMS have a mapping single portgroup or it not with multiple NICs on different port groups?

    If they are all the same, then the following should work:

    Get-VM | Select Host, Name, @{N="PortGroup";E={$_.NetworkAdapters[0].NetworkName}} | Sort PortGroup, Name, Host
    

    If you found this information useful, please consider the allocation of points for correct or helpful.

    Alan Renouf

    http://Virtu-al.NET

  • The list of all virtual machines in a Datacenter

    Hello

    I have several data centers in the vCetner and I want to list virtual machines in a perticular Datacenter. Here is the script I wrote. Apologies, I am an amateur and my script is a mess;

    #! / usr/bin/perl - w
    use strict;
    Use Data::Dumper;
    use VMware::VIRuntime;
    My % opts =)
    Data Center = > {}
    Type = > "s =",
    help = > 'enter the name of the data center. "
    required = > 1,
    }
    );
    OPTS::add_options (%OPTS);
    OPTS::parse();
    OPTS::Validate();
    Util::Connect();
    my $dc = Opts::get_option ('Center');
    My $dc_views = Vim::find_entity_views (view_type = > 'Data center',)
    filter = > {name = > $dc});
    foreach (@$dc_views)
    {
    My $funky = Vim::get_view (mo_ref = > $_-> vmFolder);
    My $funky2 = $funky-> childEntity;
    My $funky3 = Vim::get_views (mo_ref_array = > $funky2);
    foreach (@$funky3) {print $_-> name.} "\n"; }
    }

    When I run above to put it just said 'Discovered virtual machine:

    #perl test.pl - Server < what > - username < whatever - > password < what > - datacenter DC01_ESXi5

    Virtual machine discovery
    It would be great if someone could explain to me where I'm wrong. I don't want a script that I would like to get the desired result, indeed, I want to know where I am going wrong in above script. I find it extremely difficult to understand the structure of data API vSphere. Programming Perl is not the issue here.
    Thnaks.

    There is a somewhat easier way that browsing the inventory tree.

    If you just want to entities in a data center, you can use begin_entity in your find_entity_view* calls.

    #! / usr/bin/perl - w
    use strict;
    Use Data::Dumper;
    use VMware::VIRuntime;
    My % opts =)
    Data Center-Online {}
    type-online "s =",
    help-online "Please enter the name of the data center."
    necessary,-online 1
    }
    );
    OPTS::add_options (%OPTS);
    OPTS::parse();
    OPTS::Validate();
    Util::Connect();
    my $dc = Opts::get_option ('Center');
    My $dc_view = Vim::find_entity_view (view_type-online "Data center"
    filter-online {name-online $dc},
    Properties-online ['name']);
    Don't Die "No data center named"$dc"found!" unless $dc_view;
    My $vm_views = Vim::find_entity_views (view_type-online 'VirtualMachine', begin_entity-online $dc_view).
    foreach my {$vm (@$vm_views)}
    Print "vm:". "." $vm-> name. "\n";
    }
  • script to summarize the use of the total disc of virtual machines

    How can I summarize sizes total vmdk (not thin) of a list of virtual machines in vc?

    Hello, once again-

    I see your second post.  Yes, you could go that route, too.  You are close to, simply add in a Measure-Object call.  A little cleaned up, it would be like:

    $machines = Get-Content c:\servers.txtGet-VM -Name $machines | Get-HardDisk | `    select @{N="VMName";E={$_.Parent.Name}},@{N="Capacity(GB)";E={[math]::truncate($_.CapacityKB / 1MB)}},Filename | `    Measure-Object -Property "Capacity(GB)" -Sum
    

    How does do for you?

  • Change the host for a virtual machine on a cluster and the host is not in accordance with the attached profile

    Hi all

    I have 02 questions.

    1. we have a cluster which has 02 physical hosts (Host1 and Host2). We have 02 virtual machines on the Cluster. Active DRS on the cluster.

    But the problem is that my 02 VMS are always stays on a Host2. A few weeks ago, each virtual machine carried out on each host. How can I place each virtual machine on each host to perform better.

    How to do this?

    2. I connect to the cluster using vSphere client 5.1, under summer host, I get the following message

    "Configuration problems: host is not in accordance with the attached profile.

    I suspect that this is the case for my question 1?

    Thank you very much

    Hello

    I think I found the answer for the problem of home profile. I changed the following values to 1 for each host to > settings > under software > advanced settings >

    Under Data Mover

    HardwareAcceleratedInit

    HardwareAcceleratedMove


    Under VMFS3

    HardwareAcceleratedLocking

    Compliance status is returned to the green.

    Thanks for the advice guys!

    Thank you

  • The list of all virtual machines by Datastore

    Hello

    At some point LucD posted the following answer in another thread http://communities.vmware.com/thread/293395

    Get-Datacenter | Get-VM | %{$vm = $_Get-Datastore -VM $vm | %{$vm.Name + "-" + $_.Name} } | ft -AutoSize

    But on my end, I can't do this job, I get the following error:

    You must provide an expression of value on the side right of the '-' operator.
    On line: 1 char: 41
    + Get-Data Center | Get - VM | % {$vm = $_Get - < < < < Datastore - VM $vm | % {$vm.} Nom + «- » + $_. Name}} | FT - AutoSize
    + CategoryInfo: ParserError: (:)) [], ParentContainsErrorRecordException)
    + FullyQualifiedErrorId: ExpectedValueExpression

    Thanks for your help,


    There is a missing semicolon. It should be:

    Get-data center | Get - VM | %{$vm = $_ ; Get-Datastore - VM $vm | % {$vm. Nom + «- » + $_. Name}} | FT - AutoSize

  • Is it possible to recover all the virtual machines in a cluster in a single web service call?

    I tried to retrieve the list of all virtual machines in a cluster to a single web service call, but to no avail. It seems that there is no direct web service API to achieve this goal. Alternative options must first recover the hosts or data warehouses in the cluster and then recover virtual machines from there. But still, if anyone has an idea how we can do this please let me know. All help information will be greatly appreciated.

    It is possible, if you use the PropertyCollector.

    (It is usually the answer to questions of the form "Is it possible to retrieve the X in a single web service call").

    Call"propertycollector.retrievecontents:

    http://www.VMware.com/support/developer/VC-SDK/visdk41pubs/ApiReference/vmodl.query.PropertyCollector.html#retrieveContents

    allows you to retrieve a whole bunch of stuff in a single call, which you then have to go through and interpret.

    A snippet of code Java VI is not-really-tested to find virtual machines in a ComputeResource (cluster) is attached.

  • Determine the version of VMware tools on all virtual machines

    I found a powershell script that shows how to enumerate the vmtools on a virtual machine version, it is possible to use a script to display the version on all virtual machines without hard coding names? Thanks in advance for your help.

    You can try something like this

    get-vm | % { get-view $_.ID } | select Name, @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}}
    
  • The former "cannot change the power state of virtual machine: the process has exited with an error: end of the error message" thing again (Fedora 8/Server 1.08)

    OK, this problem beautifully undescriptive I've seen caused by what seems to be dozens of things happening for me.

    I made the mistake of horrible update my FC8 kernel to the latest one (2.6.26.8 - 57.fc8).  Mind you, that's all that's changed.  It was with a 1.06 server with happiness and perfectly good computers running virtual in use before the upgrade.

    After the new kernel and reboot, I had to rebuild vmmod.  I had to get a fix of any - any later that I used with my previous kernel (116 does not solve the problem of compiling) so I used all-any117d.  Update like a champion.

    Try to turn on a VM and Ihanta!, the above error.

    Nothing else was changed.

    I tried the upgrade to VMware Server 1.08.  Used all-new any117d - update OK.

    Error again.

    I have re-run the compilation, this time to say 'yes' to what the installation script to "adjust the permissions of all virtual machines in xxxlist" or whatnot.

    Error again.

    1. status of /etc/init.d/VMware

    Networking networking on/dev/vmnet0 is running

    Invited only on/dev/vmnet1 network is running

    Network invited only on/dev/vmnet8 is running

    NAT networking on/dev/vmnet8 is running

    Responsible vmmon module

    Loaded module Vmnet

    FWIW, I compile as long as root, but have always run VMware server from my UID nonroot.

    What now?

    I'm in the same boat.  Fedora 8 2.6.26.8 - 57.fc8 #1 SMP

    I have tried uninstalling/reinstalling v1.0.6 thru 1.0.8 with all 116 updates and 117d.   117D compiles with every version of server but when I try to turn on a virtual computer I get this error.

    Cannot change the power state of virtual machine: the process has exited with an error:

    vmxvmdb: name of the Index generated by the configuration file

    POST (no connection): Version mismatch with vmmon module: expected 138.0, obtained 168.0.

    You have a bad version of the module kernel "vmmon.

    Try reinstalling VMware Server.

    POST (no connection): failed to initialize the surveillance apparatus.

    Failed to initialize the virtual machine.

    End of the error message.

    I found several posts other people have this problem but

    they are months with no recent activity and nothing that solved the problem.  I found appeared

    to get a fix, one updated the all an update that corrects the problem for

    2.6.26 performing several nuclei, but the link for the update on TI-psycho appears to be dead.  Here is the link to the discussion

    http://Fedoraforum.org/Forum/showthread.php?t=199026&page=2

    Of course, I would like to know how to solve this problem as well.

    Thank you

  • Determine the maximum use of the processor for a virtual computer in the custom user interface

    I want to determine the maximum use of the processor for a virtual computer in the custom user interface.  How can I do this?

    If I use a supermetric, there is no kind of attribute under CPU called "maximum use.

    Certainly, you get points for a long question! Although to be fair, it's probably my fault to feed you so much information to digest at once.

    1. I would say you can do two ways visually. Use the operations > detail view for 'normal ranges' use the upper limit of the normal range as your typical max. You want an absolute peak, add the metric of a graph or observe that highlight high and low watermarks.

    2. There are a lot of ways to display data, but if you want to display a single metric over a period of time, we could use the following widgets [on top of my head]:

    Top - N analysis

    Weather map

    Analysis of distribution of data

    Among these, I think of your desire for a "peak". Who you want real value, which eliminates the weather map. Then, I think that the concept of a 'Summit' and what is the best thing, I think that the 95th percentile... then I came with the widget of data distribution. The decision is ultimately yours given your particular use case.

    3. you can have it apply to several virtual machines - it's just a widget capable of being an independent provider or receiving widget (metrics, DO NOT choose to select resources). Each resource/metric will add to the widget and you can remove them if you like after it is added. You can certainly all the time you visit... It is date and time standard options you have in all the other widgets chart. With the widget data distribution, you want as much time as possible to get an accurate histogram of the cycles of workload.

    4. This is similar to the question above. You can certainly add parameters of individual resource or a DM that summarizes or AVG groups of resources. And as above, the delay is configurable, along with the other graph widgets.

    5. it's part of Q4 - you can sumN or avgN up to any number of resources with a SM, then discovers that SM in the widget of data distribution. When I said container, I mean an application, group resource pool... all that acts as a container parent within the vCOps.

    6. that's correct, SMs calc using data collected last points... aka single period of time. When you are referring to the longest period, I gave you a few examples of the attributes that are composed of several periods of time which are calculated and created by the adapter for VMware vCenter behvaior. In this case, you have the GVA 15 min CPU 1.5; These specific simple mobile GVA can be specific OR a copy using SMs. Next, you will have the chance is to find a way to distribute what you need through a widget [at that time].

    7. the distribution of data is not for export, it is for Visual functions. If you want the data in CSV, just use a typical chart of metrics and export to a csv and calc your own pics, avg, 95th, whatever.

    8. This is a bit of a mix of all your questions, put in place.

    You are right, if you added those 3 VMs, then calc was the 95th of the AVG. Like Q7, you would not export the data of the distribution of data because the raw data points are not - you do not pass the metric to a metric graphics standard and export via csv.

    Take advantage of...

  • Gwetting a list of all virtual machines and used space


    I apologize for my very basic question.

    I need to make a file (better if an Excel file) with a list of all virtual machines in a simple 5.x vSphere infrastructure including 2 VMare ESXi 5.x servers and the disk space used (allocated, used) of each virtual computer.

    The easiest way seems to list the virtual machines from the vSphere client and export the list as a .xls file.

    It seems simple, but when I look at the file I see a lot of missing VMs or a large number of missing values for several virtual machines (just the Runts).

    Is this a problem with my vSphere client?

    I tried to create a PowerCli script using the "Get - VM|" Select-object Name"command, but my limited skills will let me extract the value of the used space.»

    Can someone please provide a sample of PowerCli I can just copy and use?

    Is there another way to get the information I need?

    Concerning

    Marius

    .

    Not knowing that if you have configured a cluster or just stand-alone hosts, here is one simple line...

    Get-VMHost-name | get - vm | select name, usedspaceGB

    From there, you can make formatting, get total usage etc.

Maybe you are looking for