Nagios →A DevOps tool (part -2 →installation )

Aakib
2 min readMar 6, 2023

--

In part 1 we discussed about basics of Nagios ,features and architecture …

Here we discussed How to install nagios on linux →

Pre-requisite for Nagios → means what you needed in your device before installing nagios

  1. Apache 2.0( a broswer)
  2. Php (dashboard)
  3. Gec and gd (compiler to convert raw code into binaries)
  4. Makefile ( to build)
  5. perl( Script)
  6. Main configuration file path → /usr/local/nagios/etc/nagios.cfg

Install Nagios on Linux →

Step 1→ Install pre-requisite software on your linux machine prior to changes installation like Apache,php, GCC compiler and GD development libraries.

  1. apt install apache 2.0 php
  2. apt install gcc glibc glibc — common
  3. apt install gd gd -devel

Step 2 → create account information you need to set up for Nagios user Run the following commands.

  1. //create a new user → add user -m nagios
  2. passwd nagios // now it asks to enter a new password
  3. groupadd nagioscmd
  4. usermod -a -G nagioscmd nagios
  5. usermod -a -G nagioscmd apache

Step 3 download nagios core and plugins create a directory for storing downloads

  1. mkdir ~/downloads
  2. cd ~/downloads

Step 4 → download the source code Tar balls of both Nagiosn and the Nagios plugins

  1. wget https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbGI3X1phUWNtdGNVNzA0dWNkMkRranJqZW1QZ3xBQ3Jtc0tsbEdfWmxBMDc0anBBN0QyeFcweWZsV1hheTBkYUtFdEJMTlFKc1J6YWRQSDRNTDhETThxTG1fVWpBUWJRemM4MVlKOVZDNUs2S29lTmJaNnpGRFBLUG01LVQtc3prVmV0b3RWaUhVY2EyQU1ndjk3QQ&q=http%3A%2F%2Fprdownloads.sourceforge.net%2Fsourceforge%2Fnagios%2Fnagios-4.0.8.tar.gz&v=H9uRoLS_8ks
  2. wget https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqblBOUDU5TlAyeUZKWWhGWnd5ZlEwQVFsQ0JpUXxBQ3Jtc0tuODBJRWVvUHFPQjdJNlF0VnhKaE1oRUJmcUtsaUoyMTVVMEFvdTVVNk56ZTFTck41Y2dNT2R5MUZhdFFtMTNkRVFQaXdBNXhyTTZkUDJPTkNEM1FwWWh0azgyWUx6UGsxcnNNSnVvZG83MXRGenlLTQ&q=http%3A%2F%2Fnagios-plugins.org%2Fdownload%2Fnagios-plugins-2.0.3.tar.gz&v=H9uRoLS_8ks

Step 5 → compile and install Nagios. Extract the nagios source code

  1. tar zxvf nagios-4.0.8.tar.gz
  2. cd nagios-4.0.8

Step 6 → Run the configuration script with the name of the group which you have created in above step

  1. ./configure — with-command-group=nagioscmd

Step 7→ compile the nagios source code

  1. make all

Step 8→ Install binaries , init script, sample config files and set permission on the External Command directory.

  1. make install
  2. make install-init
  3. make install-config
  4. make install-commandmode

Step 9→ Config the web interface

  1. make install-webconf

Step 10→ Create Nagios admin account for login.

  1. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  2. // asking for pass → service apache restart

Step 11→ Install the plugins and compile.

  1. cd ~/downloads
  2. tar zxvf nagios-plugins-2.0.3.tar.gz
  3. cd nagios-plugins-2.0.3

step 12 → Compile install plugins

  1. ./configure — with-nagios-user=nagios — with-nagios-group=nagios
  2. make (for compile)
  3. make install

Step 13 → Start Nagios, add Nagios to the list of system services, and have it automatically start when the system boots

  1. chkconfig — add nagios
  2. chkconfig nagios on

Verify the sample Nagios configuration files →

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

If there are no errors, start Nagios →

  1. service nagios start
  2. service apache restart

Step 14→ Copy public IP of your machine and paste in Google Chrome enter following → <public ip>/nagios/

  1. username
  2. passwd

suggested video for nagios installation →https://www.youtube.com/watch?v=H9uRoLS_8ks&list=PLBGx66SQNZ8aPsFDwb79JrS2KQBTIZo10&index=44

--

--

Aakib

Cloud computing and DevOps Engineer and to be as a fresher I am learning and gaining experiance by doing some hands on projects on DevOps and in AWS OR GCP