-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nagios 4 installation and configuration #59
Comments
Please do not close or resolve, so that other users can land and find useful information on a working setup for Nagios 4. I will create a full step-by-step guide on this page before resolving. If you would like to contribute, and you have tried to install Nagios4 package from the distribution repository, please let me know if the installation succeeded or failed and what version were you installing on. This would save me a lot of time. You are welcome to ask questions or comment. |
Hi @costarican, if you would like to create a Nagios 4 page to replace the old one your contribution would be very welcome! This has been raised as a long-standing problem and we would love to be able to deprecate the Nagios 3 content in favour of more up-to-date instructions. I'd be very happy to help in any way I can - if there's anything you need please let me know :) |
Thank you. I will be working on this in the coming days (very actively). I will be borrowing a lot from Nagios.com since I tested their instructions and tested working. A few days later: @s-makin I started to work on this: Work in progress TENTATIVE GUIDE Nagios Core 4 installation and configuration The monitoring of essential servers and services is an important part of system administration. This guide walks through how to install and configure Nagios Core 4 for availability monitoring. The example in this guide uses two servers with hostnames: server01 and server02. Server01 will be configured with Nagios to monitor services on itself and on server02, while server02 will be configured to send data to server01. Two users will be created: nagiosadmin with full administrative access, and user nagiosuser with viewing access only. Installation On server01, install the nagios 4 package and NRPE plugin, by entering the following command into your terminal:
Notes: package will install Postfix by default. You will be prompted for mail server information. If you don't have a FQDN mail server or want to do the configuration at a later time, you can choose the "No configuration" option, from the Postfix Configuration dialog. See documentation on how to install and configure Postfix. https://documentation.ubuntu.com/server/how-to/mail-services/ . It is also recommended that server01 is setup with a fully qualified domain name (FQDN). Refer to the docmentation on how to configure DNS, https://documentation.ubuntu.com/server/how-to/networking/install-dns/#install-dns. The NRPE plugin package will be used to collect data from server02. Creating a user for accessing the Nagios web interface After installation of Nagios 4 on server01, create the nagiosadmin user: On server01, enter into the terminal:
Note: the htdigest tool is installed by default by nagios 4 core package. "Nagios4" here is the realm argument provided in directive AuthName in the /etc/nagios4/apache2.conf file. More information on this will be provided later when we configure the nagios server on server01. Use the -c only when creating the user for the first time. For more information on the htdigest tool see Nagios documentation on CGI security. https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/cgisecurity.html Moving on to server02. Next, on server02 install the nagios-nrpe-server package. From a terminal on server02 enter:
Note: NRPE allows you to execute local checks on remote hosts. There are other ways of accomplishing this through other Nagios plugins, as well as other checks. Back on server01. Before starting to configure the Nagios server it is important to understand the location of directories containing Nagios configuration and check files. Nagios. Apache. Configuration Steps
to
Save file and close. Apache configuration for nagios
On the next step, edit /etc/nagios4/apache2.conf to complete the digest authentication configuration for the Nagios web interface. Edit file /etc/nagios4/apache2.conf file, and change the following lines: comment out the Require ip directive (add a # in front of it):
This line was enabled by default, to only allow private IP addresses access. If that is what you need, then leave un-commented. Inside the
Forcing All users to authenticate. The next step is going to force ALL users to authenticate.
and its closing bracket:
This has the effect of moving all directives that were inside the Apache configuration file for Nagios is now configured. Notes: the Alias /nagios4, in directive Nagios Web Interface At this point, the web interface is not working as intended.
Then enable the configuration. From terminal enter:
Nagios web interface apache site is now enabled. It is time to reload both Apache2 and Nagios to apply configuration changes. From terminal enter:
then enter:
Check the status of Nagios and Apache2. Examine output for any errors. From terminal run:
then run:
If both are active(running) and no errors are reported, then the web interface can be tested. Notes: For information on how to configure Apache2, please refer to the how-to documentation. https://documentation.ubuntu.com/server/how-to/web-services/install-apache2/#install-apache2. Troubleshooting will be reviewed later. Modifying the Nagios Apache site At this point, the Nagios site can be tested. From a browser enter: server01/nagios4 and press Enter. Alternatively, if the hostname does not resolve to DNS, enter the ip address: 172.10.100.1/nagios4. Replace the ip address, with the ip address of your Nagios server. You will asked to authenticate. Login as the user nagiosadmin that was created earlier. You will notice that under hosts, only the localhost is being monitored. More on working with objects later. To illustrate making modifications to the Nagios site, landing server01/nagios4 is going to be changed to server01/nagios.
to
Save file and quit. To activate change, disable the nagios4 site first. Enter into terminal:
Then copy the /etc/nagios4/apache2.conf file to the /etc/apache2/sites-available directory. From the terminal run:
Enable the configuration. From terminal enter:
And reload Apache2:
To test the change, enter into a browser: server01/nagios. Note: you can directly edit the /etc/apache2/sites-enabled/nagios4.conf file and then reload Apache2, without disabling the site first, but this makes it harder to keep track of changes and restoring to a working state, in case something goes wrong. It is a good idea to always backup the file before making any changes, so you can quickly restore from it, in case of issues. Working with Nagios users So far, the only user with access to nagios is nagiosadmin. In the next steps, a nagiosuser will be created and configured to have viewing access to nagios. On server01, enter in the terminal:
At this point, nagiosuser is created but no access has been defined. To define access, edit file /etc/nagios4/cgi.cfg and change the following line:
to To allow user to view global hosts and services, define access by changing these lines:
to
Save file and quit. Reload the nagios configuration:
To test, navigate in a browser to server01/nagios and login as user nagiosuser. Click on Hosts, Services links. You should be able to view both. Then look for System, Configuration links. When trying to access the Configuration, a no permission to view information message should be displayed. Notes: When using the htdigest utility, use the -c only when first creating a user. Omit the -c to change password afterwards. The /etc/nagios4/cgi.cfg has many options. Review file for usage. Working with resource objects Objects are definitions files for each one of the resources available in Nagios. Files are located in the /etc/nagios4/objects directory. Creating host config file for server02 To create host config file for server02, on server01, type into terminal:
Then, edit file /etc/nagios4/conf.d/server02.cfg. Change the host definition. Replace address with the ip address of server02. On existing definitions, replace host_name with server02.
Also add a DNS check service definition. Add these lines:
Save the file and exit. Testing the Nagios configuration When you make changes to the Nagios configuration, you can test the configuration before it is enabled. This way you can make the necessary chages, in case of errors, before restarting the Nagios server. Still on server01, enter into the terminal:
If no errors are found, restart the nagios server. In the terminal enter:
Hostgroup definitions Now create a hostgroup definition, which is used to group one or more hosts together for easier configuration. In this step you will create a service definition for the MySQL check and a MySQL hostgroup definition. To install the MySQL server, you can run into a terminal:
Note: For instructions on installing MySQL see documentation at https://documentation.ubuntu.com/server/how-to/databases/install-mysql/#install-mysql. For a very useful tutorial on how to install MySQL see https://www.tutorials24x7.com/mysql/how-to-install-mysql-8-on-ubuntu-2004-lts. See also MySQL documentation at https://www.mysql.com. Also check the man pages for MySQL. For the purpose of this guide, MySQL server has been installed on server02. Add a service definition for the MySQL check and the hostgroup mysql-servers definition Add a service definition to the file /etc/nagios4/conf.d/services_nagios2.cfg:
Add the mysql-servers definition. Edit /etc/nagios4/conf.d/hostgroups_nagios2.cfg:
Nagios user authentication to MySQL The Nagios check needs to authenticate to MySQL. Add a nagios user to MySQL. On server02, enter into the terminal:
Alternatively, you can login to MySQL and create the nagios user. Replace secret with a password.
Note: The nagios user will need to be added to all hosts in the mysql-servers hostgroup. Restart nagios to start checking the MySQL servers. On server01, enter into the terminal: sudo systemctl restart nagios4 NRPE Configuration As a last step. configure NRPE to check disk space on server02. On server01, add the service check to /etc/nagios4/conf.d/server02.cfg:
On server02, edit /etc/nagios/nrpe.cfg changing:
Below, in the command definition area, add:
While on server02, restart nagios-nrpe-server:
Finally, on server01 restart Nagios:
|
Please describe the question or issue you're facing with "How to install and configure Nagios Core 3 - Ubuntu Server documentation".
User guide for Nagios 4 not setup for Ubuntu. Could I be allowed to create Nagios 4 installation and configuration page? Nagios page is still pointing to Nagios 3 setup and users are ending up with broken installations.
Reported from: https://documentation.ubuntu.com/server/how-to/observability/install-nagios/
The text was updated successfully, but these errors were encountered: