Install Nagios Core latest version 4.x.x on RaspberryPi – Jessie

by | Feb 22, 2016 | Rasberry Pi

Its now possible to install latest Nagios CORE version on Raspbian by following the steps in this article. Before writing this article I Googled for the same but couldn’t find a single article covering install of latest version of Nagios on RasberryPi hence this guide. It has been fully tested and working on my personal RasPi.

This guide was originally written for Ubuntu but will work for Raspbian (Debian Jessie) flavour for RasberryPi as well. It might work for all debian distros but not guranteed, you can try it out yourself.

UPDATE: This guide is also now applicable to Nagios 4.1.1 (released 19/08/2015)

NOTE: This guide is valid only for RaspberryPi Jessie.

See ALSO: NRPE agent install for RasPi

Step-by-Step Install Procedure:

Become root user

# su

    OR

# sudo -i

Download required packages via YUM.

# apt-get install apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev

Create Nagios User

# /usr/sbin/useradd -m -s /bin/bash nagios

Change “nagios” user password. Not required but optional

# passwd nagios

Now Create a group for allowing external comands via the WEB UI and then add both Nagios and Apache user to it.

# /usr/sbin/groupadd nagcmd
# /usr/sbin/usermod -a -G nagcmd nagios
# /usr/sbin/usermod -a -G nagcmd www-data

Now download Nagios Core and Plugins from Nagios website to the /tmp directory. Latest versions as of now are Download Nagios 4.1.1 & Download Nagios Plugins 2.1.1

Create a directory for Nagios downloads

# cd /tmp
# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
# wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

Untar the downloaded files

# tar zxvf nagios-4.1.1.tar.gz
# tar zxvf nagios-plugins-2.1.1.tar.gz

And then you will get 2 folders with the name “nagios-4.1.1” & “nagios-plugins-2.1.1”

First we will start with Nagios Core Install.

Change directory to Nagios 4.1.1 and then compile the source and install it. All the files would go into “/usr/local/nagios/”

# cd /tmp/nagios-4.1.1
# ./configure –with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode

Run this command to successfully install-webconf.

# /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf
# make install-webconf

Next would be to create a user for loggng into Nagios WEB UI.

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

*nagiosadmin is the user for WEB UI. You can user your preffered name.

Once that is done need to restart the Apache Service

# /etc/init.d/apache2 reload

Now we need to install the Plugins for Nagios

Change directory to nagios-plugins-2.1.1 and then compile & install the plugins

# cd /tmp/nagios-plugins-2.1.1
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
# make
# make install

Then Make sure that Nagios service starts up on runtime/ when the system boots up.

# ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Verify the install for any errors

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

Now create nagios.service with the following content.

# vi /etc/systemd/system/nagios.service

[Unit] Description=Nagios
BindTo=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=nagios
Group=nagios
Type=simple
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg

If no errors reported then start the Nagios service.

# systemctl enable /etc/systemd/system/nagios.service
# systemctl start nagios
# systemctl status nagios

Output:

root@rasst:~# systemctl status nagios
● nagios.service – Nagios
Loaded: loaded (/etc/systemd/system/nagios.service; enabled)
Active: active (running) since Mon 2016-02-22 15:45:27 GMT; 19min ago
Main PID: 16450 (nagios)
CGroup: /system.slice/nagios.service
├─16450 /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
├─16451 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
├─16452 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
├─16453 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
├─16454 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
└─16455 /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg

Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16451;pid=16451
Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16452;pid=16452
Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16453;pid=16453
Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16454;pid=16454
Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16451;pid=16451
Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16452;pid=16452
Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16453;pid=16453
Feb 22 15:45:27 rasst.vh.local nagios[16450]: wproc: Registry request: name=Core Worker 16454;pid=16454
Feb 22 15:45:27 rasst.vh.local nagios[16450]: Successfully launched command file worker with pid 16455
Feb 22 15:45:27 rasst.vh.local nagios[16450]: Successfully launched command file worker with pid 16455

You are now ready to login to Nagios Web Interface via the browser (recommended would be Firefox)

http://nagios-server-URL/nagios

*Use your host IP or the hostname follwed by /nagios.

If you encounter any errors during the process, let us know via Contact Us and will get it resolved promptly.

Related Articles….