Module: check_mk
Branch: master
Commit: 403e5b50a05faa6cef587969c06e800a08fb5e6b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=403e5b50a05faa…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Jul 5 14:37:15 2016 +0200
3153 FIX windows agent: fixed two problems that could cause missing wmi results
The first problem was that under certain circumstances, the first row of each wmi result
was
skipped.
The second problem was, that a wmi section could get disabled if the wmi result is valid
but empty.
---
.werks/3153 | 12 ++++++++++++
ChangeLog | 1 +
agents/windows/Makefile | 2 +-
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1272320 -> 1272320 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 0 -> 10603394 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1272320 -> 1272320 bytes
agents/windows/check_mk_agent.cc | 10 +++++++---
agents/windows/check_mk_agent.exe | Bin 1240576 -> 1240576 bytes
agents/windows/check_mk_agent.msi | Bin 2781696 -> 2781696 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 0 -> 8930198 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1240576 -> 1240576 bytes
agents/windows/install_agent-64.exe | Bin 567258 -> 567256 bytes
agents/windows/install_agent.exe | Bin 560902 -> 561019 bytes
agents/windows/wmiHelper.cc | 11 +++++++----
agents/windows/wmiHelper.h | 4 ++++
16 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/.werks/3153 b/.werks/3153
new file mode 100644
index 0000000..58fe40c
--- /dev/null
+++ b/.werks/3153
@@ -0,0 +1,12 @@
+Title: windows agent: fixed two problems that could cause missing wmi results
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1467721715
+
+The first problem was that under certain circumstances, the first row of each wmi result
was
+skipped.
+The second problem was, that a wmi section could get disabled if the wmi result is valid
but empty.
diff --git a/ChangeLog b/ChangeLog
index c56247d..1da175c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -298,6 +298,7 @@
NOTE: Please refer to the migration notes!
* 3552 FIX: SNMPv3: Fixed login with security level noAuthNoPriv...
* 3694 FIX: fortigate_sessions_base: Added missing WATO rule
+ * 3153 FIX: windows agent: fixed two problems that could cause missing wmi
results...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/agents/windows/Makefile b/agents/windows/Makefile
index a145938..976026e 100644
--- a/agents/windows/Makefile
+++ b/agents/windows/Makefile
@@ -146,7 +146,7 @@ check_mk_agent-64.exe.versioned:
# important: %.exe.versioned must not depend on %.exe.unversioned because on the
# automated build system, "make ...versioned" is called and that system
doesn't
# provide the right compiler to build this agent
-%.exe: %.exe.unversioned %.exe.versioned
+%.exe: %.unversioned.exe %.exe.versioned
true
# -----------------------------------------------------------------------------
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 77de926..ff5a506 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-1767
+1769
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index 6d77af8..69d6980 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unstripped.exe
b/agents/windows/check_mk_agent-64.unstripped.exe
new file mode 100755
index 0000000..61f2e5a
Binary files /dev/null and b/agents/windows/check_mk_agent-64.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index d21d014..84b43c2 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 980db65..db02b01 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -1539,8 +1539,11 @@ void section_logfiles(OutputProxy &out, const Environment
&env) {
}
void dump_wmi_table(OutputProxy &out, wmi::Result &result) {
+ if (!result.valid()) {
+ return;
+ }
out.output("%ls\n", join(result.names(), L",").c_str());
- bool more = result.valid();
+ bool more = true;
while (more) {
std::vector<std::wstring> values = result.names();
// resolve all table keys to their value on this row.
@@ -1565,8 +1568,9 @@ bool output_wmi_table(OutputProxy &out, const wchar_t
*table_name,
}
if (!result.valid()) {
- crash_log("table %ls is empty or doesn't exist", table_name);
- return false;
+ crash_log("table %ls %s", table_name,
+ FAILED(result.last_error()) ? "doesn't exist" : "is
empty");
+ return !FAILED(result.last_error());
}
if (as_subtable) {
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 8172581..5138b1b 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 a1b5970..64f834d 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.unstripped.exe
b/agents/windows/check_mk_agent.unstripped.exe
new file mode 100755
index 0000000..92eb0da
Binary files /dev/null and b/agents/windows/check_mk_agent.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 6e74c04..ea3954c 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 8b48d18..97f787d 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 5744b96..68d4ac4 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ
diff --git a/agents/windows/wmiHelper.cc b/agents/windows/wmiHelper.cc
index 2baa7a4..1fc6219 100644
--- a/agents/windows/wmiHelper.cc
+++ b/agents/windows/wmiHelper.cc
@@ -124,7 +124,9 @@ Result::Result()
: ObjectWrapper(nullptr), _enumerator(nullptr, releaseInterface) {}
Result::Result(const Result &reference)
- : ObjectWrapper(nullptr), _enumerator(reference._enumerator) {}
+ : ObjectWrapper(reference)
+ , _enumerator(reference._enumerator)
+ , _last_error(reference._last_error) {}
Result::Result(IEnumWbemClassObject *enumerator)
: ObjectWrapper(nullptr), _enumerator(enumerator, releaseInterface) {
@@ -145,7 +147,8 @@ Result &Result::operator=(const Result &reference) {
_enumerator->Release();
}
_enumerator = reference._enumerator;
- next();
+ _current = reference._current;
+ _last_error = reference._last_error;
}
return *this;
}
@@ -191,13 +194,13 @@ bool Result::next() {
// in this case the "current" object isn't changed to guarantee
that the
// Result remains valid
// throw ComException("Failed to retrieve element", res);
+ _last_error = res;
return false;
}
if (numReturned == 0) {
// no more values. the current object remains at the last element so
- // that
- // a call to get continues to work
+ // that a call to get continues to work
return false;
}
diff --git a/agents/windows/wmiHelper.h b/agents/windows/wmiHelper.h
index 5abe581..7a9f4cf 100644
--- a/agents/windows/wmiHelper.h
+++ b/agents/windows/wmiHelper.h
@@ -126,6 +126,7 @@ T ObjectWrapper::get(const wchar_t *key) const {
class Result : public ObjectWrapper {
std::shared_ptr<IEnumWbemClassObject> _enumerator{NULL};
+ HRESULT _last_error{S_OK};
public:
Result();
@@ -144,6 +145,9 @@ public:
// stays there.
bool next();
+ // returns the last error that occured during iteration
+ HRESULT last_error() const { return _last_error; }
+
// return true if this is a valid result. Please note that
// once a result is valid it remains so, it doesn't become invalid
// if an error during iteration happens or the last row has been reached.