TECHIES WORLD

For Techs.... Techniques.... Technologies....

ApacheCpanelLinuxMysqlPHP

How to install Nagios with Nconf

Nagios Core, is a free and open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.

NConf is a PHP based web-tool for configuring the Nagios monitoring software. It differs from similar tools by offering enterprise-class features like templates, dependencies and the ability to configure a large-scale, distributed Nagios topology.

This tutorial explains the detailed steps for configuring Nagios with Nconf.


INITIAL CONFIGURATION

Step1: Install LAMP server and complete the configurations

Step2: Install the dependent packages

#yum install gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel unzip


NAGIOS INSTALLATION

Step1: Create nagios user and assign group

#useradd nagios

#groupadd nagcmd

#usermod -a -G nagcmd nagios

Step2: Download the latest version of nagios core from "https://www.nagios.org/downloads/nagios-core/"

#wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.4.tar.gz

Step3: Extract the downloaded package

#tar xvf nagios-*.tar.gz

Step4: Change the location to extracted folder

#cd nagios-*

Step5: Compile and install the package

#./configure --with-command-group=nagcmd

#make all

#make install

#make install-commandmode

#make install-init

#make install-config

#make install-webconf

#usermod -G nagcmd apache


NAGIOS PLUGIN INSTALLATION

Step1: Download the nagios plugin source from "http://nagios-plugins.org/download/"

#wget http://nagios-plugins.org/download/nagios-plugins-2.1.4.tar.gz

Step2: Extract the downloaded package

#tar xvf nagios-plugins-*.tar.gz

Step3: Change the location to extracted folder

#cd nagios-plugins-*

Step4: Compile and install the package

#./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl

#make

#make install


NRPE INSTALLATION

Step1: Download the nrpe source from "https://sourceforge.net/projects/nagios/files/nrpe-2.x/"

#wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

Step2: Extract the downloaded package

#tar xvf nrpe-*.tar.gz

Step3: Change the location to extracted folder

#cd nrpe-*

Step4: Compile and install the package

#./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

#make all

#make install

Step5: Copy the nrpe sample configuration file

#cp sample-config/nrpe.cfg /usr/local/nagios/etc

Step6: Start nrpe service

#/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d


NAGIOS CONFIGURATION

Note: If going to use Nconf for management, you can skip this section and continue with Nconf configuration.

Step1: Open nagios configuration file

#vi /usr/local/nagios/etc/nagios.cfg

Step2: Uncomment the following line and save the file

#cfg_dir=/usr/local/nagios/etc/servers

Step3: Create folder for saving the hosts configuration files

#mkdir /usr/local/nagios/etc/servers

Step4: Open contact configuration file

#vi /usr/local/nagios/etc/objects/contacts.cfg

Step5: Update the contact email address

#email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

Step6: Open command configuration file

#vi /usr/local/nagios/etc/objects/commands.cfg

Step7: Add nrpe check command at the end of the file and save it

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

Step8: Configure htacces authentication

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

Step9: Open new file for savinf the details for new host

#vi /usr/local/nagios/etc/servers/yourhost.cfg

Step10: Update the details for new host (sample syntax given below)

define host {
use linux-server
host_name yourhost
alias My first Apache server
address 10.132.234.52
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}

define service {
use generic-service
host_name yourhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}

define service {
use generic-service
host_name yourhost
service_description SSH
check_command check_ssh
notifications_enabled 0
}

Step11: Verify nagios configuration file syntax

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

Step12: Start the nagios service

#/etc/init.d/nagios start
That's all.. now the nagios web interface is available in the url "http://serveripaddress/nagios"


NCONF INSTALLATION AND CONFIGURATION

Step1: Download the latest version of Nconf from "https://sourceforge.net/projects/nconf/files/nconf/"

#wget http://downloads.sourceforge.net/project/nconf/nconf/1.3.0-0/nconf-1.3.0-0.tgz

Step2: Extract the downloaded package

#tar xvf nconf*.tgz

Step3: Move the extracted nconf folder to nagios document root

#mv -vf nconf /usr/local/nagios/share/

Step4: Assign permissions to the webserver user on nconf folder. Note that the webserver user will be different on different distributions

#chown -R nobody.nobody /usr/local/nagios/share/nconf

Step5: Assign execute permission to nagios binary file

#chmod 777 /usr/local/nagios/bin/nagios

Step6: Create mysql database, user for nconf and assign privileges

Step7: Browse the weburl "http://nconf_server_ip/nagios/nconf/INSTALL.php" and complete the installation

Step8: Open the nagios configuration file

#vi /usr/local/nagios/etc/nagios.cfg

Step9: Comment out all Nagios default configuration files

# You can specify individual object config files as shown below:
#cfg_file=/usr/local/nagios/etc/objects/commands.cfg
#cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
#cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
#cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
# Definitions for monitoring a router/switch
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
# Definitions for monitoring a network printer
#cfg_file=/usr/local/nagios/etc/objects/printer.cfg

Step10: Add nconf configuration directories and save the nagios configuration file

cfg_dir=/usr/local/nagios/etc/global
cfg_dir=/usr/local/nagios/etc/Default_collector

Step11: Create deployment configuration for Nconf

#vi /usr/local/nagios/share/nconf/config/deployment.ini

Step12: Update the below content and save the file

;; LOCAL deployment ;;
[deploy config]
type = local
source_file = "/usr/local/nagios/share/nconf/output/NagiosConfig.tgz"
target_file = "/usr/local/nagios/etc/"
action = extract
reload_command = sudo /etc/init.d/nagios restart

Step13: Add nagios reload command to apache user and remove the default reuiqre tty setting in sudo configuration file

#Defaults requiretty
apache ALL = NOPASSWD: /etc/init.d/nagios restart

Step14: Copy Nagios images to the right directory

#cp -a /usr/local/nagios/share/images/logos /tmp/base
#mv /tmp/base /usr/local/nagios/share/images/logos/base

Step15: Browse to http://nconf_server_ip/nagios/nconf and generate and deploy nagios configuration files

Now we can manage the Nagios configurations via Nconf web url.

 

Leave a Reply