Check MK Linux Nagvis

Check MK and Grafana

The graphs in Check MK may be quite nice but there is another way of taking this a step higher and make beautiful dashboards. You may even want to create public dashboards or put some info on wallboards.  There is a simple setting i Check MK that you may have missed. It looks like this:

I did not take any notice of it but once used it is fantastic. Ok, let´s start setting this up. I have used instructions on various places but mostly the documentation found here. Before starting make sure you have:

  • A working Check MK Server
  • An Ubuntu server with ssh access. Just install the basics.

Connect to your new server and update:

Install what is needed. Answer no to remove the files

Configure Carbon

Edit the Carbon configuration file.

Make the following change.

Start the service.

Install and configure PostgreSQL

By default Graphite will use SQLite. PostgreSQL is better.

Install PostgreSQL.

Change to postgres user.

Create a database user. You will be prompted to supply a password. Remember this password as you’ll need it when configuring Graphite.

Create the databases for Graphite and Grafana.

Then switch back to your user account. For example:

Configure Graphite

Update the database settings.

Update the database connection settings to use the PostgreSQL database. Use the password your specified for the graphite user created in PostgreSQL. For example:

Within the same file, update the time zone. Uncomment the TIME_ZONE line and add the correct time zone which matches the server’s time zone.  I did got an error here when I initialized the database. In case you get that change this setting later. For example:

 

Within the same file, update the secret key to something long and complicated. Uncomment the SECRET_KEY line and add a random string of letters and numbers. For example:

Initialize the database. You will be prompted to create a superuser account which will be used to access Graphite’s web interface. Leave the username as root and enter a password.

Configure Apache for Graphite

Apache is required for Graphite.

Copy Graphite’s Apache config template to Apache’s sites-available directory.

Change Graphite’s port from 80 to 8080 (port 80 will be used by Grafana).

Update which ports Apache is listening for.

Add port 8080. For example:

Disable Apache’s default site to avoid any conflicts.

Enable Graphite’s virtual site.

Reload Apache to apply the changes.

You should now be able to browse to Graphite’s web interface, http://servername:8080.

If you have configured the setting in Check MK and if it is working you should be able to see the host here now.

Install and configure Grafana

Add the following line to your /etc/apt/sources.list file.

Use the above line even if you are on Ubuntu or another Debian version. There is also a testing repository if you want beta or release candidates.

Then add the Package Cloud key. This allows you to install signed packages.

Update your Apt repositories and install Grafana

Edit Grafana’s configuraiton file.

Update the database connection values to use PostgreSQL. For example:

Update the server configuration. For example:

Update the security information. For example:

Enable anonymous viewing.

Enable Apache’s proxy modules for reverse proxying. This will allow Apache to listen to port 80 and proxy the requests to Grafana’s webserver on port 3000.

Create an Apache configuration file for Grafana.

Add the following to the file:

Enable the Grafana website in Apache.

Configure Grafana to run after boot.

Start the Grafana server.

Restart Apache.

Go to http://yourserver. If it shows Grafana it works. Also try the :8080 to Grahite again to make sure it works. This was the boring part. The next is the fun one.

Setting the datasource

In Grafana go to datasources.  For me it looks like this:

Press save & test and make sure it works. When I first installed Grafana via apt- get without adding the repository I ended up with an old version without any icon. So make sure you have installed the latest release. You can check this is the Grafana gui.

Dashboards with Check MK Data

Press the add row in a dashboard. Choose what type of panel you may want.

I choosed the graph. Edit the settings you want and save.

There are several cool panels that you may download from grafana. These are installed with the command below (the example is the pie chart) Restart Grafana after installing.

In the end you may have a dashboard something like (it is just a demo I made quick) this with realtime data collected from Check MK.