Automation

 View Only
  • 1.  Need powercli for getting cluster report for anomaly detection.

    Posted Mar 10, 2021 04:03 PM

    Hi,

    Need help how we can automate if my Cluster Host and Memory Utilization reaches certain threshold to notify user with dashboard report. Need to add host capacity in Cluster

     



  • 2.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 10, 2021 04:52 PM

    What do you already have?



  • 3.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 07:30 AM

    Currently , we are not using any tool. Looking for help to build script . Please help us . How we can automate...



  • 4.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 07:49 AM

    That is a very vague request for a script.

    Do you have any concrete requirements for the script?
    What specific help do you seek?
    Have you any experience with PowerCLI?



  • 5.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 07:52 AM

    Yes, Have experience in using Powercli. Can you help us to get dashborad report . If not possible for anomaly detection.



  • 6.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 08:02 AM

    Looking Powercli script like this

    ClusterName =
    Total Hosts =
    Total VMs =
    CPU (Available) = No of Phyical core per socket
    Memory (Available) (GB) =
    vCPU (Allocated) =
    vCPU Allocation Ratio (%) = vCPU (Allocated) / CPU (Available)
    vRAM Allocated (GB) =
    vRAM Allocation Ratio (%) = vRAM Allocated (GB) / Memory (Available) (GB)
    vCPU Utilization Max(%) =
    vCPU Utilization Min(%) =
    vCPU Utilization Avg(%) =
    vRAM Utilization Max(%) =
    vRAM Utilization Min(%) =
    vRAM Utilization Avg(%) =

     



  • 7.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 08:07 AM

    Did you do a search in this community?
    That kind of report is asked for quite regularly.



  • 8.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 10:31 AM

    I tried but not getting relevant report. Would request you to share the discussion article or help me to get script.



  • 9.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 11:13 AM

    Thanks , I found same script in your earlier post.



  • 10.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 11:20 AM

    Having got the powercli for Cluster information. But need your help how i can convert this into dashboard in html format. Can we set some threshold to high light in red color using formula.

     

    Example : If used capacity of CPU / Mem / Storage reaches 85% then should highlight in red color.

    Get-Cluster -Server $vc | where{$_.ExtensionData.Host.Count -ne 0} | ForEach-Object -Process {
    Write-Host "Looking at cluster $($_.Name)"
    #$ds = Get-Datastore -RelatedObject $_ | where{$_.ExtensionData.Summary.MultipleHostAccess}
    $sStat = @{
    Entity = Get-Cluster -Name $_.Name
    Stat = 'cpu.usage.average', 'mem.usage.average'
    Start = (Get-Date).AddDays(-7)
    # Start = (Get-Date).AddHours(-1)
    Instance = '*'
    ErrorAction = 'SilentlyContinue'
    }
    $stat = Get-Stat
    $esx = Get-VMHost -Location $_
    $hostthreads = ($esx.extensiondata.hardware.cpuinfo.numcputhreads | Measure-Object -Sum).Sum
    $vm = Get-VM -Location $_ | where{$_.PowerState -eq "PoweredOn"}
    $cpuTot = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum
    $cpuUse = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum
    $memTot = ($esx | Measure-Object -Property MemoryTotalGB -Sum).Sum
    $memUse = ($esx | Measure-Object -Property MemoryUsageGB -Sum).Sum
    $obj = [ordered]@{
    #vCenter = $global:defaultviserver.Name
    Cluster = $_.Name
    'Total CPU Ghz' = [math]::Round($cpuTot/1000,0)
    'CPU Usage' = "{0:P0}" -f ($cpuUse/$cpuTot)
    'CPU 7-day' = "{0:P2}" -f (((($stat | where { $_.MetricId -eq 'cpu.usage.average' }).Value | Measure-Object -Average).Average)/100)
    'CPU Free' = "{0:P0}" -f (($cpuTot - $cpuUse)/$cpuTot)
    'Total RAM GB' = [math]::Round($memTot,0)
    'RAM Usage' = "{0:P0}" -f ($memUse/$memTot)
    'RAM 7-day' = "{0:P2}" -f (((($stat | where { $_.MetricId -eq 'mem.usage.average' }).Value | Measure-Object -Average).Average)/100)
    'RAM Free GB' = "{0:P0}" -f (($memTot - $memUse)/$memTot)
    #'Total Capacity GB' = [math]::Round(($ds.CapacityGB | Measure-Object -Sum).Sum,0)
    #'Used Capacity GB' = [math]::Round(($ds | %{$_.CapacityGB - $_.FreeSpaceGB} | Measure-Object -Sum).Sum,0)
    #'Free Capacity GB' = [math]::Round(($ds.FreeSpaceGB | Measure-Object -Sum).Sum,0)
    'N° Hosts' = $_.ExtensionData.Host.Count
    'N°VMs' = &{
    $esxVM = Get-View -Id $_.ExtensionData.Host -Property VM
    $vm = @()
    if($esxVM.VM){
    $vm = Get-View -Id $esxVM.VM -Property Summary.Config.Template |
    where{-not $_.Summary.Config.Template}
    }
    $vm.Count
    }
    'vCPU' = ($vm.NumCpu | Measure-Object -Sum).Sum
    'pCPU' = ($esx.NumCpu | Sort-Object -Descending | Select -Skip 1 | Measure-Object -Sum).Sum
    'vCPU/pCPU' = "{0:P0}" -f (($vm.NumCpu | Measure-Object -Sum).Sum / ($esx.NumCpu | Measure-Object -Sum).Sum)
    'vMem' = [math]::Round(($vm.MemoryGB | Measure-Object -Sum).Sum)
    'pMem' = [math]::Round(($esx.MemoryTotalGB | Measure-Object -Sum).Sum)
    'vMem/pMem' = "{0:P0}" -f (($vm.MemoryGB | Measure-Object -Sum).Sum / ($esx.MemoryTotalGB | Measure-Object -Sum).Sum)
    }
    New-Object PSObject -Property $obj
    }



  • 11.  RE: Need powercli for getting cluster report for anomaly detection.

    Posted Mar 11, 2021 11:33 AM

    There are similar questions in this community, see for example Solved: Re: Generate HTML Report with cell colors - VMware Technology Network VMTN