[Xymon] BUG REPORT: double utc correction on windows powershell client

Ribeiro, Glauber glauber.ribeiro at experian.com
Wed Jan 8 17:42:30 CET 2014


(I reported this yesterday. Just cleaning up and changing the subject to make it a bug report.)


In the Powershell client:


Function epochTime assumes a local time and converts it to UTC:


function epochTime([System.DateTime] $t)
{
		[uint32](($t.Ticks - ([DateTime] "1/1/1970 00:00:00").Ticks) / 10000000) - $osinfo.CurrentTimeZone*60

}




But it's being used on times that are already UTC


function XymonFileStat($file,$hash="")
{
...
		"atime:{0} ({1})" -f (epochTime $fh.LastAccessTimeUtc),$fh.LastAccessTime.ToString("yyyy/MM/dd-HH:mm:ss")
		"ctime:{0} ({1})" -f (epochTime $fh.CreationTimeUtc),$fh.CreationTime.ToString("yyyy/MM/dd-HH:mm:ss")
		"mtime:{0} ({1})" -f (epochTime $fh.LastWriteTimeUtc),$fh.LastWriteTime.ToString("yyyy/MM/dd-HH:mm:ss")
...
}




I think the fix is to change the lines above to


		"atime:{0} ({1})" -f (epochTime $fh.LastAccessTime),$fh.LastAccessTime.ToString("yyyy/MM/dd-HH:mm:ss")
		"ctime:{0} ({1})" -f (epochTime $fh.CreationTime),$fh.CreationTime.ToString("yyyy/MM/dd-HH:mm:ss")
		"mtime:{0} ({1})" -f (epochTime $fh.LastWriteTime),$fh.LastWriteTime.ToString("yyyy/MM/dd-HH:mm:ss")



glauber




More information about the Xymon mailing list