Add Mongodb as an archive mode in the EC

Hello everyone,

I would like to share some expression about how to enable MongoDB as an archieve mode in Check Mk Raw Edition. That solution I think it is applicable also for the Enterprise.

That topic is continued of Event Console - archive events to MongoDB.
I tried many times to solve the errors from my previous topic and I did at the end.

I enable MongoDB as an archive mode on Check Mk Raw 1.6.0p18.

What you need?

  • install MongoDB
  • install pymongo
  • add button in Event Console Settings (in the GUI) that allow you to decide what solution of archive mode you would like to use:
    - MongoDB
    - file
  • change the code responsible for the connection to the MongoDB

In the official documentation of MongoDB is explained how to install it. I am using Centos8.

After the installation of MongoDB, check if it is working. I have small modification to the /etc/mongod.conf. Instead of the general path for storing the date I have changed it to - /omd/sites/instance_name/var/mongodb

And the file:

mongod.conf

for documentation of all options, see:

http://docs.mongodb.org/manual/reference/configuration-options/

where to write logging data.

systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log

Where and how to store data.

storage:
dbPath: /opt/omd/sites/tncoper/var/mongodb
#dbPath: /var/lib/mongodb
journal:
enabled: true

engine:

mmapv1:

wiredTiger:
engineConfig:
cacheSizeGB: 2

how the process runs

processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile

network interfaces

net:
port: 27017
bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.

#security:

#operationProfiling:

#replication:

#sharding:

Enterprise-Only Options

#auditLog:

#snmp:

After you have installed the MongoDB, check if the service is working. Do not forget to check each file of the mongodb for the correct user and group.

The next step is to install pymongo. I did it through pip.

Next step is to add the button in Event Console Settings as it is explained in the topic attached in the beggining. After you do these 3 steps, go to the EC > Settings and select MongoDB as an archive mode, restart the instance. Most probably you will get the error that it is also visible in the attached topic and it is located in - /omd/sites/instance_name/var/log/mkeventd.log. Probably the error will - cannot connect to the MongoDB.

The next step is to change the code responsible to connect to the MongoDB.
That code is located in - /omd/sites/instance_name/lib/python/cmk/ec
/history.py

And the changes you need to do:

When you are ready with that change, you can restart again the instance. If the result is the same, copy the pymongo packages to that folder - /omd/sites/instance_name/lib/python2.7/site-packages

Restart the instance again and it should work.

Great idea, but please, do not ever change code that is not part of the site:

This is a file that comes out of the checkmk package and will be lost with the next update. Code modifications should be stored in $OMD_ROOT/local and its subdirectories accordingly.