Hi evryone,
My script for Performance Statistics give some errors:
I get now these erros then I run the script against only upgraded vCenter from version 5.5 to 6.0.0
Running the script against vCenter version 5.5 is totally ok.
I started to debug the Metrics for vCenter 6.0 and found these Metrics for entity "my vm [Obfuscated] ":
Get-StatType -Entity "my vm [Obfuscated] " -Start $StartTime | Sort-Object -Unique
cpu.cpuentitlement.latest
cpu.ready.summation
cpu.usage.average
cpu.usagemhz.average
disk.maxTotalLatency.latest
disk.provisioned.latest
disk.unshared.latest
disk.usage.average
disk.used.latest
mem.consumed.average
mem.mementitlement.latest
mem.overhead.average
mem.swapinRate.average
mem.swapoutRate.average
mem.usage.average
mem.vmmemctl.average
net.usage.average
sys.uptime.latest
My script contain these Metrics in a variable
$metrics = "cpu.usage.average", `
"cpu.usagemhz.average", `
"mem.usage.average", `
"mem.consumed.average", `
"disk.usage.average", `
"disk.maxTotalLatency.latest", `
"net.usage.average", `
"sys.uptime.latest"
My command in script:
$vms = "my vm [Obfuscated] "
$StartTime = "05.02.2019 08:53:57"
$EndTime = "20.02.2019 13:53:57"
$intervall = "*"
$metrics = "cpu.usage.average", `
"cpu.usagemhz.average", `
"mem.usage.average", `
"mem.consumed.average", `
"disk.usage.average", `
"disk.maxTotalLatency.latest", `
"net.usage.average", `
"sys.uptime.latest"
get-stat -Entity $vms -Stat $metrics -Start $StartTime -Finish $EndTime -IntervalSecs $intervall
We did not change the level value for Performance Statistics, the value is still 1.
Could anyone advise me to solve this problem?
Thanks and regards
Denis
First, does it return the data?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, your script return data.
Try the attached version, I added a Server parameter, which allows you to pick a specific vCenter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
New script with parameter -server work fine when only one connection vCenter is in place. (collecting data is OK)
With two vCenter connections I get an error:
Exception calling "QueryAvailablePerfMetric" with "4" argument(s): "A specified parameter was not
correct: entity"
At D:\vCenter_Reporting\Get-Stat2.ps1:154 char:5
+ $metricId = $perfMgr.QueryAvailablePerfMetric($Entity.MoRef,$null ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
-Instance parameter invalid for requested stat: cpu.usage.average.
Valid values are:
At D:\vCenter_Reporting\Get-Stat2.ps1:180 char:9
+ Throw "-Instance parameter invalid for requested stat: $st.`n ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (-Instance param...id values are: :String) [], Runt
imeException
+ FullyQualifiedErrorId : -Instance parameter invalid for requested stat: cpu.usage.average.
Valid values are:
Try replacing this line
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, it's work without error!
another problem with date!
I added -start and -finish...
Get-Stat2 : Cannot process argument transformation on parameter 'Finish'. Cannot convert value
"20.02.2019 13:53:57" to type "System.DateTime". Error: "String was not recognized as a valid
DateTime."
At C:\Users\a80710058\AppData\Local\Temp\Untitled175.ps1:94 char:64
+ ... -Entity $vm -Stat $metrics -Start $StartTime -Finish $EndTime -Interv ...
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Stat2], ParameterBindingArgumentTransformationE
xception
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-Stat2
This is most probably due to your regional settings.
What does this show?
(Get-Culture).DateTimeFormat
You can in fact use any format, but then you have to tell how to parse it.
[datetime]::ParseExact("20.02.2019 13:53:57", 'dd.MM.yyyy HH:mm:ss', $null)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
My variables
$StartTime = "05.02.2019 08:53:57"
$EndTime = "20.02.2019 13:53:57"
(Get-Culture).DateTimeFormat
AMDesignator : vorm.
Calendar : System.Globalization.GregorianCalendar
DateSeparator : .
FirstDayOfWeek : Monday
CalendarWeekRule : FirstFourDayWeek
FullDateTimePattern : dddd, d. MMMM yyyy HH:mm:ss
LongDatePattern : dddd, d. MMMM yyyy
LongTimePattern : HH:mm:ss
MonthDayPattern : d. MMMM
PMDesignator : nachm.
RFC1123Pattern : ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ShortDatePattern : dd.MM.yyyy
ShortTimePattern : HH:mm
SortableDateTimePattern : yyyy'-'MM'-'dd'T'HH':'mm':'ss
TimeSeparator : :
UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z'
YearMonthPattern : MMMM yyyy
AbbreviatedDayNames : {So., Mo., Di., Mi....}
ShortestDayNames : {So., Mo., Di., Mi....}
DayNames : {Sonntag, Montag, Dienstag, Mittwoch...}
AbbreviatedMonthNames : {Jan, Feb, Mär, Apr...}
MonthNames : {Januar, Februar, März, April...}
IsReadOnly : False
NativeCalendarName : Gregorianischer Kalender
AbbreviatedMonthGenitiveNames : {Jan., Feb., März, Apr....}
MonthGenitiveNames : {Januar, Februar, März, April...}
Did you try the ParseExact?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
using [datetime]::ParseExact("20.02.2019 13:53:57", 'dd.MM.yyyy HH:mm:ss', $null)
$StartTime = "05.02.2019 08:53:57"
$EndTime = "20.02.2019 13:53:57"
$StartTime = [datetime]::ParseExact($StartTime, 'dd.MM.yyyy HH:mm:ss', $null)
$EndTime = [datetime]::ParseExact($EndTime, 'dd.MM.yyyy HH:mm:ss', $null)
$StartTime
Dienstag, 5. Februar 2019 08:53:57
Our vCenter date setting are:
date
The current date is: 26.02.2019
Time
The current time is: 14:06:20.67
Do you still get the error when you pass the the StartTime and EndTime variables on the Start and Finish parameters when calling Get-Stat2?
It looks like the casting of the string to a DateTime object has any issue with the format.
So convert the strings to DataTime objects before making the call to the Get-Stat2 function.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I did this way:
$StartTime = "05.02.2019 08:53:57"
$EndTime = "20.02.2019 13:53:57"
$StartTime = [datetime]::ParseExact($StartTime, 'dd.MM.yyyy HH:mm:ss', $null)
$EndTime = [datetime]::ParseExact($EndTime, 'dd.MM.yyyy HH:mm:ss', $null)
Get-Stat2 -server $vc -Entity $vm.Extensiondata -Stat $metrics -Start $StartTime -Finish $EndTime -Interval "RT"
get no error and no data!!!
The RT interval (RealTime) is only for the last hour, you should use HI3 with those Start and Finish times.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
With HI3 is OK.
I'll be back tomorrow for more details about integrating your script into my app.
get-stat2 against vCenter 5.5 produced this error:
Exception calling "QueryAvailablePerfMetric" with "4" argument(s): "A
specified parameter was not correct: entity"
At D:\vCenter_Reporting\Get-Stat2.ps1:154 char:5
+ $metricId = $perfMgr.QueryAvailablePerfMetric($Entity.MoRef,$null ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationExceptio
n
+ FullyQualifiedErrorId : VimException
-Instance parameter invalid for requested stat: cpu.usage.average.
Valid values are:
At D:\vCenter_Reporting\Get-Stat2.ps1:180 char:9
+ Throw "-Instance parameter invalid for requested stat: $st.`n ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (-Instance param...id values
are: :String) [], RuntimeException
+ FullyQualifiedErrorId : -Instance parameter invalid for requested stat
: cpu.usage.average.
Valid values are:
I don't have a 5.5 available (it's unsupported since last year), but it looks like the VM doesn't have statistical data at the start of the interval you requested.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not a problem I will use get-stat for this environment till it will be megrated.
In my App for statisitcis I use a form where the user can select with two calendar the start date and end date and
the type of statistics Large, Medium and Small, the value are: Large( if Null) = "*" , Medium = "1800" , Small = "7200".
What is the correpondance for the new value in get-stat2, RT, (HI1), HI2, HI3, HI4.
I need to know where it will be a conflict between a range of temp and the selected intervall.
get-stat2 CounterName is named Metrics in get-stat.
Maybe changing the name in the query is the easy way for me.
Finally, we see your function work properly with our environment vCenter 6.0.
What can we do with get-stat? oppening an incident or not?
For Medium and SMall, the intervals (1800 and 7200) correspond respectively with HI2 and HI3.
For Large I'm not sure what you mean by the '*' value, that is normally used for the Instance parameter.
Correct CounterName is the same as Metric.
You pass the required metrics via the Stat parameter.
Yes, I would suggest to open a SR for the issue with Get-Stat on vSphere 6.0.
If GSS claims you need a Developer Support Contract to open calls for PowerCLI, point them to PowerCLI Support Breakdown.
You don't need a Developer contract when the issue is obviously a bug in a cmdlet, and not in your script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your explanation
With -Intervlsecs "*" I got the all statistics that are present without taking care to the interval temp.
Did we have a switch with get-stat2 to do the same?
I'll try again with VMware, hope it will not be difficult as for the other Case (port 7444) !