Konfigurasi Nagios

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

1) Install pre-requisites

To have nagios well working, you need apache2 and php to be installed and
correctly configured. If you have not yet these packages installed, you can do
it with the command below.

# apt install apache2 apache2-utils php

In this article, the configuration of the above packages will be not detailed.
There are some other pre-requisites packages to install as below

# apt install -y build-essential autoconf gcc libc6 make wget unzip libgd2-xpm-dev

2) Create Nagios user and group


You'll need a default user and group on nagios for the system to run under.
The default user will be nagios and the default group will be nagcmd.nagios
You can turn off logins for this user once everything is installed

# useradd nagios && groupadd nagcmd

# usermod -a -G nagcmd nagios && usermod -a -G nagcmd www-data

3) Install and build Nagios 4.3.2 from source


code
a) Download nagios
We will download nagios from the official github site. We will create our
working directory at /opt/nagios

# mkdir /opt/nagios

# cd /opt/nagios

Now download nagios

# wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-


4.3.2.tar.gz
# tar xzf nagioscore.tar.gz

# cd nagioscore-nagios-4.3.2/

b. Install and configure nagios


Now we will configure, compile and install nagios.

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


--with-httpd_conf=/etc/apache2/sites-enabled/

# make all
You can that it helps you by giving you next configurations steps to follow and
description. Now we will install the binary files, CGIs, and HTML files

# make install

We will install the service or daemon files and also configure them to start on
boot

# make install-init

Now install and configure the external command file

# make install-commandmode
Now install the *SAMPLE* configuration files. These are required as Nagios
needs some configuration files to allow it to start.

# make install-config

Then install the Apache web server configuration files and configure the
Apache settings.

# make install-webconf

# a2enmod rewrite && a2enmod cgi

4) Configure nagios web interface


The web interface requires login so we will create a nagiosadmin account and
record the password that we will assign

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

New password:

Re-type new password:

Notice that you will use this user and password to log into you nagios web
interface. Now restart apache service to make modifications to take effect

# systemctl restart apache2.service

5) Download and install nagios plugins 2.2.1


To work properly, nagios core needs plugins to monitor various services. You
need to make sure that you have the pre-requisites packages installed

# apt install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential
snmp libnet-snmp-perl gettext

Now we will create our working directory into /opt directory where we will
download the plugins

# mkdir /opt/nagios && cd /opt/nagios


# wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-
plugins/archive/release-2.2.1.tar.gz

# tar zxf nagios-plugins.tar.gz

# cd nagios-plugins-release-2.2.1

Now we will compile and install the plugins

# ./tools/setup

# ./configure

# make

# make install

6) Start nagios service and access to your nagios


server
Before starting nagios, we need to check if the nagios configuration file
doesn't have any error

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

........................

........................

Total Warnings: 0

Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

As it looks fine, now let's make nagios services start on startup

# systemctl enable nagios


# systemctl reload nagios

Now we can start the nagios service

# systemctl start nagios

Note that if you don't start the nagios service, you will have an error message
at you nagios homepage.

Now you can access to your web interface at the


address http://nagios-ip/nagios via your web browser. If you server has an
interface environment, so you can open your web browser and use the
link http://localhost/nagios. You will be asked to enter the username and the
password. Below are the values that I have configured

 username: nagiosadmin
 password: nagios

Then you will have the following homepage

Now you can go to Hosts or Services menu list to the left side in order to see
you server and services monitored.
You can see that the default monitored services of our server.

7) Configure Firewall
If you can not access to your web interface, you should check your firewall
configuration.

By default on Debian 9, it seems that ufw is not installed but iptables is


installed. So, you will certainly need to allow port 80 inbound traffic on the
local firewall to reach the nagios core web interface.

# iptables -I INPUT -p tcp --destination-port 80 -j ACCEPT

# apt install -y iptables-persistent

Save the firewall configuration

# iptables-save

But if you prefer ufw as firewall instead of iptables, use the command below

# ufw allow Apache

# ufw reload

Now restart all service again to check


# systemctl restart nagios

# systemctl restart apache2.service

You might also like