Module: check_mk
Branch: master
Commit: fd413348568153de8ad60fea8aa1be5f8b509901
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fd413348568153…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Apr 28 10:55:30 2015 +0200
2071 fix: windows agent: fileinfo check now correctly reports empty directories
---
.werks/2071 | 12 ++++++++++++
ChangeLog | 1 +
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent.cc | 15 +++++++++++----
agents/windows/check_mk_agent.exe | Bin 181760 -> 181760 bytes
agents/windows/check_mk_agent.msi | Bin 730112 -> 730112 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 181760 -> 181760 bytes
agents/windows/install_agent-64.exe | Bin 177836 -> 177835 bytes
agents/windows/install_agent.exe | Bin 158872 -> 158921 bytes
9 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/.werks/2071 b/.werks/2071
new file mode 100644
index 0000000..13043a2
--- /dev/null
+++ b/.werks/2071
@@ -0,0 +1,12 @@
+Title: windows agent: fileinfo check now correctly reports empty directories
+Level: 2
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1430210905
+
+The fileinfo check did not report any data in case the directory
+in question exists but did not contain any files.
+
diff --git a/ChangeLog b/ChangeLog
index 9babfb8..8a0ed7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -347,6 +347,7 @@
* 1243 FIX: mk_postgres: Prevent loading of .psqlrc...
* 2234 FIX: AIX Agent: Forced load of environment and fixed call of trd (Libelle
Business Shadow)...
* 2247 FIX: ibm_svc_mdiskgrp: Made check working with different firmware versions
outputs
+ * 2071 FIX: windows agent: fileinfo check now correctly reports empty directories...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 897bdc8..dee261d 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-139
+140
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 3b2c576..3d6a090 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -2560,7 +2560,7 @@ void section_mem(SOCKET &out)
// '-----------------------------------------------------------------------'
void output_fileinfos(SOCKET &out, const char *path);
-void output_fileinfo(SOCKET &out, const char *basename, WIN32_FIND_DATA *data);
+bool output_fileinfo(SOCKET &out, const char *basename, WIN32_FIND_DATA *data);
void section_fileinfo(SOCKET &out)
{
@@ -2577,6 +2577,8 @@ void output_fileinfos(SOCKET &out, const char *path)
{
WIN32_FIND_DATA data;
HANDLE h = FindFirstFileEx(path, FindExInfoStandard, &data,
FindExSearchNameMatch, NULL, 0);
+ bool found_file = false;
+
if (h != INVALID_HANDLE_VALUE) {
// compute basename of path: search backwards for '\'
const char *basename = "";
@@ -2585,12 +2587,15 @@ void output_fileinfos(SOCKET &out, const char *path)
*end = 0;
basename = path;
}
- output_fileinfo(out, basename, &data);
+ found_file = output_fileinfo(out, basename, &data);
while (FindNextFile(h, &data))
- output_fileinfo(out, basename, &data);
+ found_file = output_fileinfo(out, basename, &data) || found_file;
if (end)
*end = '\\'; // repair string
FindClose(h);
+
+ if (!found_file)
+ output(out, "%s|missing|%d\n", path, current_time());
}
else {
DWORD e = GetLastError();
@@ -2599,7 +2604,7 @@ void output_fileinfos(SOCKET &out, const char *path)
}
-void output_fileinfo(SOCKET &out, const char *basename, WIN32_FIND_DATA *data)
+bool output_fileinfo(SOCKET &out, const char *basename, WIN32_FIND_DATA *data)
{
unsigned long long size = (unsigned long long)data->nFileSizeLow
+ (((unsigned long long)data->nFileSizeHigh) << 32);
@@ -2607,7 +2612,9 @@ void output_fileinfo(SOCKET &out, const char *basename,
WIN32_FIND_DATA *data)
if (0 == (data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
output(out, "%s\\%s|%llu|%.0f\n", basename,
data->cFileName, size, file_time(&data->ftLastWriteTime));
+ return true;
}
+ return false;
}
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 5d33379..30aecce 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 9402311..bdde1ea 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 8f5fab4..6b2b57e 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index 8df5e16..80efe14 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 0024f6c..b83ae28 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ