Nagios 4 (core) + Check_mk + pnp4Nagios + Nagvis 23


Since Nagios 4 version release there was an important addon update pending. Recently, check_mk released its innovation version check_mk-1.2.5i2 including MK Livestatus with compatibility with Nagios Core 4. We need therefore check_mk-1.2.5i2 or higher to run check_mk with Nagios Core 4.


In aboutmonitoring we are going to build and test a monitoring system with probably the more interesting and powerful utilities for Nagios. We need compile Nagios 4 because there is not packages in usual distros yetand because we prefer the lastest versions for testing. If you are looking for to install same software in Centos 7 look at Nagios Core 4 + PNP4Nagios + Check_mk + Nagvis in CentOS 7 – Redhat 7

Software components used in this test:

Tested with SELINUX disabled!!!

Update (06/09/2015): The recent check_mk “free” versions are called Check_MK Raw Edition (CRE). These versions incorporate check_mk and additional software (pack previously called OMD). For the source package of check_mk mentioned in this article you must download the CRE version, untar and localize the tar.gz package check_mk in packages/check_mk/

Install Linux and general prerequisites.

CentOS is installed with minimal options an updated from repositories.

We need install development tools for compile Nagios, nagiosplugins, check_mk,…

yum groupinstall "Development Tools"
yum install wget

Nagios 4 Core


Install Apache, php and some required libraries and tools.

yum install httpd php glibc glibc-common gd gd-devel make net-snmp

Create nagios user and groups

We are going to create nagios account and an additional group “nagcmd” that we need to use for nagios external commands. Nagios user and Apache user must be in “nagcmd” group.

useradd nagios && passwd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

Compile and install Nagios Core 4.

We need to configure Nagios sofware with (important) our nagcmd group as command group and compile:

tar zxfv nagios-4.0.5.tar.gz
cd nagios-4.0.5
./configure --with-command-group=nagcmd

*** Configuration summary for nagios 4.0.5 04-11-2014 ***:

General Options:


Nagios executable: nagios

Nagios user/group: nagios,nagios

Command user/group: nagios,nagcmd

Event Broker: yes

Install ${prefix}: /usr/local/nagios

Install ${includedir}: /usr/local/nagios/include/nagios

Lock file: ${prefix}/var/nagios.lock

Check result directory: ${prefix}/var/spool/checkresults

Init directory: /etc/rc.d/init.d

Apache conf.d directory: /etc/httpd/conf.d

Mail program: /bin/mail

Host OS: linux-gnu

IOBroker Method: epoll

Web Interface Options:


HTML URL: http://localhost/nagios/

CGI URL: http://localhost/nagios/cgi-bin/

Traceroute (used by WAP):

Next steps are to compile and install. Tools inform us about next steps and other important inforamation about executed commands.

make all

# This installs the main program, CGIs, and HTML files

make install

# This installs the init script in /etc/rc.d/init.d

make install-init

# This installs and configures permissions on the directory for holding the external command file

make install-commandmode

# This installs *SAMPLE* config files in /usr/local/nagios/etc

make install-config

# This installs the Apache config file for the Nagios web interface

make install-webconf

# This installs the Exfoliation theme for the Nagios web interface

make install-exfoliation

From nagios source directory we must copy something files that may need in the future.

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

Check nagios config (with included sample files)

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Create password file

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Configure Apache and Nagios services to run at init and start both services.

chkconfig --add nagios && chkconfig --level 35 nagios on && chkconfig --level 35 httpd on
service nagios restart && service httpd restart


Go to nagios URI: http://server/nagios/ and all should be ok. (Remember to enable http port in your local firewall with iptables).

We can see that localhost sample checks fail. It is logical, there is not directory with Nagios Plugins yet.


Nagios Plugins.

We have several options for installing Nagios Plugins. We can install actual plugins binaries from EPEL repositories (equivalent to monitoring-plugins). We can download and compile from monitoring-plugin classic plugins or plugins from Nagios Enterprise (similar to monitoring-plugins yet).

We are going to compile and install Nagios Enterprise plugins. It’s your choice.


Basic packages

yum install bind-utils net-snmp-devel net-snmp-utils net-snmp-perl

Only if we are going to use some plugins for check mysql (local), samba (local),… we need install some more packages to compile successfully this specific plugins.

yum install mysql-client mysql-devel samba-client samba-common postgresql-devel openldap-devel

Compile and install Nagios plugins

tar zxfv nagios-plugins-2.0.1.tar.gz
cd nagios-plugins-2.0.1
./configure -with-nagios-user=nagios -with-nagios-group=nagios
make install

Now, localhost check samples must be ok in our Nagios. The plugins are in directory /usr/local/nagios/libexec/ with correct permissions and owners (some plugins need different rights and/or owner).



Install from EPEL or install compiling? At this point, with Nagios Core and Nagios Plugins compiling installed… I prefer to compile PNP4Nagios too. Is the best option really. Install from EPEL would try install Nagios core 3 too and we want Nagios Core 4.


yum install rrdtool perl-Time-HiRes rrdtool-perl php-gd

Download, untar, configure, compile and install.

tar zxfv pnp4nagios-0.6.21.tar.gz
cd pnp4nagios-0.6.21
make all
make fullinstall

Important to save end command information to find software directories later if we need them.

*** Configuration summary for pnp4nagios-0.6.21 03-24-2013 ***

General Options:

————————- ——————-

Nagios user/group: nagios nagios

Install directory: /usr/local/pnp4nagios

HTML Dir: /usr/local/pnp4nagios/share

Config Dir: /usr/local/pnp4nagios/etc

Location of rrdtool binary: /usr/bin/rrdtool Version 1.3.8

RRDs Perl Modules: FOUND (Version 1.3008)

RRD Files stored in: /usr/local/pnp4nagios/var/perfdata Logfile: /usr/local/pnp4nagios/var/perfdata.log

Perfdata files (NPCD) stored in: /usr/local/pnp4nagios/var/spool

Web Interface Options:

————————- ——————-

HTML URL: http://localhost/pnp4nagios

Apache Config File: /etc/httpd/conf.d/pnp4nagios.conf


Configure npcd service to run at init and starting. Reload apache for reading pnp4nagios config file.

chkconfig --add npcd && chkconfig --level 35 npcd on
service httpd reload

In pnp4nagios URI http://server/pnp4nagios/ to look at all checks are marked green. If all it’s ok rename file /usr/local/pnp4nagios/share/install.php

Reloading PNP4Nagios page we are going to find an error:

Please check the documentation for information about the following error.perfdata directory “/usr/local/pnp4nagios/var/perfdata/” is empty. Please check your Nagios config. Read FAQ online

At this point is a normal error. We need configure nagios integration yet!

Configure PNP4Nagios.

PNP4Nagios allow several options to configure Nagios integration. We are going to use option named “Bulk-mode”. It’s the best available for Nagios 4 (Bulk Mode with npcdmod is more simple but is not valid for Nagios 4, it use a broker that is not compatible with Nagios 4 module broker).

There are example config. texts in /usr/local/pnp4nagios/etc files ready to copy and paste.

From file nagios.cfg-sample copy ONLY next text to nagios config file /usr/local/nagios/etc/nagios.cfg


# Bulk / NPCD mode



# *** the template definition differs from the one in the original nagios.cfg







# *** the template definition differs from the one in the original nagios.cfg








From file misccommands.cfg-sample copy ONLY next text configuration to nagios commands file /usr/local/nagios/etc/objects/commands.cfg. And uncomment the lines!!


# Bulk with NPCD mode


define command {

command_name process-service-perfdata-file

command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$


define command {

command_name process-host-perfdata-file

command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$


Restart npcd and nagios daemons now

service npcd restart && service nagios restart

We can test now pnp4Nagios site and must be up and running.


Configure links to graphs.

Last but not least we must configure acces to graphs from Nagios pages.

Edit /usr/local/nagios/etc/objects/templates.cfg and add next text:

define host {

name host-pnp

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_’ class=’tips’ rel=’/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_

register 0


define service {

name srv-pnp

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$’ class=’tips’ rel=’/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$

register 0


Modify required host and service objects to use inheritance with pnp4nagios specific templates created previously (use property):


define host{

use linux-server,host-pnp

host_name localhost

alias localhost



define service{

use local-service,srv-pnp

host_name localhost

service_description PING

check_command check_ping!100.0,20%!500.0,60%


ATENTION: Copy next file from PNP4Nagios source directory to Nagios directory. It’s necessary to show POPUPS graphs in icons.

cp contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/

Restart nagios and ncmd (pnp4nagios module):

service npcd restart && service nagios restart

We can see a beautiful POPUP when mouse to hover graph icon and we can click on this for go to PNP4Nagios site. Beautiful and practical :-)






Check_mk GUI need a python apache module that is not included in distro repositories actually. It can be installed from EPEL repositories.

# Install EPEL Repositories (if needed it)
rpm --import
yum localinstall epel-release-6-8.noarch.rpm
# Install python module for apache
yum install mod_python
service httpd restartInstall check_mk (and Live status).


Check_mk install is quite easy. It may be even easier if you copy next text in a file named “.check_mk_setup.conf”  in your home root (first character file name is “.”). 


# Written by setup of check_mk 1.2.5i2p1 at Wed Apr 16 20:10:20 CEST 2014























nagios_auth_name=’Nagios Access’











You can install check_mk without this file and answer all questions about you file locations or use this file and change default entries during setup. Check_mk create and use this file to know values in next installation or update.

tar zxfv check_mk-1.2.5i2p1.tar.gz
cd check_mk-1.2.5i2p1

When check_mk setup completes install show… “Installation completed successfully. Please restart Nagios and Apache in order to update/active check_mk’s web pages.”

service httpd restart $$ service npcd restart && service nagios restart

Setup add next lines at the end of Nagios config file “nagios.cfg”.

# Load Livestatus Module
broker_module=/usr/lib/check_mk/livestatus.o /usr/local/nagios/var/rw/live
# added by of check_mk

We can test check_mk in URI http://server/check_mk.

If you find any problem with check_mk livestatus connect to Nagios, first to look is correct load of livestatus in nagios.log:

> tail /usr/local/nagios/var/nagios.log
[1396806973] livestatus: Livestatus 1.2.5i2 by Mathias Kettner. Socket: '/usr/local/nagios/var/rw/live'
[1396806973] livestatus: Please visit us at
[1396806973] livestatus: Hint: please try out OMD - the Open Monitoring Distribution
[1396806973] livestatus: Please visit OMD at
[1396806973] livestatus: Finished initialization. Further log messages go to /usr/local/nagios/var/livestatus.log
[1396806973] Event broker module '/usr/lib/check_mk/livestatus.o' initialized successfully.
[1396806974] Successfully launched command file worker with pid 4873

Example localhost in check_mk…





yum install php-mbstring php-pdo graphviz


tar zxfv nagvis-1.8b3.tar.gz
cd nagvis-1.8b3

Main questions from install are about paths and users but Nagvis install discover so good all important values. We must select only “backend mklivestatus”


| Welcome to NagVis Installer 1.8b3 |


| This script is built to facilitate the NagVis installation and update |

| procedure for you. The installer has been tested on the following systems: |

| – Debian, since Etch (4.0) |

| – Ubuntu, since Hardy (8.04) |

| – SuSE Linux Enterprise Server 10 and 11 |

| |

| Similar distributions to the ones mentioned above should work as well. |

| That (hopefully) includes RedHat, Fedora, CentOS, OpenSuSE |

| |

| If you experience any problems using these or other distributions, please |

| report that to the NagVis team. |


| Do you want to proceed? [y]: y


| Starting installation of NagVis 1.8b3 |


| OS : CentOS release 6.5 (Final) |

| |

+— Checking for tools ——————————————————-+

| Using packet manager /bin/rpm found |

| |

+— Checking paths ———————————————————–+

| Please enter the path to the nagios base directory [/usr/local/nagios]:

| nagios path /usr/local/nagios found |

| Please enter the path to NagVis base [/usr/local/nagvis]:

| |

+— Checking prerequisites —————————————————+

| PHP 5.3 found |

| PHP Module: gd php found |

| PHP Module: mbstring php found |

| PHP Module: gettext compiled_in found |

| PHP Module: session compiled_in found |

| PHP Module: xml compiled_in found |

| PHP Module: pdo php found |

| Apache mod_php found |

| Checking Backends. (Available: mklivestatus,ndo2db,ido2db,merlinmy) |

| Do you want to use backend mklivestatus? [y]: y

| Do you want to use backend ndo2db? [n]:

| Do you want to use backend ido2db? [n]:

| Do you want to use backend merlinmy? [n]:

| Livestatus Socket (/usr/local/nagios/var/rw/live) found |

| PHP Module: sockets compiled_in found |


+— Trying to detect Apache settings —————————————–+

| Please enter the web path to NagVis [/nagvis]:

| Please enter the name of the web-server user [apache]:

| Please enter the name of the web-server group [apache]:

| create Apache config file [y]:

| |

+— Checking for existing NagVis ———————————————+

| |


| Summary |


| NagVis home will be: /usr/local/nagvis |

| Owner of NagVis files will be: apache |

| Group of NagVis files will be: apache |

| Path to Apache config dir is: /etc/httpd/conf.d |

| Apache config will be created: yes |

| |

| Installation mode: install |

| |

| Do you really want to continue? [y]:


| Installation complete |

| |

| You can safely remove this source directory. |

| |

| For later update/upgrade you may use this command to have a faster update: |

| ./ -n /usr/local/nagios -p /usr/local/nagvis -l “unix:/usr/local/nagios/var/rw/live” -b mklivestatus -u apache -g apache -w /etc/httpd/conf.d -a y

| |

| What to do next? |

| – Read the documentation |

| – Maybe you want to edit the main configuration file? |

| Its location is: /usr/local/nagvis/etc/nagvis.ini.php |

| – Configure NagVis via browser |

| <http://localhost/nagvis/config.php> |

| – Initial admin credentials: |

| Username: admin |

| Password: admin |


service httpd reload

Test your new Nagivis web site: http://server/nagvis/ (admin/admin)

Minimal configuration and test.

Nagvis include a lot of samples, so much samples really. Is good bat… there is so much confusion to start with nagvis.

First is configure the default backend to check_mk livestatus (live_1). Menu Options / Manage Backends / Default Backend → live_1 (save)

Go to an existing map (p.e. “Demo1. Datacenter Hamburg”).

  • Menu Edit Map / Map Options / listbox “backend_id” and select live_1 (save).
  • Menu Edit Map / Add Icon / Host, place cross where you like in the map, select as Hostname in listbox your localhost (save).

Now we can create new map from our images and start to place objects in it. Great!

Perhaps, the best is delete all demo maps first.

Example localhost passing mouse over host object in Nagvis MAP:


Dowload this post.


See you soon!!


Leave a comment

Your email address will not be published. Required fields are marked *


23 thoughts on “Nagios 4 (core) + Check_mk + pnp4Nagios + Nagvis

  • Sam

    I followed all the setps and I’m still having issue with Livestatus

    Livestatus problem: Cannot connect to ‘unix:/var/log/nagios/rw/live’: [Errno 13] Permission denied

    86] Event broker module ‘/usr/lib/check_mk/livestatus.o’ initialized successfully.
    [1404464586] Warning: failure_prediction_enabled is obsoleted and no longer has any effect in host type objects (config file ‘/usr/local/nagios/etc/check_mk.d/check_mk_templates.cfg’, starting at line 88)
    [1404464586] Warning: failure_prediction_enabled is obsoleted and no longer has any effect in service type objects (config file ‘/usr/local/nagios/etc/check_mk.d/check_mk_templates.cfg’, starting at line 157)
    [1404464586] Successfully launched command file worker with pid 35237
    [1404464586] TIMEPERIOD TRANSITION: 24X7;-1;1
    [1404464586] TIMEPERIOD TRANSITION: 24×7;-1;1
    [1404464586] TIMEPERIOD TRANSITION: 24x7_sans_holidays;-1;0
    [1404464586] TIMEPERIOD TRANSITION: none;-1;0
    [1404464586] TIMEPERIOD TRANSITION: us-holidays;-1;0
    [1404464586] TIMEPERIOD TRANSITION: workhours;-1;0

    • distractedman1 Post author

      Hi Sam.
      Nagios broker seem is running ok. There is a problem with “live” file or rights in dir of “live” file.
      Is your socket livestatus file in :/var/log/nagios/rw/live ??? CMK install default is not there…


    • Mark

      Sam – it it helps, I got similar errors after a reboot:

      check_mk: Cannot connect to ‘unix:/usr/local/nagios/var/rw/live’: [Errno 13] Permission denied
      nagvis: Error (Dwoo_Exception): The compile directory must be writable, chmod “/usr/local/nagvis/var/tmpl/compile/” to make it writable

      The issue was that I disabled SElinux while installing the apps, but it was only temporarily. I had to update /etc/selinux/config to permanently disable.


    Server or Configuration Problem
    A Server problem occurred. You’ll find details in the error log of Apache. One possible reason is, that the file /usr/local/nagios/etc/htpasswd.users is missing. You can create that file with htpasswd or htpasswd2. A better solution might be to use your existing htpasswd file from your Nagios installation. Please edit /etc/httpd/conf.d/check_mk and change the path there. Restart Apache afterwards.

  • Ashik

    I am getting the following error after adding nagios.cfg file
    # Load Livestatus Module
    broker_module=/usr/lib/check_mk/livestatus.o /usr/local/nagios/var/rw/live

    [root@localhost ~]# tail /usr/local/nagios/var/nagios.log [1421900034] Event broker module ‘/usr/lib/check_mk/livestatus.o’ deinitialized successfully.
    [1421900034] Error: Failed to load module ‘/usr/lib/check_mk/livestatus.o’.
    [1421900034] livestatus: Livestatus 1.2.6b6 by Mathias Kettner. Socket: ‘/usr/local/nagios/var/rw/live’
    [1421900034] livestatus: Please visit us at
    [1421900034] livestatus: Hint: please try out OMD – the Open Monitoring Distribution
    [1421900034] livestatus: Please visit OMD at
    [1421900034] livestatus: Removed old left over socket file /usr/local/nagios/var/rw/live
    [1421900034] livestatus: Finished initialization. Further log messages go to /usr/local/nagios/var/livestatus.log
    [1421900034] Event broker module ‘/usr/lib/check_mk/livestatus.o’ initialized successfully.
    [1421900034] Error: Module loading failed. Aborting.
    [root@localhost ~]#

    • distractedman1 Post author

      Hi Ashik. It’s strange. Module load but is not loaded…
      I would review potential problems with permissions on the files involved. Have you disabled SELINUX? Test disable SELINUX first.

  • dario

    Hello folks, after PNP4nagios installation trying to connect to http://nagiosserver/pnp4nagios I received this msg error:
    Fatal error: Call to undefined function simplexml_load_file() in /usr/local/pnp4nagios/share/application/models/data.php on line 270
    do you have any idea how to solve? thanks in advance

  • Nishith N.Vyas


    I have configured Nagios, Check_MK, PNP4 Nagios and Nagvis as per your documentation, but I am unable to configure map using “Demo1. Datacenter Hamburg”.

    In addition to this, I don’t get “Options” menu button on top. I have checked Nagvis in three different browsers, but all browsers show same result.

    Please let me know if I miss something.

  • Nishith Vyas

    Getting Error while compiling mk-livestatus using “make -j 4” command. In member function ‘void TableLog::updateLogfileIndex()’: error: expected primary-expression before ‘struct’
    int len = offsetof(struct dirent, d_name)
    ^ error: ‘d_name’ was not declared in this scope
    int len = offsetof(struct dirent, d_name)
    ^ error: ‘offsetof’ was not declared in this scope
    int len = offsetof(struct dirent, d_name)
    make[2]: *** [livestatus_so-TableLog.o] Error 1
    make[2]: *** Waiting for unfinished jobs….
    mv -f .deps/livestatus_so-OffsetStringMacroColumn.Tpo .deps/livestatus_so-OffsetStringMacroColumn.Po
    mv -f .deps/livestatus_so-TableContactgroups.Tpo .deps/livestatus_so-TableContactgroups.Po
    mv -f .deps/livestatus_so-OffsetStringServiceMacroColumn.Tpo .deps/livestatus_so-OffsetStringServiceMacroColumn.Po
    make[2]: Leaving directory `/home/Nagios_Setup/mk-livestatus-1.1.6p1/src’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/Nagios_Setup/mk-livestatus-1.1.6p1′
    make: *** [all] Error 2

  • selvamani

    Hi , in which file i need to add the below test.

    define host{

    use linux-server,host-pnp

    host_name localhost

    alias localhost



    define service{

    use local-service,srv-pnp

    host_name localhost

    service_description PING

    check_command check_ping!100.0,20%!500.0,60%


  • Feico

    A warning, I copied the nagios cfg settings for pnp4nagios from this website instead of the original files. After this everything worked except the popup graphs. After carefull comparing the differences, I figured out that the wrong quote character was copied somehow! After changing the qoutes to the standard backqoute on the keyboard, the popup graphs worked.