hi - i am running a script against a vcentre hosted in France that contains all the Hosts for our european sites. The variables relating to date are as follows ...
$date = get-date
$todaymidnight = get-date -hour 0 -minute -0 -second -0
$start = $todaymidnight.adddays(-1).addseconds(1)
$finish = $todaymidnight
I am running a script to get some performance metrics as follows. The odd thing is if i run it on a vcentre in the uk it works fine. If i run it against the paris vcentre i get no information at all. If i change the $date to get-date -UFormat "%d/ %m/ %Y %T" i get some information back for some countries and not others
Ther line that is not working correctly is ... $stats = get-stat -Entity $esx -Stat $metrics -Start $start -Finish $Finish
I guess i need to normalise the dates somehow - how can i achieve this ?
"Normalizing" dates (UTC<->Local time conversion) is automatically handled by the get-stat cmdlet.
So lets see what causes the issue:
1. Please make sure that the server time is correct:
Login to sever and check the time. You can configure a NTP server to make sure that the time is correct.
2. Check if a problem with localizing time exists
Run with specified "Realtime" parameter. The samples returned should be maximul 5 min away from the current moment.
3. Check if the counter that you are requesting is available in the specified time frame
Use Get-StatType cmdlet.
hi nedko - here is some more information - i hope it makes sense 😉
the scenarios are as follows ...
if i am connected to my paris vcentre and do the following ..
Get-Stat -Entity vmxxx.xx.xx.xx -Stat $metrics -Start $start.tolocaltime()
I get a statistical entry every 20 seconds (therefore realtime stat reporting starting from one hour ago)
If i am connected to my London vcentre and do the same i get a satistic for every 30 minutes from 12.30am 3april2011 to 12am 4th april2011 (- this is correct as i am trying to extract the stats from midnight-midnight the previous day
So going by the fact i get a statistic for every 20 seconds when connected to my paris vcentre i can only assume the dates are getting mixed up as i would expect to see those stats if extracting stats from within the last 24 hours, which is not what i want (as mentioned previously it is the stats for the previous day i am interested in)
If i add -Finish to the line (so $stats = Get-Stat -Entity $esximpl -Stat $metrics -Start $start.tolocaltime() -Finish $finish.ToLocalTime())
for london vcentre i get stats for every 30 minutes as above (which is correct), if i am connected to my paris vcentre i get no statistics returned at all (obviously not correct ;-))
So to summarise - same script run against 2 vcentres - when connecting to a paris vcentre gives me stats every 20seconds for the previous hour (so assuming realtime), when connected to london vcentre gives me stats every 30 minutes from midnight to midnight the previous day which is what i want
i have attached the script to maybe clarify a bit further
hi luc - thanks for the response - didnt work as expected
i have attached the script in the response to nedko - maybe if you get a moment you could take a look to see if i have missed anything
Everything in your scripts looks good to me.
Please folow the steps in my previous post and report the result here.
Possible cause 1: The VC database can be currupted.
To confirm: Specify "-IntervalSecs 300" with no Start/End parameters and see if you can find any samples in the desired time frame.
Notes: The cmdlet Get-Stat analyzes the available data and returns the most detailed information available for the specified interval. If no data exist for the whole interval it changes the sampling rate to find any samples. I believe it changed sampling rate to 20s because it didn't find information for the other sampling rates.
Possible cause 2: The performance counter didn't exist for the specified interval
To confirm: Use Get-StatType and see if it returns any counters for the interval.