Firstly - this is really a message to LucD (who I know from previous assistance tends to prowl this forum ) , just figured I'd share it, as it's all usefull info and any insight LucD has will no doubt be usefull for all.
yep... obviously you're right...
The last thing... then I'll stop to bother you
How can I cange the time format of the report?
I would like to have the timestamp in the format of h24 instead of h12...
I mean:
now: 23/04/2012 01:00
to be: 23/04/2012 13:00
Thanks
V.
Change this line
Timestamp = ($oentry.Timestamp).toString('dd/MM/yyyy hh:mm')
into this
Timestamp = ($oentry.Timestamp).toString('dd/MM/yyyy HH:mm')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PERFECT!!!!
Thank you very much LucD.
you're awesome :smileygrin:
Great script indeed !
One thing I'm struggling with, is the output.
This script has an output looking like:
Entity | Instance | MetricId | Value |
MyVM | xyz.12345e8069872a000000963d00008015 | disk.numberwrite.summation | 7 |
MyVM | xyz.12345e8069872a000000963d00008012 | disk.numberwrite.summation | 0 |
Is there a way to get an output with instances and values per line:
Entity | Instance 1 | Instance 2 | disk.numberwrite.summation 1 | disk.numberwrite.summation 2 |
MyVM | xyz.12345e8069872a000000963d00008015 | xyz.12345e8069872a000000963d00008012 | 7 | 0 |
I saw in other scripts from LucD, for example for the Network Statistics per VM, http://www.lucd.info/2012/04/21/vnic-transmit-and-receive-rates/ that he succeeds to output with values in line (not in columns) but I'm not so gifted with scripting...
Any hint would be greatly appreciated.
This info is great. I used the above script from LucD and tonygent. I'm just starting with PS and PowerCLI, and trying to figure out how to get some things out of my environment. Wanted to note a couple things that I had trouble with:
I'm going to be taking the CSV data from the script and using it to generate usage graphs of VM IOPS to use to evaluate storage expansion options.
Thanks everyone! Any suggestions or thoughts would be helpful. I hope my notes will help some other PowerCLI noobs!
You need to understand how vSphere handles performance data.
Have a look at my PowerCLI & vSphere statistics – Part 1 – The basics, there I try to explain the different intervals that exist and how the aggregation takes places.
You can use the Windows Task Scheduler to run your scripts.
See Alan's Running a PowerCLI Scheduled task post.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
although this is a very old topic, I hope someone can answer me here as well.
I want to extract the following statistics for a definite time in the past (like last November). Is this possible with PowerCLI?
Average CPU utilization |
Peak CPU utilization |
Average Memory utilization |
Peak Memory utilization |
allocated disc storage |
used disc storage |
Thanks in advance!
Yes, by manipulating the Start and Finish parameters on the Get-Stat cmdlet you can do this.
But it will depend on the statistics level you have defined for that time interval which metrics will be available.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great, I did some tests and get the average CPU usage for a VM.
However I want to have the disk statistics as well and it tells me the following:
Get-Stat -entity vm -start 01/31/2014 -finish 02/01/2014 -disk -MaxSamples 1
Get-Stat : 2/10/2014 3:10:37 PM Get-Stat Object reference not set to an instance of an object.
At line:1 char:9
+ get-stat <<<< -entity vm -start 01/31/2014 -finish 02/01/2014 -disk -MaxSamples 1
+ CategoryInfo : NotSpecified: (:) [Get-Stat], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio n.ViCore.Cmdlets.Commands.GetViStats
The VM is powered on for a while (for weeks at least).
I also want to know what kind of metrics are available and how can I query them (like the peak CPU utilization of a VM).
Thanks!
That error is most of the time caused by a VM that was not powered on at the Start of the interval you specify on the Get-Stat cmdlet.
You can skip such VMs, by adding -ErrorAction SilentlyContinue on the Get-Stat cmdlet.
All available counters are described on the PerformanceManager page in the API Reference.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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...
Do you see metrics for that VM under the Performance tab for that period ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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)
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?
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
while virtualdisk.write.average requires level 2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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_
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: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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_
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: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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_