1 2 Previous Next 25 Replies Latest reply on Feb 26, 2020 2:21 PM by LucD

    Average Network throughput for a VM with PowerCLI

    TheVMinator Master

      I would like to get the average network throughput for a VM with PowerCLI including all virtual NICs the VM has for the last week (not including NFS or storage-related traffic).

      How should I best add that to this report:

       

      get-vm myvm | select name, numcpu

      Thanks!

        • 1. Re: Average Network throughput for a VM with PowerCLI
          LucD Guru
          vExpertUser ModeratorsCommunity Warriors

          Try like this

           

          Get-VM | 
          Select Name, @{N="Avg Network Throughput MBPs";E={
              [
          math]::Round((Get-Stat -Entity $_ -Start (Get-Date).AddDays(-7) -Stat "net.throughput.usage.average" |
             
          where {$_.Instance -eq ""} |
             
          Measure-Object -Property Value -Average | Select -ExpandProperty Average)/1KB,2)
          }}

           

          The script only takes the aggregated value for all vNICs (the one where the Instance is an empty string).

          Then it takes the average and converts the KBPs to MBPs.

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Average Network throughput for a VM with PowerCLI
            TheVMinator Master

            OK great thanks again.

            • 3. Re: Average Network throughput for a VM with PowerCLI
              bvi1006 Enthusiast

              Hi,

              When I run this I get The metric counter "net.throughput.usage.average" doesn't exist for entity....

              Does anyone know why?
              Thanks!

              • 4. Re: Average Network throughput for a VM with PowerCLI
                bvi1006 Enthusiast

                Looks like (maybe it's my version of esx or vsphere, but I have to use

                 

                net.usage.average

                 


                1 person found this helpful
                • 5. Re: Average Network throughput for a VM with PowerCLI
                  LucD Guru
                  vExpertUser ModeratorsCommunity Warriors

                  The net.throughput.usage.average counter requires statistics level 3, perhaps that is the cause of the problem ?

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  2 people found this helpful
                  • 6. Re: Average Network throughput for a VM with PowerCLI
                    bvi1006 Enthusiast

                    thanks, probably it !

                    Is there a way to get the top talkers (vms) to the Datastores?

                    Thanks!

                    • 7. Re: Average Network throughput for a VM with PowerCLI
                      LucD Guru
                      Community WarriorsUser ModeratorsvExpert

                      You might want to look at datastore.write.average and datastore.read.average for VMs.

                      These require statistics level 2.

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      1 person found this helpful
                      • 8. Re: Average Network throughput for a VM with PowerCLI
                        Madmax01 Hot Shot

                        @Lucd: net.throughput.usage.average    is not working for me.  guessing it's  for 5.5?  or lower then 5.5?  then with 5.1 it's not working.

                         

                        Anyway  i have planned to query Stats from >1000 VM's.

                         

                        with the normal translated cmdlets  its horrible slow.

                         

                        i remember some threads where somebody tested to talk nativ with the Api without translation.

                         

                        Anybody does have knowledge through that?  so because it would be massive time saving.

                         

                        thx

                         

                        max

                        • 9. Re: Average Network throughput for a VM with PowerCLI
                          LucD Guru
                          User ModeratorsCommunity WarriorsvExpert

                          That counter is available in vSphere 5.5, but make sure you are at statistics level 3 to get it.

                           

                          net-throughput.png

                           

                          You might want to give my Get-Stat2 a try. It should be faster than the Get-Stat cmdlet.

                          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                          1 person found this helpful
                          • 10. Re: Average Network throughput for a VM with PowerCLI
                            Madmax01 Hot Shot

                            Hi LucD,

                             

                            thx for the Info.

                             

                            Just a Mind-question.   Is it primary Possible to use new Function as nativ cmdlets?  So what i mean > is it possible to have  "Get-Stat2"  as cmdlet started through powercli?  would like to avoid loading up in script directly. once a new function is usefull > would be good starting up with powercli directly.

                             

                            PS:  would be happy if you could give us short info differences between stat + stat2 .

                             

                            muchas thx

                             

                            max

                            • 11. Re: Average Network throughput for a VM with PowerCLI
                              LucD Guru
                              vExpertCommunity WarriorsUser Moderators

                              I did some annotations in my 1st publication of my Get-Stat2 function.

                              See Datastore usage statistics

                               

                              The difference with the Get-Stat cmdlet that comes with PowerCLI, is that my Get-Stat2 function uses the same underlying PerformanceManager properties and methods.

                              The explanation that my function tends to be faster, is most probably due to the fact that I had take less aspects into account, and that I could optimise my function for the functionality I wanted from the function. While the PowerCLI Dev Team has to code more general.

                               

                              And yes, a PowerShell function can be used just like a cmdlet.

                              I store my often used functions in my personal PowerShell profile.

                              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                              • 12. Re: Average Network throughput for a VM with PowerCLI
                                Madmax01 Hot Shot

                                Hi Lucd,

                                 

                                many thx.  i pushed it into the Profile. works fine.  So now but the Difference beetween get-stat and get-stat2 are confusing me.

                                 

                                follwoing code i used:

                                 

                                1:

                                (get-vm test |get-stat -stat net.usage.average -Start (get-date).date.adddays(-30) |measure-object value -average).average

                                 

                                2:

                                (get-stat2 -Entity $vm.extensiondata -Stat "net.usage.average" -Start (get-date).date.adddays(-30) -Finish (get-date) -Interval "HI3" |measure-object value -average).average

                                 

                                1: = 126.19

                                2: = 625.60

                                 

                                so i ever though that the get-stat is using the correct Interval ?  so seems to be it's using not correct ones.

                                 

                                If i push for Version 1:   -IntervalSec  7200  > then i get same Value then  from get-stat2

                                 

                                are i'am wrong or was it working for a specific version of powercli to have correct Interval once using   -Start + -Finish?

                                 

                                but in my test the execution was amazing fast >5x faster then the normal cmdlet

                                 

                                thx

                                 

                                Best regards

                                 

                                Max

                                 

                                PS: could you please have a look what i have done false? So because with get-stat  everything is working (but runs several hours). But with get-stat2   i get errors after i pooling through some vm's. thx.

                                 

                                -Instance parameter invalid for requested stat: net.usage.average. Valid values are: "" At C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:179 char:9 +         Throw "-Instance parameter invalid for requested stat: $st.`nValid value ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~     + CategoryInfo          : OperationStopped: (-Instance param... values are    : "":String) [], RuntimeException     + FullyQualifiedErrorId : -Instance parameter invalid for requested stat:    net.usage.average. Valid values are: ""

                                • 13. Re: Average Network throughput for a VM with PowerCLI
                                  Madmax01 Hot Shot

                                  Hi theire,

                                   

                                  ok found the Problem.  get-stat2 is stopping once attaching an shuted down vm which is longer offline then the interval time.   i integrated now a PowerState query for (get-vm). now get-stat2 script is running.

                                  get-stat is running through > and alerts at the end.

                                   

                                  now i will run the script.   nosy about the time difference.  other ones was  ~3h running. now i test with that .

                                   

                                  Best regards

                                   

                                  Max

                                  • 14. Re: Average Network throughput for a VM with PowerCLI
                                    LucD Guru
                                    vExpertUser ModeratorsCommunity Warriors

                                    I'm afraid that is how the PerformanceManager methods work.

                                    They look at the start of the interval, and if no data is there, they seems to return nothing.

                                    Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                    1 2 Previous Next