Module: check_mk
Branch: master
Commit: 2eaced2866a4590fb1792d4e5b8edd868f463026
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2eaced2866a459…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 14 09:47:02 2011 +0100
Windows: fix timestamp computation
---
agents/windows/check_mk.ini | 2 --
agents/windows/check_mk_agent.cc | 11 +++++++----
agents/windows/check_mk_agent.exe | Bin 102912 -> 102912 bytes
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/agents/windows/check_mk.ini b/agents/windows/check_mk.ini
index 5b82eb1..0f94b3d 100644
--- a/agents/windows/check_mk.ini
+++ b/agents/windows/check_mk.ini
@@ -14,7 +14,6 @@
# Just output certain sections (e.g. for upper hosts)
# sections = check_mk plugins df
- sections = fileinfo
[winperf]
@@ -44,4 +43,3 @@
[fileinfo]
# path = C:\Programs\Foo\*.log
# path = M:\Bar Test\*.*
- path = M:\*.*
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 2cc1083..508c9d5 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -288,11 +288,14 @@ double current_time()
return file_time(&filetime);
}
+#define WINDOWS_TICK 10000000
+#define SEC_TO_UNIX_EPOCH 11644473600LL
double file_time(const FILETIME *filetime)
{
- unsigned long long ft = (unsigned long long)(filetime->dwLowDateTime)
- + (((unsigned long long)filetime->dwHighDateTime) << 32);
- return ft / 10000000.0;
+ _ULARGE_INTEGER uli;
+ uli.LowPart = filetime->dwLowDateTime;
+ uli.HighPart = filetime->dwHighDateTime;
+ return double(uli.QuadPart / (double)WINDOWS_TICK - SEC_TO_UNIX_EPOCH);
}
char *lstrip(char *s)
@@ -339,7 +342,7 @@ void char_replace(char what, char into, char *in)
void section_systemtime(SOCKET &out)
{
output(out, "<<<systemtime>>>\n");
- output(out, "%ld\n", time(0));
+ output(out, "%.0f\n", current_time());
}
// .----------------------------------------------------------------------.
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index b912cbd..1a87076 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ