Chotaire Wiki

Stuff you didn't know

User Tools

Site Tools


Install Nagios CGI support in Checkmk 1.6.0 / 2.0

Checkmk 1.6.0 is no longer shipped with the classic Nagios UI, which includes the cgi-bin files. The authors have decided to remove it for security reasons and they don't intend to bring it back. This decision results in all third-party smartphone apps (such as aNag) to effectively stop working. This document explains how to get back Nagios cgi support.

Download my nagios-cgi pack to your Checkmk server

Download the following file: checkmk-1.6.0-nagios-cgi.tar.bz2

Transfer this to your Checkmk server. If you don't trust me, feel free to grab the original files from a Check_MK 1.5.0 installation. In our example, move the downloaded archive to /opt directory (and keep it there, you will likely need it again in the future).

Unpack the archive into your current version of Checkmk

As root, unpack the archive in the following directory, please remember to swap cmk-version with the currently running version (e.g. 1.6.0p1.cre).

cd /opt/omd/versions/cmk-version/lib/nagios/
tar -jxvf /opt/checkmk-1.6.0-nagios-cgi.tar.bz2

This will create a new cgi-bin directory inside your nagios/ folder. It includes the files needed for 3rd party tools to function. Remember you will need to do this again after every Checkmk update.

The unpacked files should look like this:

[root@kawuffelpeter nagios]# cd cgi-bin/
[root@kawuffelpeter cgi-bin]# ls -al
total 3952
drwxrwxr-x. 2 root root   4096 Sep 11 16:21 .
drwxr-xr-x. 4 root root   4096 Sep 25 00:32 ..
-rwxrwxr-x. 1 root root 285496 Sep  9 00:18 avail.cgi
-rwxrwxr-x. 1 root root 284112 Sep  9 00:18 cmd.cgi
-rwxrwxr-x. 1 root root 252648 Sep  9 00:18 config.cgi
-rwxrwxr-x. 1 root root 297752 Sep  9 00:18 extinfo.cgi
-rwxrwxr-x. 1 root root 244640 Sep  9 00:18 histogram.cgi
-rwxrwxr-x. 1 root root 228120 Sep  9 00:18 history.cgi
-rwxrwxr-x. 1 root root 228104 Sep  9 00:18 notifications.cgi
-rwxrwxr-x. 1 root root 223968 Sep  9 00:18 outages.cgi
-rwxrwxr-x. 1 root root 223984 Sep  9 00:18 showlog.cgi
-rwxrwxr-x. 1 root root 293672 Sep  9 00:18 status.cgi
-rwxrwxr-x. 1 root root 244704 Sep  9 00:18 statusmap.cgi
-rwxrwxr-x. 1 root root 240432 Sep  9 00:18 statuswml.cgi
-rwxrwxr-x. 1 root root 228112 Sep  9 00:18 statuswrl.cgi
-rwxrwxr-x. 1 root root 248640 Sep  9 00:18 summary.cgi
-rwxrwxr-x. 1 root root 240448 Sep  9 00:18 tac.cgi
-rwxrwxr-x. 1 root root 252832 Sep  9 00:18 trends.cgi
[root@kawuffelpeter cgi-bin]# pwd

Create a new Apache configuration file

Now you need to create a new config file for Checkmk's included apache server. Remember to replace cmk-sitename with the name of your Checkmk site. In this example, as root we use the editor nano.

cd /opt/omd/sites/cmk-sitename/etc/apache/conf.d/
nano nagios.conf

Paste the following contents into your editor and again, replace cmk-sitename with the name of your Checkmk site. Remember, you have to edit 4 occasions. Once done, save the file:

# This will bring back nagios CGI support for 3rd party applications.
# Enjoy! /Chot
ScriptAlias /cmk-sitename/nagios/cgi-bin /omd/sites/cmk-sitename/lib/nagios/cgi-bin
<Directory /omd/sites/cmk-sitename/lib/nagios/cgi-bin>
  Order allow,deny
  Allow from all
  SetEnv NAGIOS_CGI_CONFIG "/omd/sites/cmk-sitename/etc/nagios/cgi.cfg"

I have tested that this file survives Checkmk version updates. Still, keep a copy of your edited file. Also keep a copy of the nagios cgi-bin directory for your upcoming Checkmk updates. You will have to unpack the nagios cgi archive into every future version of Checkmk 1.6.0 / 2.0.

Restart your Checkmk site

Finally, restart Checkmk so that Apache reads the new configuration.

omd restart

You're now able to use 3rd party tools again. I have tested and verified that this works with roles, permissions, contact groups. Access restrictions still apply as they should. I've also tested that aNag can still send commands.

Do you think this is too hacky? Checkmk subscribers, contact Tribe29 to revert this change.

Tip: Nagstamon (solely for desktops) is the only 3rd party app that natively supports Checkmk.
All these integrations like Opsgenie, PagerDuty or Slack are NOT two-way. Only the IRC plugin is.

linux-check_mk-nagios-cgi.txt · Last modified: 2021/05/14 00:10 by chotaire