statusengine / broker

Repository of the Statusengine Event Broker Module written in C++ (development)
GNU General Public License v2.0
8 stars 5 forks source link

Statusengine naemon/nagios broker module

The Statusengine Broker Module is a small c++ library that gets loaded into your Naemon or Nagios Core.

It will grab all status information, encode them as JSON, and put them into the Gearman Job Server or RabbitMQ. Due to the queuing engine (Gearman or RabbitMQ) your Monitoring Core will not get blocked by a slow database or disk io issues. It is highly recommended to run the Gearman Job Server on the same node as the monitoring core.

Visit the documentation for more information about Statusengine C++ Broker Module

Build and Installation

Please compile and install the newest version of naemon or nagios. We need the header files for building the broker.

Dependencies

Meson

https://mesonbuild.com/Getting-meson.html

Ubuntu/Debian

apt install git python3-pip gcc g++ cmake build-essential libglib2.0-dev libgearman-dev uuid-dev libuchardet-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev
pip3 install meson ninja

CentOS

yum install git python-pip gcc gcc-c++ cmake3 pkgconfig librabbitmq-devel libgearman-devel libuchardet-devel json-c-devel openssl-devel glib2-devel
pip install meson ninja

Sources

cd /tmp
git clone https://github.com/statusengine/broker
cd broker

Naemon

Please make sure you have set up Naemon like described in the docs.

Then create the make files

export PKG_CONFIG_PATH=/opt/naemon/lib/pkgconfig/
meson setup --buildtype=release build
ninja -C build

Nagios

Please make sure you have set up Nagios like described in the docs.

Ubuntu/Debian

meson setup -Dnagios=true -Dnagios_include_dir=/opt/nagios/include build

RHEL/CentOS

meson setup -Dnagios=true -Dnagios_include_dir=/opt/nagios/include build

Build

ninja -C build

Installation

ninja -C build install

Additional meson build flags

Installation path

The default installation path for the library is /usr/local, which means that the so file will be placed under /usr/local/lib/libstatusengine.so.

You can specify --prefix=/opt/naemon as meson argument to change the path.

Disable RabbitMQ or Gearman

You can specify -Dgearman=false or -Drabbitmq=false as meson argument to disable gearman or rabbitmq.

Configuration

Per default everything is disabled and the broker does nothing.

You can look at statusengine.toml as an example configuration file. In your naemon.cfg/nagios.cfg you have to specify the broker module like this:

broker_module=/opt/naemon/lib/libstatusengine.so /path/to/statusengine.toml

Developer build + test

If you want to build and test the broker, you can use the docker-compose configuration:

docker-compose up --build

This will create docker containers with naemon, rabbitmq and gearman. The broker module will be build on the naemon container. The up command will also run the containers, so you can test if it works.

For deeper inspection you can switch into the naemon container on a second console:

docker exec -t -i broker_naemon_1 /bin/bash

I have also placed a small script inside the container that shows you the queue status of rabbitmq and gearman:

docker exec -t -i broker_naemon_1 /usr/bin/queuestatus

Development with Visual Studio Code

  1. Setup Naemon Core The easiest method is to clone the original Naemon repository and run the initial Task as described here: https://github.com/naemon/naemon-core/tree/master/.vscode

  2. Install Statusengine Broker dependencies

    apt-get install git python3-pip gcc g++ cmake build-essential libglib2.0-dev libgearman-dev uuid-dev libuchardet-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev gearman-job-server
    pip3 install meson ninja
  3. Open the Project in Visual Studio Code. Create a new folder named build. Adjust the path of /home/dziegler/git/naemon-core-original in the tasks.json and settings.json.

Than run the Task Terminal > Run Task... > configure to setup meson

  1. Make sure the Statusengine Broker is loaded in Naemon

    broker_module=/home/dziegler/git/broker/build/src/libstatusengine.so /home/dziegler/git/broker/statusengine.toml
  2. Start Debugging using the Debug Shared Library configuration

vscode debugger via WSL2

License

statusengine - the missing event broker
Copyright (C) 2019  The statusengine team

This program 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; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.