Monitoring the uptime of your virtual private servers is an essential part of guaranteeing maximum uptime for your web facing assets. As a result, many VPS enthusiasts have exclusively chosen Nagios as their uptime monitoring suite.
Nagios is an open source uptime monitoring app that is used extensively by server administrators all around the world. If a problem is detected on one of your virtual private servers, Nagios can be configured to immediately alert an administrator of the issue.
When it comes to free open-source uptime monitoring software, Nagios is considered the gold standard. Nagios gives administrators expert insight into services such as:
- CPU Usage
- Memory Consumption
- Disk Performance
- Log Files
- HTTP Logs
- SMTP Monitoring
- DNS Uptime
Nagios can also be modified using plugins to get the exact uptime metrics of specific services used by your VPS. In this article, we will setup Nagios on a low end box and use this VPS to remotely monitor other virtual private servers in your fleet.
How to Setup Your First Instance of Nagios
First, let’s setup Nagios on low end VPS and configure it to monitor itself. After this is setup, we can deploy Nagios to other servers that we may want to monitor remotely. Please note that the instructions in this article pertain to the Ubuntu 16.04 operating system.
Here are a few prerequisites for getting started with Nagios:
- Root access
- Apache
- PHP
We will assume that you are logged in the VPS with your root account. If you aren’t, you will need to use all the commands below by prepending ‘sudo’. Let’s start running the following commands to make sure our system is up to date and that we have all the required modules:
Next, let’s create a user for Nagios with the following commands:
We are now ready to install Nagios. Let’s download the app and install it using the following commands:
If you haven’t encountered any errors, the Nagios Core should be completely installed. We need to execute a few more commands before Nagios is fully functional.
Type the following into an SSH window:
The next step is to edit the Nagios configuration file. This is the part where you’ll input your email address so that you can get the alerts generated from the servers. Use the following command to open the config file.
And change the following line:
To the address that should receive the alerts.
Now that this is complete, we will need to open this file with your favorite editor:
and comment each occurrence the following lines:
Don’t forget to enable Apache’s rewrite and CGI modules:
Before restarting the webserver, open the following configuration file:
And change the following line from:
to
Now it’s time to restart the webserver. This will load the new configuration file. You can restart Apache using the following command:
Now that our environment is ready, let’s create a configuration file that helps us monitor services. Use the following command to add the new file to the Nagios configuration:
Create and open the new file with your favorite editor and add the following content changing the X.X.X.X with the IP address of the server you want to monitor:
In this test, we are only performing a basic ping to monitor the server’s response. Be sure to check out Nagio’s configuration file webpage for tips on how to further customize your uptime monitoring services.
We’ll want Nagios load when the system is booted up, therefore we must verify that the configuration file has no errors. Use the following command:
And you should get the following 2 lines at the end of the output:
Total Warnings: 0
Total Errors: 0
We are now ready to start Nagios service:
Nagios will be available on HTTP port 80 by default. Open your favorite browser and navigate to
Click on the “Services” link located on the left side of the webpage in order to access the list of monitored services. You should be able to monitor the availability of both the local and remote server that we have configured in the steps above.
If they do not appear to be green, give it some time. The service will run regular tests in order to check the availability of the services. Since we just started Nagios for the first time, it will require a bit of time to complete the first check.
Important: Make sure that the remote server has no firewall on the ICMP protocol. Otherwise, the test will fail and you will receive an alert from Nagios that the server is unreachable.
Congratulations! You have installed and configured Nagios on your virtual private server.
No comments:
Post a Comment