MattHodge / Graphite-PowerShell-Functions

A group of PowerShell functions that allow you to send Windows Performance counters to a Graphite Server, all configurable from a simple XML file.
https://hodgkins.io/using-powershell-to-send-metrics-graphite
GNU General Public License v3.0
218 stars 71 forks source link

timezone / standardname vs daylightname #26

Closed stevewhiting closed 9 years ago

stevewhiting commented 9 years ago

Matt, thanks a lot for your work on this. Hugely helpful.

I ran into an issue where my systems were reporting metrics an hour in the future to graphite. Being the deep thinker I am, I just subtracted an hour:

 $UnixTime = ($UnixTime - 3600);

In the middle of setting this up on some systems, I noticed that this reports "PST" even though we're currently in daylight savings time:

PS C:\WINDOWS\system32> [System.TimeZoneInfo]::LOCAL.id
Pacific Standard Time

So, I removed my subtract-an-hour solution and added this to determine my local timezone instead:

# determine if we're in dst
$wmisys = get-wmiobject "Win32_ComputerSystem"
$dst = $wmisys.DaylightInEffect
if ($dst -eq 'True') {
     $LocalTimeZone = [TimeZone]::CurrentTimeZone.daylightname
}
else {
     $LocalTimeZone = [TimeZone]::CurrentTimeZone.standardname
}

Its now "working", and my metrics show up correctly in graphite. Am I completely off track with this?

ghostsquad commented 9 years ago

It might be better to send UTC times to graphite, and ignore timezones entirely.

stevewhiting commented 9 years ago

Perfect, thanks for the update.