BBWin V.12 filesystem epoch time and local time conflict

Kauffman, Tom KauffmanT at nibco.com
Tue Jun 24 19:36:21 CEST 2008


I think you're looking for something that doesn't exist, unless the windows epoch handling is non-posix. In the Unix/posix environment, the epoch is always UTC and the conversion to local time-zone value occurs as part of the time formatting - there's no such animal as 'local epoch'. I'd look at the system returning these values and make sure the time zone is set correctly.

Tom

-----Original Message-----
From: McGraw, Robert P [mailto:rmcgraw at purdue.edu]
Sent: Tuesday, June 24, 2008 11:46 AM
To: hobbit at hswn.dk
Subject: [hobbit] RE: BBWin V.12 filesystem epoch time and local time conflict



A little more digging and I see


> -----Original Message-----
> From: McGraw, Robert P
> Sent: Tuesday, June 24, 2008 10:40 AM
> To: 'hobbit at hswn.dk'; 'bbwin-users at lists.sourceforge.net'
> Subject: BBWin V.12 filesystem epoch time and local time conflict
>
> I have the [file:] set up in central mode on our BBWin V.12 client and it
> returns the following client data to the Hobbit server.
>
>       [file:c:\Alligate\AAATEST]
>       type:0x00020 (file)
>       mode:777 (not implemented)
>       linkcount:1
>       owner:0 (not implemented)
>       group:0 (not implemented)
>       size:0
>       atime:1214222069 (2008/06/23-11:54:29)
>       ctime:1213796626 (2008/06/18-13:43:46)
>       mtime:1214222069 (2008/06/23-11:54:29)
>
> On my hobbit server hobbit-clients.cfg I have
>
>       FILE c:\Alligate\AAATEST red MTIME<88200
>
> The YYYY/MM/DD-HH:MM:SS atime, ctime and mtime are local time.
>
> During testing I noticed that the red icon would come on before I had
> expected.
>
> I decided to do a little checking and using a web epoch time calculator.
>
> If I enter 2008/06/23-11:54:29 it returns the epoch time of 1214236469,
> which
> does not match mtime epoch time above.
>
> If I enter the epoch mtime 1214222069 I get Mon Jun 23 2008 07:54:29
> GMT-0400 (EDT) which does not match the date.
>
> If I enter epoch time 1214236469 I get Mon Jun 23 2008 11:54:29 GMT-0400
> (EDT)
>
> It seems that the YYYY/MM/DD-HH:MM:SS time is reported in local time and
> the
> epoch time is reported in GMT time which throws things off by four hours.
>
>
> The following is the code in filesystem
>
>   325         reportData << format("type:0x%05x ") %
> handle_file_info.dwFileAttributes;
>   326         if (handle_file_info.dwFileAttributes &
> FILE_ATTRIBUTE_DIRECTORY)
>   327                 reportData << "(dir)" << endl;
>   328         else
>   329                 reportData << "(file)" << endl;
>   330         reportData << "mode:777 (not implemented)" << endl;
>   331         reportData << format("linkcount:%u") %
> handle_file_info.nNumberOfLinks
> << endl;
>   332         reportData << "owner:0 (not implemented)" << endl;
>   333         reportData << "group:0 (not implemented)" << endl;
>   334         reportData << format("size:%lu") % fsize << endl;
>   335         string output;
>   336         GetTimeString(handle_file_info.ftLastAccessTime, output);
>   337         reportData << "atime:" << output << endl;
>   338         GetTimeString(handle_file_info.ftCreationTime, output);
>   339         reportData << "ctime:" << output << endl;
>   340         GetTimeString(handle_file_info.ftLastWriteTime, output);
>   341         reportData << "mtime:" << output << endl;
>   342         fclose(f);
>   343         return true;

GetTimeString is a function in the filesystem code which follows.

bool            AgentFileSystem::GetTimeString(const FILETIME & filetime,
string & output) {
  255   __int64 ftime = (filetime.dwHighDateTime * MAXDWORD) +
filetime.dwLowDateTime;
  256   SYSTEMTIME      fsystime;
  257   FILETIME        floctime;
  258   time_t          epoch;
  259
  260   if (::FileTimeToLocalFileTime(&filetime, &floctime) == 0) {
  261           return false;
  262   }
  263   if (::FileTimeToSystemTime(&floctime, &fsystime) == 0) {
  264           return false;
  265   }
  266   utils::SystemTimeToTime_t(&fsystime, &epoch);
  267   stringstream reportData;
  268   reportData << format("%llu (%02d/%02d/%d-%02d:%02d:%02d)")
  269                                   % (unsigned __int64)epoch
  270                                   % fsystime.wYear
  271                                   % fsystime.wMonth
  272                                   % fsystime.wDay
  273                                   % fsystime.wHour
  274                                   % fsystime.wMinute
  275                                   % fsystime.wSecond;
  276   output = reportData.str();
  277   return true;
  278 }

It seems to me that after line 266 there needs to be a couple lines that
converts the GMT epoch to local epoch.



>
>
> The function GetTimeString seems to be the code that is returning the time
> information. I have not been able to find this code in the BBWin svn so I
> am
> not sure if this is a local function or a system function.
>
> I am not a Window type guy and no very little about such things. Can a
> super
> duper window type person peruse this and see what they can find.
>
> Tanks
>
>
>
> Thanks
>
> Robert
>
>
>
>
>
> --------------------------------------------------------------------
> Robert P. McGraw, Jr.
> Manager, Computer System                 EMAIL: rmcgraw at purdue.edu
> Purdue University                         ROOM: MATH-807
> Department of Mathematics                PHONE: (765) 494-6055
> 150 N. University Street
> West Lafayette, IN 47907-2067

CONFIDENTIALITY NOTICE:  This email and any attachments are for the 
exclusive and confidential use of the intended recipient.  If you are not
the intended recipient, please do not read, distribute or take action in 
reliance upon this message. If you have received this in error, please 
notify us immediately by return email and promptly delete this message 
and its attachments from your computer system. We do not waive  
attorney-client or work product privilege by the transmission of this
message.




More information about the Xymon mailing list