Module: check_mk
Branch: master
Commit: 5785a211ab0bbb31ea762d63aed686c15235c25b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5785a211ab0bbb…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Sep 3 15:55:27 2015 +0200
#2570 FIX winperf_msx_queues: fixed crash when winperf data is missing
---
.werks/2570 | 13 +++++++++++++
ChangeLog | 1 +
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 307712 -> 307712 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 307712 -> 307712 bytes
agents/windows/check_mk_agent.cc | 18 ++++++++++++++++--
agents/windows/check_mk_agent.exe | Bin 190464 -> 190976 bytes
agents/windows/check_mk_agent.msi | Bin 747008 -> 747520 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 190464 -> 190976 bytes
agents/windows/install_agent-64.exe | Bin 181024 -> 181093 bytes
agents/windows/install_agent.exe | Bin 163072 -> 163075 bytes
checks/winperf_msx_queues | 7 ++++---
12 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/.werks/2570 b/.werks/2570
new file mode 100644
index 0000000..9516b57
--- /dev/null
+++ b/.werks/2570
@@ -0,0 +1,13 @@
+Title: winperf_msx_queues: fixed crash when winperf data is missing
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1441287640
+
+Previously the windows agent would return empty sections if it couldn't retrieve
performance data.
+The winperf_msx_queues check responded to this empty section by crashing.
+This has been fixed by making sure the agent doesn't return empty winperf sections
and by making the
+check handle empty sections gracefully
diff --git a/ChangeLog b/ChangeLog
index 9126678..730017f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -166,6 +166,7 @@
* 1290 FIX: brocade_mlx_fan: Fix: Not longer add fans who not are present while
discovery
* 2569 FIX: fixed crash in aix lvm check after volume disappears...
* 2559 FIX: job: Trying to read job result files as non root when agent is not
executed as root
+ * 2570 FIX: winperf_msx_queues: fixed crash when winperf data is missing...
Multisite:
* 2385 SEC: Fixed possible reflected XSS on all GUI pages where users can produce
unhandled exceptions...
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 0d38910..9d683f8 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-212
+214
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index ad4a729..2d32de7 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.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index e76e106..646279a 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 68117b5..e8b21f6 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -868,10 +868,8 @@ void outputCounterValue(SOCKET &out, PERF_COUNTER_DEFINITION
*counterPtr, PERF_C
void dump_performance_counters(SOCKET &out, unsigned counter_base_number, const char
*countername)
{
crash_log("<<<winperf_%s>>>", countername);
- output(out, "<<<winperf_%s>>>\n", countername);
static LARGE_INTEGER Frequency;
QueryPerformanceFrequency (&Frequency);
- output(out, "%.2f %u %lu\n", current_time(), counter_base_number,
Frequency.QuadPart);
// registry entry is ascii representation of counter index
char counter_index_name[8];
@@ -912,6 +910,10 @@ void dump_performance_counters(SOCKET &out, unsigned
counter_base_number, const
// Determine first object in list of objects
PERF_OBJECT_TYPE *objectPtr = FirstObject(dataBlockPtr);
+ // awkward way to ensure we really really only create the section header if there
+ // are performance counters
+ bool first_counter = true;
+
// Now walk through the list of objects. The bad news is:
// even if we expect only one object, windows might send
// us more than one object. We need to scan a list of objects
@@ -939,6 +941,12 @@ void dump_performance_counters(SOCKET &out, unsigned
counter_base_number, const
int num_instances = objectPtr->NumInstances;
if (num_instances >= 0)
{
+ if (first_counter) {
+ output(out, "<<<winperf_%s>>>\n",
countername);
+ output(out, "%.2f %u %lu\n", current_time(),
counter_base_number, Frequency.QuadPart);
+ first_counter = false;
+ }
+
output(out, "%d instances:", num_instances);
char name[512];
PERF_INSTANCE_DEFINITION *instancePtr = FirstInstance(objectPtr);
@@ -957,6 +965,12 @@ void dump_performance_counters(SOCKET &out, unsigned
counter_base_number, const
output(out, "\n");
}
+ if (first_counter && (objectPtr->NumCounters > 0)) {
+ output(out, "<<<winperf_%s>>>\n",
countername);
+ output(out, "%.2f %u %lu\n", current_time(),
counter_base_number, Frequency.QuadPart);
+ first_counter = false;
+ }
+
// Now walk through the counter list a second time and output all counters
for (unsigned int b=0 ; b < objectPtr->NumCounters ; b++)
{
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index abcdca8..613f67a 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 b2d29c7..80c1f89 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 27818a3..6a1db6e 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 0cfb47f..57f32ba 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 e08b52f..5524f41 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ
diff --git a/checks/winperf_msx_queues b/checks/winperf_msx_queues
index a770572..3e2ba1c 100644
--- a/checks/winperf_msx_queues
+++ b/checks/winperf_msx_queues
@@ -89,9 +89,10 @@ def inventory_winperf_msx_queues(info):
return [ (name, { "offset" : offset } ) for name, offset in
queues.items() ]
def check_winperf_msx_queues(item, params, info):
- num_instances = int(info[1][0])
- if num_instances < 1:
- return (3, "no counters available, transport service running?")
+ # current windows agents should not produce winperf sections with no data after the
header but
+ # this ensures compatibility with older agents
+ if len(info) < 2 or int(info[1][0]):
+ return 3, "no counters available, transport service running?"
# Old default case:
if type(params) == tuple: