Installing Nagios on Solaris for network and server monitoring
Nagios, is a popular and free, open source network and server monitoring system that can benefit your IT infrastructure.
nagios offers monitoring and alerting services for servers, switches, applications, and services.
This article will walk you through setting up a basic installation of Nagios on a Solaris 11 system.
Nagios installation prerequisites
You can successfully build Nagios Core using either the GNU compiler or Oracle Solaris Studio. In this article, we will be using the GNU C compiler to build the Nagios Core.
- Firstly, install the Apache Web Server and PHP Server:
# pkg install pkg:/web/server/apache-22 # pkg install pkg:/web/php-53 # pkg install pkg:/web/server/apache-22/module/apache-php53 # pkg install pkg:/library/gdNote: The Graphics Draw library (
gd) is needed to use the
- Install the GNU C compiler (
gcc) if not installed on your system.
# pkg install pkg:/developer/gcc-45There might be multiple version of
gccin your repository, use the
pkg search -p gccto examine which versions are available
- Create a nagios user and group
# groupadd nagios # useradd -g nagios -c "nagios admin" nagios
Download, compile and install nagios
At the time of writing, the latest version of Nagiois is 4.0.2 available from the Nagious download page.
- Download and extract the archives into /usr/local/src (our your preferred download location)
# mkdir -p /usr/local/src # cd /usr/local/src # tar -zxf nagious-4.0.2.tar.gz # mv nagious-4.0.2 nagios
- Configure and compile Nagios
# cd nagios # ./configure --prefix=/usr/local/nagiosOnce the configuration process completes we need to modify a couple of files prior to compiling:
- Add the following line as line 28 of the
- Comment out the following line (line 144) in the
- Change the following line (line 27) in the
./base/utils.cfile from this:
#include "../include/comments.h"To this:
- Change the following line (line 29) in the
./cgi/Makefilefile from this:
CFLAGS=-Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGITo this:
CFLAGS=-Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -I/usr/include/gd2
- Add the following line as line 28 of the
- Rub the following command to compile nagios:
# gmake all cd ./base && make gmake: Entering directory `/root/nagios/base' gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o broker.o broker.c gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nebmods.o nebmods.c gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o ../common/shared.o ../common/shared.c gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o checks.o checks.c gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o config.o config.c ...
- One compilation has completed, use the
# gmake install # gmake install-commandmode # gmake install=config
- Now add the following lines to /usr
/local/nagios/etc/cgi.cfgto get the correct authorisation for nagios:
default_user_name=nagiosadmin authorized_for_system_information=nagiosadmin authorized_for_system_commands=nagiosadmin authorized_for_configuration_information=nagiosadmin authorized_for_all_hosts=nagiosadmin authorized_for_all_host_commands=nagiosadmin authorized_for_all_services=nagiosadmin authorized_for_all_service_commands=nagiosadmin
Building nagios plugins
After Nagios itself is compiled and installed, the next step is to repeat the process with the Nagios plug-ins, which enable enhanced system and service checks. At the time of writing plugins version 1.5 was available (visit Nagios plugins for the latest release)
- Download and uncompress:
# cd /usr/local/src # wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz # tar -zxf nagios-plugins-1.5.tar.gz # cd nagios-plugins-1.5
- For plugins version 1.5, we need to modify the
./configurefile and change line 18226 to the following:
elif $PATH_TO_SWAP -l 2>/dev/null | egrep -i "^swapfile +dev + swaplo +blocks +free" >/dev/null
- Compile the nagios plugins:
# ./configure --prefix=/usr/local/nagios
- Install the plugins
# gmake install
Configure Apache for Nagios
To configure Apache for use with Nagios, add the following code to your Apache config file. In this case the file is located in
<IfModule alias_module> ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" Alias /nagios /usr/local/nagios/share </IfModule> <Directory "/usr/local/nagios/sbin/"> Options ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> <Directory "/usr/local/nagios/share"> Options None AllowOverride None Order allow,deny Allow from all </Directory>
Create nagiosadmin user account
You'll need to create an Apache user account to be able to log into Nagios. The following command will create a user account called nagiosadmin and you will be prompted to provide a password for the account.
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Starting Apache Web Server and Nagios Server
Once Apache is configured for Nagios, simply enable and start the web server:
# svcadm enable apache2 # svcs apache2 STATE STIME FMRI online 17:14:22 svc:/network/http:apache22
Enable and start the Nagios core services:
# svcadm restart manifest-import # svcadm enable nagios
Nagios is now running, to confirm this you need to log into the Nagios Web interface. Point your browser to the
ip address or
FQDN of the Nagios core server, for example:
Nagious has a number of configuration files located in:
Whilst this article dealt with the compilation and installation of Nagios on the Solaris 11 OE, we do no cover the entire configuration; Review the Nagios online documentation which goes into detail on configuring Nagios.