The purpose of this article is to show how to automatically install the Nagios server and the NRPE clients using the prearranged python scripts.

First of all, you must activate root access on all hosts (server and clients).

The following are the list and scheme of Nagios server and clients machines:

nagios-logo-720345

Server:

  1. Ubuntu 14.04

Clients:

  1. Ubuntu 14.04
  2. FreeBSD 10.3
  3. Centos 6.7
  4. CentOS7

fan

Now we start Full automated Nagios installation

After you have activated the root access and performed the system update on all machines, you must perform one additional step on FreeBSD. Install bash and copy the shell executable from /usr/local/bin/bash to /bin/bash.

# pkg install -y bash vim
 # cp /usr/local/bin/bash /bin/bash
 # chsh -s /usr/local/bin/bash root ; reboot

Now we can prepare a Linux desktop, install the git package on it and copy all necessary scripts from the repository.

# git clone https://github.com/jamalshahverdiev/full-automated-nagios.git

Execute the python-installer.sh to automatically install python2.7, python3.4, and all necessary libraries.

# cd full-automated-nagios
 # ./python-installer.sh

Automated scripts consist of the following parts:

fpyvenv fully-automated-nagios # ll
 total 36
 -rw-r--r--  1 root  wheel    14B Sep 25 14:41 clients.txt
 drwxr-xr-x  2 root  wheel   512B Sep 24 21:48 jinja2temps
 -rwxr-xr-x  1 root  wheel   5.7K Sep 25 09:28 nagios-clients.py
 -rwxr-xr-x  1 root  wheel   3.9K Sep 25 01:15 nagios-server.py
 drwxr-xr-x  2 root  wheel   512B Sep 24 21:46 ngclout
 drwxr-xr-x  2 root  wheel   512B Sep 24 21:09 output
 -rwxr-xr-x  1 root  wheel   2.9K Sep 25 09:30 python-installer.sh
 -rwxr-xr-x  1 root  wheel   1.7K Sep 25 09:27 run.py
 -rwxr-xr-x  1 root  wheel   1.7K Sep 25 09:27 README.md

clients.txt – List of IP addresses for all Nagios clients.
nagios-clients.py – Automatic installation of Nagios Server.
nagios-server.py – Automatic installation of Nagios Clients.
run.py – Installation lunch script with an interactive menu.

Please, execute the following to start the installation ( Full automated Nagios installation ) :

 fpyvenv fully-automated-nagios # ./run.py


The Program is going to install and configure the Nagios server automatically.
 It is supposed that you have already added all IP addresses of client hosts to the 'clients.txt' file.
 Users must be 'root' with the same passwords on all hosts ...

=====================================================================================

Choose one of following options:
  1. To install and configure Nagios server, type 1 and press 'Enter'.
  2. To install and configure 'Nrpe' agents on all client hosts, type 2 and press 'Enter'.
  3. To exit type 3 and press 'Enter'.
Please choose the installation option: 1

Please enter the following parameters to proceed to the installation of Nagios server:
 IP address: 172.16.100.10
 Name of superuser: root
 Superuser password: serverrootpass

The remote server identified as Ubuntu...

Please wait while installing 'Apache2'...

Please provide passwords for MySQL 'root' user and 'nagiosadmin' web user:

Please enter password for MySQL "root" user: mysqlrootpass
 Please repeat password for MySQL "root" user: repeatmysqlrootpass

Please enter password for "nagiosadmin" user: webadminpass
 Please repeat password for "nagiosadmin" user: repeatwebadminpass

Please wait while installing 'MySQL'...

Installation of Nagios server and plugins is in progress…

Nagios server successfully installed and configured!!!

You will automatically return to the menu after successful installation of Nagios server. Now select installation of clients.

Choose one of following options!!!
  1. To install and configure Nagios server, type 1 and press 'Enter'.
  2. To install and configure 'Nrpe' agents on all client hosts, type 2 and press 'Enter'.
  3. To exit type 3 and press 'Enter'.
Please choose the installation option: 2

It is supposed that you have already added all IP addresses of client hosts to the /root/pythoncodes/fully-automated-nagios/clients.txt file.
 The password for all Nagios clients and server must be the same!!!

Please enter superuser: root
 Please enter password for superuser: freebsd
 ==================================================================
 Please enter IP address of the Nagios server: 172.16.100.10

The remote server identified as CentOS 7…
 Installation and configuration of 'Nrpe' necessary plugins are in progress…

The remote server identified as CentOS 6…
 Installation and configuration of 'Nrpe' necessary plugins are in progress…

The remote server identified as FreeBSD…
 Installation and configuration of 'Nrpe' necessary plugins are in progress…

The remote server identified as Ubuntu…
 Installation and configuration of 'Nrpe' necessary plugins are in progress…

Nrpe and necessary plugins successfully installed and configured on all servers.

At the end type 3 to exit the program

Choose one of following options!!!
  1. To install and configure Nagios server, type 1 and press 'Enter'.:
  2. To install and configure 'Nrpe' agents on all client hosts, type 2 and press 'Enter'.
  3. To exit type 3 and press 'Enter'.

Please choose the installation option: 3

Done
Your nagios Server + Clients are installed in one go .

Please test this wonderful script and let us know your feed back about.

 

 

Advertisements