Ever had to change a switch and labeled all the cables? No longer! Use this printable RJ45 Switch tool to connect all the cables while replacing the switch.
This tutorials shows you how to install Nagios Core (version 4.5.3), including the Nagios Plugins (version 2.4.10) and NConf (version 1.3.0-0) on Debian 12. Nagios Core and NConf use ancient versions of PHP and MySQL so we have to use external repositories and packages.
Start with installing Debian 12. You can download the version I used for this tutorial here. Install Debian without a desktop-environment but do install the SSH server and standard system utilities. This tutorial is written without entering a root password when installing Debian, thus having the main user having sudo-permissions.
When your server is installed and booted, use your favorite tool to connect using SSH and log in. Make sure your are logged in as super user:
# sudo su
Install GnuPG en Curl:
# apt update && apt install gnupg curl -y
Execute following commands to add the PHP 5.6 repository and add it’s key:
Download, install and configure Nagios Core 4.5.3:
# cd /tmp
# wget https://downloads.dennisbor.com/nagios-4.5.3.tar.gz
# tar -zxvf nagios-4.5.3.tar.gz
# cd nagios-4.5.3
# ./configure --with-httpd-conf=/etc/apache2/sites-enabled
# make install-groups-users
# make all
# make install
# make install-daemoninit
# make install-commandmode
# make install-config
# make install-webconf
# a2enmod rewrite cgi
Download, install and configure the Nagios plugins:
# cd /tmp
# wget https://downloads.dennisbor.com/nagios-plugins-2.4.10.tar.gz
# tar -zxvf nagios-plugins-2.4.10.tar.gz
# cd nagios-plugins-2.4.10
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
Add the Nagios user to the www-data group:
usermod -aG www-data nagios
Configure the firewall to allow connections on port 80 (web server) and 22 (SSH) and enable it:
# ufw allow 80
# ufw allow 22
# ufw enable
Restart Apache (the web server), start the Nagios-service en enable at boot:
# cd /tmp
# wget https://downloads.dennisbor.com/mysql-server_5.7.42-1debian10_amd64.deb-bundle.tar
# tar xf mysql-server_5.7.42-1debian10_amd64.deb-bundle.tar
If an error is displayed, regarding unmet or broken dependencies, fix it:
# apt --fix-broken install -y
Log on to the MySQL-server with the previously set root-password:
# mysql -u root -p
Create database nconf, create a default user (I will give it the name nconfadmin), set a password and grant the required privileges to the database:
mysql> CREATE DATABASE nconf;
mysql> CREATE USER nconfadmin@localhost IDENTIFIED BY 'nconfpassword';
mysql> GRANT ALL PRIVILEGES ON nconf.* TO nconfadmin@localhost;
mysql> FLUSH PRIVILEGES;
mysql> EXIT
Restart the web server:
# systemctl restart apache2
When browsing to http://<IP_ADDRESS>/nagios/nconf/INSTALL.php, you will see we meet all requirements for NConf 1.3.0:
Click Next to start the configuration. Use ‘nconf’ for DBNAME, ‘nconfadmin’ for DBUSER and the previously set password for DBPASS. Click on Next. If the settings and credentials are entered correclty, a connection with the database is established and database tables are created.
Click Next and do not change anything in the next screen.
Klik op Next. Choose ‘TRUE’ for AUTH_ENABLED which requires users to log on to NConf. Choose an administrator-password for file_admin_password. This will protect the user-file.
Click Next. When everything is configured properly, you will see nine green OK’s:
Head back to your server and remove the NConf installation and temporary files:
To prevent permission issues, run the following commands (please note the removal and re-creation of the temp-folder, which for me was the only way to get access):
By default, the Nagios pages display errors instead of the host images, so we have to move them to the proper path:
# mkdir /usr/local/nagios/share/images/logos/base
# cd /usr/local/nagios/share/images/logos
# mv * base
Please note that the latter will give you a warning because it can’t move the subfolder into itself. You can ignore this.
Nagios and NConf are ready to use. All you have to do is to configure Postfix for sending e-mail notifications.
Need to monitor a Windows Server? Don’t forget to install the NSClient++ to enable monitoring. You can download it here.
Did this tutorial help you and save you some precious time? Consider donating. Every donation will be invested in my IT career.
Localization
By default, Nagios uses US localization. You can however change this setting to one of the following:
Format
Date/time is display as
us
MM-DD-YYYY HH:MM:SS
euro
DD-MM-YYYY HH:MM:SS
iso8601
YYYY-MM-DD HH:MM:SS
strict-iso8601
YYYY-MM-DDTHH:MM:SS
Possible localization options in Nagios
To change the localization, modify the Nagios configuration file:
# nano /usr/local/nagios/etc/nagios.cfg
Search for the line containing date_format and change it to your preferred value (European in the following example).
date_format=euro
Save the file and reload Nagios for the changes to take effect.
Updating Nagiosfrom 4.5.2 to 4.5.3
If you are still using Nagios Code 4.5.2 and would like to update to 4.5.3, use the steps below.
First backup your old Nagios installation, just in case!
# tar -cvf /tmp/nagios_backup.tar /usr/local/nagios
Stop both Nagios and Apache
# systemctl stop nagios apache2
Download Nagios Code 4.5.3:
# cd /tmp
# wget https://downloads.dennisbor.com/nagios-4.5.3.tar.gz
Unpack the archive and enter the folder:
# tar -zxvf nagios-4.5.3.tar.gz
# cd nagios-4.5.3
We need LibC6 development tools for compiling:
# apt install libc6-dev -y
Configure, compile and install Nagios:
# ./configure --with-httpd-conf=/etc/apache2/sites-enabled
# make all
# make install
Start both Nagios and Apache
# systemctl start nagios apache2
Finished!
Common issues
Please see the text below to solve the most common problems configuring / deploying. Stuck on another error? Do not hesitate to contact me!
Error: Service has no hosts and/or service_description (config file ‘/usr/local/nagios/share/nconf/temp/Default_collector/advanced_services.cfg’, starting on line 120)
This error is displayed when you delete hosts and there are advanced services without linked hosts left. Make sure all advanced services are linked to at least one host or otherwise delete them.
New hosts are not displayed in Nagios
This has to do with the folder permissions. Execute following command:
Als je verbinding wilt maken met een computer, waarop ingelogd wordt met een Microsoft account, zorg je dat je eerst de account registreert in Windows door een opdracht uit te voeren (als admin):
Ontdekte bug: Bij het verzetten van de klok van winter- naar zomertijd werden alle stekkers uitgeschakeld. Na het herstart werkte alles weer naar behoren.