Nagios with GitLab in Independent VPs

Date : 27-oct -2018

In this article, we are going to run two different services in single machine at different ports.Namely Nagios and GitLab are the services which be running on different ports.This will accomplished by installing the services on machine.

I.Introduction : 

Nagios Core is free & open source monitoring tool or software which can monitor the resources like servers, network equipment like firewall, network switches and printers etc. Nagios core also provides alerting services, using which nagios informs administrators about issue that has occurred & then trigger alerts again when the issue has been resolved.Nagios shows all the information regarding all the servers on a single screen using its web-interface.

GitLAB – GitLab CE (Community Edition) is an open-source application used to host Git repositories with additional features like issue tracking.GitLab CE is using your own infrastructure to host repositories which provide flexibility in deploying as an internal repository.The GitLab project makes it pretty straightforward to set up a GitLab repository on your own server with an easy installation mechanism.

II.Assumption

In this tutorial,

> we will cover how to install and configure GitLab 11.4.0 version on a CentOS 7 server.

> Nagios core released 4.3.2 version of nagios core & 2.2.1 version of nagios plugins. In this tutorial, we are going to install & configure the latest version of Nagios server on CentOS 7 / RHEL 7 server.

III.Nagios Installation

Step 1 : Installation of  essential Packages

We need to install some essential packages like apache, php & packages required for building the source packages, use below command to install these packages.

yum install httpd php gcc glibc glibc-comman gd gd-devel make net-snmp unzip -y

Step 2 : Downloading and extracting the Nagios Packages

The downlinks are given below, follow the below mentioned command

wget https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.2/nagios-4.3.2.tar.gz 

wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

to extract the packages, follow the below command,

tar -zxvf nagios-4.3.2.tar.gz

tar -zxpvf nagios-plugins-2.2.1.tar.gz

Step 3 : Create user and group for Nagios

Create user and group for Nagios

useradd nagios

passwd nagios

groupadd nagcmd

Now add the user nagios and apache user to the created group ‘nagcmd’

usermod -G nagcmd nagios

usermod -G nagcmd apache

Step 4 : Installing Nagios Core and install the complied nagios package

cd nagios-4.3.2
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config

Step 5 :Configure Nagios Core Web-Interface

For monitoring the resources of the client systems run the command,

make install-webconf

Web interface will be installed with a default user by the name ‘nagiosadmin‘ but there will be no default password for the user. We will create default password for user by issuing the following command,

htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Step 6 : Configuring email alerts

Its optional, to receive emails of nagios alerts on server activities round the clock, edit the file and save the changes,

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

after saving restart the apache,

systemctl restart httpd

Step 7 : Installing Nagios Plugins

e have now completed installation for nagios core but we need to install plugins as without them we can’t monitor the resources. So open the directory with nagios plugin files & then we will compile & install the plugins

cd nagios-plugins-2.2.1/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

Step 8 : Verification of Nagios files

Nagios configuration file is verified with the sample file configuration.

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

This process ensures that the settings made to nagios configuration are correct and now restart the nagios and apache services to implement the changes and make sure port 80 is allowed in your nagios server.

systemctl enable httpd

systemctl enable nagios

systemctl restart httpd

systemctl restart nagios

Step 9 : Changing apache default port for nagios

Edit the file by changing the default port number to 81 , Because later, Port 80 will be assign for Gitlab – Nginx service.

vi /etc/httpd/conf/httpd.conf

Step 10 : Logging into Nagios Web-interface

Type http://<ip-address>:81/nagios

After entering the credentials home page of nagios server will be displayed.

 

IV. GitLab Installation

Step 1 : Install the dependencies

The most important dependency is the “Postfix” which is provided by the official CentOS repository and you can install it using YUM with the following command.

yum install curl postfix policycoreutils-python openssh-server

After the installation process is finished, execute the following commands to start Postfix service and make it run at startup,

systemctl start postfix

systemctl enable postfix

Step 2 : Add the GitLab official package repository

By using curl command we can easily add the official repository,

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

Step 3 : Installing GitLab Community Edition

yum install gitlab-ce

Step 4 : Install Configuration

Execute the following command to start GitLab initial configuration process, it may take a few minutes (This is a completely automated process so you will not have to answer any prompt).

gitlab-ctl reconfigure

Once the above process is completed, by using IP address in the browser we can able to see the GitLab Community Edition Sigin page.

Note : Nginx will be installed along with GitLab CE installation.Nginx services will be running in port 80.

 

Now, the installation have complete and both the services are running independently in different ports successfully.Now, you are free to restore the Git-Lab backup into this new VPs along with Nagios monitoring service.

 

 

Leave a Reply