Module: check_mk
Branch: master
Commit: 6fb81e6ddb02b291c985afac6db3972f3d8f0f6d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6fb81e6ddb02b2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 9 12:00:33 2018 +0200
6062 FIX checkpoint_ha_status: Workaround devices reporting wrong state information
Some devices report a state of "Active\n" instead of "Active" which was not
handled by the check. The state could not be determined correctly.
Change-Id: Ia5aeba84366a6c18ff588f1eafcc12d64486b350
---
.werks/6062 | 12 ++++++++++++
checks/checkpoint_ha_status | 3 +++
2 files changed, 15 insertions(+)
diff --git a/.werks/6062 b/.werks/6062
new file mode 100644
index 0000000..e96f9d5
--- /dev/null
+++ b/.werks/6062
@@ -0,0 +1,12 @@
+Title: checkpoint_ha_status: Workaround devices reporting wrong state information
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1525859977
+
+Some devices report a state of "Active\n" instead of "Active" which was not
+handled by the check. The state could not be determined correctly.
diff --git a/checks/checkpoint_ha_status b/checks/checkpoint_ha_status
index 48e26d0..511c1ec 100644
--- a/checks/checkpoint_ha_status
+++ b/checks/checkpoint_ha_status
@@ -44,6 +44,9 @@ def inventory_checkpoint_ha_status(info):
def check_checkpoint_ha_status(_no_item, _no_params, info):
installed, major, minor, started, state, block_state, stat_code, stat_long = info[0]
+ # Some devices have a trailing "\n" in the state field. Drop it.
+ state = state.rstrip()
+
if installed == "0":
yield 2, "Not installed"
else:
Module: check_mk
Branch: master
Commit: b4ff4ce7bab082d2078ba474fad1f7c4817a1167
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b4ff4ce7bab082…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 9 11:54:35 2018 +0200
6061 FIX Real time checks: Improved log messages in case of invalid messages
The error messages now contain the name of the related host.
This makes it easier to find host related problems during debugging.
Change-Id: I4cd9a4c78f3abd8fc90a81c9362c9d7ebf36b6a0
---
.werks/6061 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/.werks/6061 b/.werks/6061
new file mode 100644
index 0000000..57c2530
--- /dev/null
+++ b/.werks/6061
@@ -0,0 +1,12 @@
+Title: Real time checks: Improved log messages in case of invalid messages
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1525859624
+
+The error messages now contain the name of the related host.
+This makes it easier to find host related problems during debugging.
Module: check_mk
Branch: master
Commit: e6ee1015e221b3cfe42d9498ba1173eda0417655
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e6ee1015e221b3…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed May 9 09:35:46 2018 +0200
Move the 2 parts of a MongoDB connection into a new class.
Change-Id: Ic1af495cf7491656c88bd616d4b79bf57d2e1b62
---
cmk/ec/main.py | 44 +++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index df74d36..f094e21 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -827,8 +827,15 @@ try:
except ImportError:
Connection = None
-g_mongo_conn = None
-g_mongo_db = None
+
+class MongoDB(object):
+ def __init__(self):
+ super(MongoDB, self).__init__()
+ self.connection = None
+ self.db = None
+
+
+g_mongo = MongoDB()
def mongodb_local_connection_opts(settings):
@@ -843,19 +850,18 @@ def mongodb_local_connection_opts(settings):
def connect_mongodb(settings):
- global g_mongo_conn, g_mongo_db
if Connection is None:
raise Exception('Could not initialize MongoDB (Python-Modules are missing)')
- g_mongo_conn = Connection(*mongodb_local_connection_opts(settings))
- g_mongo_db = g_mongo_conn.__getitem__(os.environ['OMD_SITE'])
+ g_mongo.connection = Connection(*mongodb_local_connection_opts(settings))
+ g_mongo.db = g_mongo.connection.__getitem__(os.environ['OMD_SITE'])
def flush_event_history_mongodb():
- g_mongo_db.ec_archive.drop()
+ g_mongo.db.ec_archive.drop()
def get_mongodb_max_history_age():
- result = g_mongo_db.ec_archive.index_information()
+ result = g_mongo.db.ec_archive.index_information()
if 'dt_-1' not in result or 'expireAfterSeconds' not in result['dt_-1']:
return -1
else:
@@ -863,28 +869,28 @@ def get_mongodb_max_history_age():
def update_mongodb_indexes(settings):
- if not g_mongo_conn:
+ if not g_mongo.connection:
connect_mongodb(settings)
- result = g_mongo_db.ec_archive.index_information()
+ result = g_mongo.db.ec_archive.index_information()
if 'time_-1' not in result:
- g_mongo_db.ec_archive.ensure_index([('time', DESCENDING)])
+ g_mongo.db.ec_archive.ensure_index([('time', DESCENDING)])
def update_mongodb_history_lifetime(settings, config):
- if not g_mongo_conn:
+ if not g_mongo.connection:
connect_mongodb(settings)
if get_mongodb_max_history_age() == config['history_lifetime'] * 86400:
return # do not update already correct index
try:
- g_mongo_db.ec_archive.drop_index("dt_-1")
+ g_mongo.db.ec_archive.drop_index("dt_-1")
except OperationFailure:
pass # Ignore not existing index
# Delete messages after x days
- g_mongo_db.ec_archive.ensure_index(
+ g_mongo.db.ec_archive.ensure_index(
[('dt', DESCENDING)],
expireAfterSeconds=config['history_lifetime'] * 86400,
unique=False
@@ -892,7 +898,7 @@ def update_mongodb_history_lifetime(settings, config):
def mongodb_next_id(name, first_id=0):
- ret = g_mongo_db.counters.find_and_modify(
+ ret = g_mongo.db.counters.find_and_modify(
query={'_id': name},
update={'$inc': {'seq': 1}},
new=True
@@ -900,7 +906,7 @@ def mongodb_next_id(name, first_id=0):
if not ret:
# Initialize the index!
- g_mongo_db.counters.insert({
+ g_mongo.db.counters.insert({
'_id': name,
'seq': first_id
})
@@ -910,14 +916,14 @@ def mongodb_next_id(name, first_id=0):
def log_event_history_to_mongodb(settings, event, what, who, addinfo):
- if not g_mongo_conn:
+ if not g_mongo.connection:
connect_mongodb(settings)
# We converted _id to be an auto incrementing integer. This makes the unique
# index compatible to history_line of the file (which is handled as integer)
# within mkeventd. It might be better to use the ObjectId() of MongoDB, but
# for the first step, we use the integer index for simplicity
now = time.time()
- g_mongo_db.ec_archive.insert({
+ g_mongo.db.ec_archive.insert({
'_id': mongodb_next_id('ec_archive_id'),
'dt': datetime.datetime.fromtimestamp(now),
'time': now,
@@ -933,7 +939,7 @@ def get_event_history_from_mongodb(settings, table_events, query):
history_entries = []
- if not g_mongo_conn:
+ if not g_mongo.connection:
connect_mongodb(settings)
# Construct the mongodb filtering specification. We could fetch all information
@@ -972,7 +978,7 @@ def get_event_history_from_mongodb(settings, table_events, query):
else:
raise Exception('Filter %s not implemented for MongoDB' % filter_name)
- result = g_mongo_db.ec_archive.find(query).sort('time', -1)
+ result = g_mongo.db.ec_archive.find(query).sort('time', -1)
# Might be used for debugging / profiling
#file(cmk.paths.omd_root + '/var/log/check_mk/ec_history_debug.log', 'a').write(