1 2 3 4 5 Previous Next 61 Replies Latest reply on Apr 12, 2016 10:15 AM by ggmattingly Go to original post
      • 30. Re: Using PowerCLI to get VM Disk Stats
        vihar1 Novice

        Thanks, I'll have a look at it.

         

        What is strange, that the VM was powered on Jan 15 this year and the query was about the time between 31 Jan and 02 Feb and it still gave me this error...

        • 31. Re: Using PowerCLI to get VM Disk Stats
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          Do you see metrics for that VM under the Performance tab for that period ?

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 32. Re: Using PowerCLI to get VM Disk Stats
            vihar1 Novice

            The same error received for productive VMs, but in the GUI it shows seemingly correctly (there are peaks but mostly 0 - not much load is there).

             

            I had a look at the metrics but I do not know how to use them. The get-stat does not seem to accept them (I'm a PowerCLI beginner, API calls seem to stretch beyond my knowledge)

            • 33. Re: Using PowerCLI to get VM Disk Stats
              vihar1 Novice

              We were able to gather CPU stats but not for disks. Is that true that it is not possible to gather disk metrics via this method?

              • 34. Re: Using PowerCLI to get VM Disk Stats
                LucD Guru
                Community WarriorsUser ModeratorsvExpert

                You should also take into account the Statistics level for the counters for a specific time interval.

                 

                For example, cpu.usage.average requires statistics level 1

                statslvl1.png

                 

                while virtualdisk.write.average requires level 2

                statslvl2.png

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 35. Re: Using PowerCLI to get VM Disk Stats
                  _axel_ Lurker

                  Hi!

                   

                  I've been reading this thread over and over again, and I like it! This NFS-performance-metric-script would do exactly what i've been trying to do for some time now.

                  If I could get it to run ...

                   

                  I've modified it a bit to check other metrics ( I changed entities of "$arrMetrics" to cpu.usage.average and so on), just to see if it's me doing something totally wrong, or if something is just ... not working as it should, and I've noticed that the only performance metrics I can get out of my ESXi hosts are the ones that I can see when i'm doing a "get-stat -Entity myesxihost". And that would be cpu.usage,average,cpu.usagemhz,average, mem.usage.average, disk.usage.average, net.usage.average, and sys.uptime.lastest.

                  When i'm asking for the metrics in the orginial script all I get is :

                   

                  Get-Stat : 2014-02-27 13:17:22    Get-Stat        The metric counter "datastore.totalwritelatency.average" doesn't exist for entity "esxihost.fqdn".

                  At C:\tmp\powercli\nfs_disk_stats.ps1:37 char:18

                  + $stats = Get-Stat <<<<  -Entity $arrHosts -Stat $arrMetrics -Start $today9am.AddDays($intStartDay) -Finish $today5pm.

                  AddDays($intEndDay)

                      + CategoryInfo          : ResourceUnavailable: (datastore.totalwritelatency.average:String) [Get-Stat], VimExcepti

                     on

                      + FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics_MetricDoesntExist,VMware.VimAutomation.

                   

                  ===

                   

                  So am I doing something wrong here? Or is it my installation of vmware that is FUBAR? Or have I just been staring at this code to long to see what's wrong?

                   

                  I'm using vmware 5.5, powershell 2.0 ... and as I have understood it, that should do it... but it doesn't.

                   

                  Best regards

                  /_Axel_

                  • 36. Re: Using PowerCLI to get VM Disk Stats
                    LucD Guru
                    Community WarriorsvExpertUser Moderators

                    From the name of the variable ($arrHosts) it looks as if you are passing ESXi servers to the Get-Stat cmdlet.

                    This metric is only available for VMs, so pass VMs on the Entity parameter.

                    Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                    • 37. Re: Using PowerCLI to get VM Disk Stats
                      _axel_ Lurker

                      Thank you for the quick reply!

                       

                      Yes, I did pass a esxi-host to the get-stat cmdlet, but I get the same errors when i'm running the script.

                      Best regards

                      /_Axel_

                      • 38. Re: Using PowerCLI to get VM Disk Stats
                        LucD Guru
                        vExpertCommunity WarriorsUser Moderators

                        I didn't notice that you were looking for the datastore.totalwritelatency.average counter.

                        That is available for ESXi hosts and VMs.

                         

                        Perhaps you could show how you populated the variables you use in the Get-Stat cmdlet.

                        Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                        • 39. Re: Using PowerCLI to get VM Disk Stats
                          _axel_ Lurker

                          When using the script from this thread, and your post (no#5) i'm populating the variables like this:

                           

                          # Main Variables

                          $sVCentre = "vcenter"      #the vcenter server...

                          $sVCUser = "appropriateusernameforthetask"

                          $sVCPwd = "andthecorrespondingpassword"

                          $strHostWildCard = "*" #all and everything would be fine

                          $strCSVName = "Stats-AvgHostDiskWriteStatsWorkingDay-nfs_disk_stats"

                          $strCSVLocation = "c:\tmp\powercli\stats\"

                          $arrMetrics = "datastore.numberReadAveraged.average","datastore.numberWriteAveraged.average",

                          "datastore.read.average","datastore.write.average","datastore.totalReadLatency.average",

                          "datastore.totalWriteLatency.average"   #this one i'm not doing anything with ...

                           

                          And that's all i'm doing with the script.

                           

                          When i'm using the get-stats cmdlet it looks like this:

                          get-stat -Entity 'esxihost.fq.dn' | get-stats -Stat "datastore.numberReadAveraged.average"

                           

                          And I get the error as stated above. I've tried a few different metrics, and it doesn't matter what I try, besides the stats that are given when i'm doing just Get-stat -Entity 'esxihost.fq.dn'

                           

                          Best regards

                          /_Axel_

                          • 40. Re: Using PowerCLI to get VM Disk Stats
                            LucD Guru
                            Community WarriorsvExpertUser Moderators

                            This line

                            get-stat -Entity 'esxihost.fq.dn' | get-stats -Stat "datastore.numberReadAveraged.average"

                            should be something like this

                            Get-Stat -Entity (Get-VMHost -Name $strHostWildCard) -Stat $arrMetrics -Start $today9am.AddDays($intStartDay) -Finish $today5pm

                            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                            • 41. Re: Using PowerCLI to get VM Disk Stats
                              _axel_ Lurker

                              Tried that one as well, but no luck .

                               

                              What puzzles me is that we're using a small vmware cluster, 4 servers, one nfs-datastore for all of them, the setup isn't uniqe or special in any way, and still I can't get it to work.

                              I've attached the script that i'm using, and a screenshot from part of the output. I'm about to give up.

                               

                              Thanks for all the help! I really appreciate it!

                               

                              Best regards

                              /_Axel_

                              • 42. Re: Using PowerCLI to get VM Disk Stats
                                LucD Guru
                                User ModeratorsvExpertCommunity Warriors

                                Did you already try with my Get-Stat2 function ?

                                See Get NFS performance counters via PowerCLI

                                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                • 43. Re: Using PowerCLI to get VM Disk Stats
                                  clavelstephane Novice

                                  Hello

                                   

                                  Thanks a lot for this script.

                                   

                                  I'm trying to find large vdisks with low iops in our infrastructure. With the script I can find the disks with low iops but I fail to modify it to add disk size (ideally used space).

                                   

                                  How should I do this ?

                                   

                                  thanks

                                  • 44. Re: Using PowerCLI to get VM Disk Stats
                                    LucD Guru
                                    User ModeratorsCommunity WarriorsvExpert

                                    That is the 2nd script in this thread you are talking about, right ?

                                    Note that it is not too obvious to link VMDK to guest OS partitions, or do you mean used space on the VMDK level ?

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