Deploying Nagios
Jump to navigation
Jump to search
Setup Details |
App Server: Nagios Network : 172.16.141.0/24 IP Address : 172.16.141.110 Subnet Mask: 255.255.255.0 Gateway: 172.16.141.1 DNS: 8.8.8.8 sudo user: kedar Container: test-server Network: 172.16.141.0/24 IP Address : 172.16.141.102 Subnet Mask: 255.255.255.0 Gateway: 172.16.141.1 DNS: 8.8.8.8 sudo user: kedar |
Before you proceed
This how to article will explain how to install Nagios Core 4 monitoring server on Ubuntu 24.04. This 'how to' will also include installing Nagios Plugins to monitor various parameters of Linux servers. This may not be the most optimal way of installing Nagios server but will help users to understand how to Nagios works, what are the various aspects of Nagios. It will include some sample configs for switches and Linux servers. A lot of documentation is available for extending the capabilities of Nagios and it is not in scope of this article.
Introduction
- Install Nagios 4 Core on Ubuntu Server - 172.16.141.110
- Install Nagios Plugins on the Nagios Monitoring server
- Install NRPE and Nagios plugins on another Linux server which needs to be monitored - 172.16.141.102
- Access the web interface to check the status of various parameters of the both the servers
Pre-requisites
- Log into the Nagios server - ssh kedar@172.16.141.110) and run the below commands
sudo apt install apache2 php8.3 libapache2-mod-php8.3 php8.3-gd wget snmp snmpd build-essential openssl libssl-dev unzip sendmail snmp-mibs-downloader nano curl autoconf gcc make libgd-dev libmcrypt-dev libssl-dev dc libnet-snmp-perl gettext inetutils-ping net-tools
- Add relevant Nagios user and user groups that will be used to run nagios
$ sudo useradd nagios $ sudo groupadd nagcmd $ sudo usermod -a -G nagcmd nagios $ sudo usermod -a -G nagcmd www-data
Installing Nagios
- Log into the Nagios server - ssh kedar@172.16.141.110) and run the below commands. This will download Nagios source and Nagios plugins source on the Nagios server from where Nagios will be compiled and installed.
$ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.5.7.tar.gz $ wget http://www.nagios-plugins.org/download/nagios-plugins-2.4.11.tar.gz
- Extract and change directory to Nagios
$ tar -xvf nagios-4.5.7.tar.gz $ cd nagios-4.5.7 nagios-4.5.7 $ ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-mail=/usr/sbin/sendmail nagios-4.5.7$ make all nagios-4.5.7$ sudo make install nagios-4.5.7$ sudo make install-commandmode nagios-4.5.7$ sudo make install-init nagios-4.5.7$ sudo make install-config nagios-4.5.7$ sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf nagios-4.5.7$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
- Create Nagios Service by adding the below code in the file: sudo nano /etc/systemd/system/nagios.service
[Unit] Description=Nagios BindTo=network.target [Install] WantedBy=multi-user.target [Service] Type=simple User=nagios Group=nagios ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
- Enable and restart Nagios, Apache
$ sudo systemctl enable /etc/systemd/system/nagios.service $ sudo a2ensite nagios.conf $ sudo a2enmod rewrite $ sudo a2enmod cgi $ sudo systemctl start nagios $ sudo systemctl restart apache2
- Nagios server is now installed
Install Nagios Plugins
- On the Nagios server, extract the Nagios plugins folder and compile
$ tar -xvf nagios-plugins-2.4.11.tar.gz $ cd nagios-plugins-2.4.11 nagios-plugins-2.4.11 $ ./compile --with-nagios-user=nagios --with-nagios-group=nagios nagios-plugins-2.4.11 $ sudo make nagios-plugins-2.4.11 $ sudo make install $ sudo systemctl restart nagios $ sudo systemctl restart apache2
Check Localhost
- With the above, Nagios and Nagios plugins have been installed
- Open any browser and type: http://<server-ip>/nagios
- It will prompt for user id & password: User I'd is nagiosadmin and password what you had kept while installing Nagios above
- You should be able to see all the services green for the host
Monitoring other hosts
- Install pre-requisites on the Linux host you want to monitor
$ sudo apt install wget build-essential openssl libssl-dev unzip sendmail nano curl autoconf gcc make libgd-dev libmcrypt-dev libssl-dev dc inetutils-ping net-tools
- Install
References
- Redmine Website - https://redmine.org
- Download Redmine - https://www.redmine.org/projects/redmine/wiki/Download
- Install Redmine - https://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_50x_on_Ubuntu_2004_with_Apache2
- How Tos - https://www.redmine.org/projects/redmine/wiki/HowTos
- Configure PostgreSQL for Redmine - https://www.redmine.org/projects/redmine/wiki/RedmineInstall
- Explore Plugins - https://www.redmine.org/plugins
- Redmine Themes - https://www.redmine.org/projects/redmine/wiki/Theme_List
- User Guide - https://www.redmine.org/projects/redmine/wiki/Guide