Post Date: December 23, 2020
Last Updated: November 22, 2026
Introduction
Nagios website monitoring helps administrators monitor server availability, network services, and website health. It allows administrators to verify whether websites are accessible and returning the expected HTTP status codes.
Nagios supports HTTP status code monitoring in Nagios through the check_http plugin, which allows administrators to check HTTP/HTTPS connectivity and validate the response status codes returned by a web server. With Nagios HTTP monitoring, administrators can identify unexpected responses, such as HTTP 500 errors, connectivity failures, and redirection issues.
In this guide, we will explain how to configure a custom Nagios command using the Nagios check_http plugin to monitor websites using HTTP status codes and apply it to a service configuration.
Prerequisites
Before configuring website monitoring in Nagios, ensure the following:
- Nagios Core is installed and running.
- The Nagios Plugins package is installed.
- The
check_httpplugin is available under the Nagios plugins directory. - Access to the Nagios configuration files with root or sudo privileges.
- The website or URL to be monitored is accessible from the Nagios server.
Nagios Website Monitoring Implementation
Step 1: Create a Custom Nagios Command
Nagios provides the check_http plugin for monitoring websites and validating HTTP response codes.
We can create a custom command definition in the /etc/nagios-plugins/config/ directory.
For example, to monitor https://domain1.com and accept HTTP status codes 200, 301, and 302, create a file named https_url.cfg and add the following configuration:
define command {
command_name check_https_url
command_line /usr/local/nagios/libexec/check_http -H domain1.com -e 200,301,302
}
This command checks the HTTPS website and considers the specified status codes as acceptable responses.
Step 2: Add the Command to the Nagios Configuration
Create the https_url.cfg file in the following directory:
/etc/nagios-plugins/config/
Add the custom command definition shown in Step 1 and save the file.
Ensure that Nagios is configured to load this command definition file and reload or restart the Nagios service after making the configuration changes.
If you need any assistance with Nagios configuration or website monitoring, please feel free to reach out to our team here.
Step 3: Configure Website Monitoring as a Service
Once the custom command is created, we can use it in the host’s service configuration.
For example, add the following service definition to the appropriate Nagios configuration file, such as /etc/nagios3/conf.d/server.cfg:
define service {
host_name domain1.com
service_description WEB SERVICE
check_command check_https_url!8243!/services/echo%3Fwsdl2
use generic-service
}
This service configuration tells Nagios to monitor the specified web service using the custom command.
Here, the command arguments specify the port and URL path to be checked. Ensure that the custom command definition supports these arguments if they are passed through the service configuration.
Step 4: Validate and Reload Nagios
After updating the configuration files, validate the Nagios configuration to ensure there are no syntax errors.
Run the appropriate configuration validation command for your Nagios installation, then reload or restart the Nagios service to apply the changes.
Once the configuration is loaded successfully, the website monitoring service will appear in the Nagios dashboard, where you can view its status and alerts.
Conclusion
HTTP status code monitoring in Nagios is a simple and effective way to check website availability and detect unexpected HTTP responses. By configuring custom commands using the Nagios check_http plugin and defining service checks for specific URLs, administrators can monitor website health and identify potential issues proactively.
With Nagios HTTP monitoring, administrators can improve service visibility, reduce manual monitoring effort, and respond quickly when websites return unexpected status codes or become unavailable.
FAQs
1. What is HTTP status code monitoring in Nagios?
HTTP status code monitoring in Nagios checks whether a website returns the expected HTTP response codes, helping administrators verify website availability and identify errors.
2. Which Nagios plugin is used to monitor websites using status codes?
The check_http plugin is used to monitor HTTP and HTTPS websites, check connectivity, and validate the HTTP response codes returned by the web server.
3. Which HTTP status codes can be monitored using Nagios?
Nagios can be configured to accept specific status codes, such as 200 (OK), 301 (Moved Permanently), and 302 (Found). Administrators can customize the accepted status codes based on the website’s expected behavior.
4. Can Nagios monitor HTTPS websites on custom ports?
Yes. Nagios can monitor HTTPS websites on custom ports by specifying the appropriate port number and configuring the check_http command accordingly.
5. What happens if a website returns an unexpected HTTP status code?
If the website returns a status code that is not included in the accepted response codes, Nagios can report the service as a warning or critical state, depending on the plugin configuration.
Official Documentation
Read the Nagios HTTP Monitoring Documentation
Read the check_http Plugin Documentation
Read the Nagios Plugins Documentation
Related Articles
How to set up the website monitoring on Nagios?
How to enable email notifications for the Nagios alerts
Need Assistance?
Configuring Nagios website monitoring and monitoring HTTP status codes can sometimes require additional technical expertise. Our team can help you with Nagios configuration, website monitoring, server management, and infrastructure monitoring requirements.
Explore our Pheonix Solutions to learn more about our hosting, server management, and infrastructure services.
