Module: check_mk
Branch: master
Commit: 3e8a9cad65353dead209395f0b357f6fe71cfafc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3e8a9cad65353d…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Wed Dec 6 10:38:36 2017 +0100
Windows agent: use RAII for event handles
More precisely, use the Resource Release is Finalization principle as
the handles cannot be always acquired in a uniform way in a constructor
due to the various ways handles can be acquired/opened through WinAPI.
Wrap handles related to eventlog handling in instances of classes
responsible for releasing the resources (alias closing the handles in
this case). Specialize based wrapper class through handle-specific
traits classes for handle type, invalid value as well as closing the
handle.
Do not wrap wrapper classes further to unique_ptr's etc when. there is no
need for heap allocation of the wrapper object.
Also refactor the eventlog handling in order to get rid of unnecessary
resetting.
Add unit tests for handle wrappers.
Change-Id: Iacd6e245d5e55b6276f3ce3509ea6679103e7e8b
---
agents/windows/EventLog.cc | 92 ++++-----
agents/windows/EventLog.h | 84 ++------
agents/windows/EventLogVista.cc | 184 +++++++++---------
agents/windows/EventLogVista.h | 76 ++------
agents/windows/IEventLog.h | 15 +-
agents/windows/Makefile.am | 3 +
agents/windows/build_version | 2 +-
agents/windows/sections/SectionEventlog.cc | 1 -
agents/windows/test/EnvironmentTest.cc | 3 -
agents/windows/test/EventLogVistaTest.cc | 107 +++++++++++
agents/windows/test/MockWbem.h | 2 +-
agents/windows/test/typesTest.cc | 295 +++++++++++++++++++++++++++++
agents/windows/test/wmiHelperTest.cc | 12 +-
agents/windows/types.h | 122 ++++++++++--
14 files changed, 691 insertions(+), 307 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=3e8a9cad65…
Module: check_mk
Branch: master
Commit: 9702d6169071e6a9c8a4d85361dcc72b666da923
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9702d6169071e6…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Dec 12 08:38:53 2017 +0100
The number of RRD write threads is an integer, not an age.
Change-Id: I5f21ba78cd195057aa4e48fd3579748f21e2e878
---
web/plugins/wato/omd_configuration.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/web/plugins/wato/omd_configuration.py b/web/plugins/wato/omd_configuration.py
index 45556f5..6933ad5 100644
--- a/web/plugins/wato/omd_configuration.py
+++ b/web/plugins/wato/omd_configuration.py
@@ -531,12 +531,13 @@ register_configvar(group,
"acceptable in most cases."),
minvalue = 0,
)),
- ("WRITE_THREADS", Age(
+ ("WRITE_THREADS", Integer(
title = _("Number of threads used for writing RRD files"),
help = _("Increasing this number will allow rrdcached to have more simultaneous "
"I/O requests into the kernel. This may allow the kernel to re-order "
"disk writes, resulting in better disk throughput."),
minvalue = 1,
+ maxvalue = 100
)),
],
optional_keys = [],
Module: check_mk
Branch: master
Commit: f253e7bd86f45e787b72164289ad2ea5055e4d67
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f253e7bd86f45e…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Dec 11 12:02:10 2017 +0100
Made counter for active Livestatus connections atomic.
We have seen Livestatus usage >100% out in the wild, which is total
nonsense. This commit is trying to fix this, but there could be other
problems: We really, really have to introduce memory barriers and locks in
Livestatus, the current code is simply wrong in this respect.
Change-Id: Ie063ef2b4ff0dc78d1a05159d320d452d9e7e9bc
---
livestatus/src/AtomicInt32PointerColumn.h | 48 +++++++++++++++++++++++++++++++
livestatus/src/TableStatus.cc | 6 ++--
livestatus/src/module.cc | 3 +-
3 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/livestatus/src/AtomicInt32PointerColumn.h b/livestatus/src/AtomicInt32PointerColumn.h
new file mode 100644
index 0000000..42fd34c
--- /dev/null
+++ b/livestatus/src/AtomicInt32PointerColumn.h
@@ -0,0 +1,48 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+// +------------------------------------------------------------------+
+//
+// This file is part of Check_MK.
+// The official homepage is at http://mathias-kettner.de/check_mk.
+//
+// check_mk is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation in version 2. check_mk is distributed
+// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+// PARTICULAR PURPOSE. See the GNU General Public License for more de-
+// tails. You should have received a copy of the GNU General Public
+// License along with GNU Make; see the file COPYING. If not, write
+// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+// Boston, MA 02110-1301 USA.
+
+#ifndef AtomicInt32PointerColumn_h
+#define AtomicInt32PointerColumn_h
+
+#include "config.h" // IWYU pragma: keep
+#include <atomic>
+#include "IntColumn.h"
+
+class AtomicInt32PointerColumn : public IntColumn {
+public:
+ AtomicInt32PointerColumn(const std::string& name,
+ const std::string& description,
+ const std::atomic_int32_t* number)
+ : IntColumn(name, description, -1, -1, -1, 0), _number(number) {}
+
+ int32_t getValue(Row /* row */,
+ const contact* /* auth_user */) const override {
+ return _number->load();
+ }
+
+private:
+ const std::atomic_int32_t* const _number;
+};
+
+#endif // AtomicInt32PointerColumn_h
diff --git a/livestatus/src/TableStatus.cc b/livestatus/src/TableStatus.cc
index acf5604..b09aebc 100644
--- a/livestatus/src/TableStatus.cc
+++ b/livestatus/src/TableStatus.cc
@@ -23,8 +23,10 @@
// Boston, MA 02110-1301 USA.
#include "TableStatus.h"
+#include <atomic>
#include <ctime>
#include <memory>
+#include "AtomicInt32PointerColumn.h"
#include "Column.h"
#include "DoublePointerColumn.h"
#include "IntPointerColumn.h"
@@ -61,7 +63,7 @@ extern int g_num_hosts;
extern int g_num_services;
extern int g_livestatus_threads;
extern int g_num_queued_connections;
-extern int g_livestatus_active_connections;
+extern std::atomic_int32_t g_livestatus_active_connections;
#ifndef NAGIOS4
extern circular_buffer external_command_buffer;
@@ -217,7 +219,7 @@ TableStatus::TableStatus(MonitoringCore *mc) : Table(mc) {
addColumn(std::make_unique<StringPointerColumn>(
"livestatus_version", "The version of the MK Livestatus module",
VERSION));
- addColumn(std::make_unique<IntPointerColumn>(
+ addColumn(std::make_unique<AtomicInt32PointerColumn>(
"livestatus_active_connections",
"The current number of active connections to MK Livestatus",
&g_livestatus_active_connections));
diff --git a/livestatus/src/module.cc b/livestatus/src/module.cc
index 6875cfa..90b6a8a 100644
--- a/livestatus/src/module.cc
+++ b/livestatus/src/module.cc
@@ -34,6 +34,7 @@
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
+#include <atomic>
#include <chrono>
#include <cstddef>
#include <cstdint>
@@ -98,7 +99,7 @@ size_t g_livestatus_threads = 10;
// current number of queued connections (for statistics)
int g_num_queued_connections = 0;
// current number of active connections (for statistics)
-int g_livestatus_active_connections = 0;
+std::atomic_int32_t g_livestatus_active_connections{0};
size_t g_thread_stack_size = 1024 * 1024; /* stack size of threads */
static int fl_disable_statehist_filtering;