{"id":6019,"date":"2020-12-23T18:11:26","date_gmt":"2020-12-23T12:41:26","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=6019"},"modified":"2026-11-22T11:47:37","modified_gmt":"2026-11-22T06:17:37","slug":"nagios-http-status-code-monitoring","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/nagios-http-status-code-monitoring\/","title":{"rendered":"How to Monitor Websites Using HTTP Status Codes in Nagios"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date:<\/strong> December 23, 2020<br><strong>Last Updated:<\/strong> November 22, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nagios supports <strong>HTTP status code monitoring in Nagios<\/strong> through the <code>check_http<\/code> plugin, which allows administrators to check HTTP\/HTTPS connectivity and validate the response status codes returned by a web server. With <strong>Nagios HTTP monitoring<\/strong>, administrators can identify unexpected responses, such as HTTP 500 errors, connectivity failures, and redirection issues.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, we will explain how to configure a custom Nagios command using the <strong>Nagios check_http plugin<\/strong> to monitor websites using HTTP status codes and apply it to a service configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before configuring website monitoring in Nagios, ensure the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Nagios Core is installed and running.<\/li>\n\n\n\n<li>The Nagios Plugins package is installed.<\/li>\n\n\n\n<li>The <code>check_http<\/code> plugin is available under the Nagios plugins directory.<\/li>\n\n\n\n<li>Access to the Nagios configuration files with root or sudo privileges.<\/li>\n\n\n\n<li>The website or URL to be monitored is accessible from the Nagios server.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Nagios Website Monitoring Implementation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create a Custom Nagios Command<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Nagios provides the <code>check_http<\/code> plugin for monitoring websites and validating HTTP response codes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can create a custom command definition in the <code>\/etc\/nagios-plugins\/config\/<\/code> directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, to monitor <code>https:\/\/domain1.com<\/code> and accept HTTP status codes 200, 301, and 302, create a file named <code>https_url.cfg<\/code> and add the following configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define command {\n    command_name    check_https_url\n    command_line    \/usr\/local\/nagios\/libexec\/check_http -H domain1.com -e 200,301,302\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command checks the HTTPS website and considers the specified status codes as acceptable responses.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Add the Command to the Nagios Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create the <code>https_url.cfg<\/code> file in the following directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/nagios-plugins\/config\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the custom command definition shown in Step 1 and save the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ensure that Nagios is configured to load this command definition file and reload or restart the Nagios service after making the configuration changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need any assistance with Nagios configuration or website monitoring, please feel free to reach out to our team <a href=\"https:\/\/pheonixsolutions.com\/contact\/\">here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Configure Website Monitoring as a Service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once the custom command is created, we can use it in the host&#8217;s service configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, add the following service definition to the appropriate Nagios configuration file, such as <code>\/etc\/nagios3\/conf.d\/server.cfg<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define service {\n    host_name            domain1.com\n    service_description   WEB SERVICE\n    check_command        check_https_url!8243!\/services\/echo%3Fwsdl2\n    use                 generic-service\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This service configuration tells Nagios to monitor the specified web service using the custom command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Validate and Reload Nagios<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After updating the configuration files, validate the Nagios configuration to ensure there are no syntax errors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the appropriate configuration validation command for your Nagios installation, then reload or restart the Nagios service to apply the changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the configuration is loaded successfully, the website monitoring service will appear in the Nagios dashboard, where you can view its status and alerts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>HTTP status code monitoring in Nagios<\/strong> 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With <strong>Nagios HTTP monitoring<\/strong>, administrators can improve service visibility, reduce manual monitoring effort, and respond quickly when websites return unexpected status codes or become unavailable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. What is HTTP status code monitoring in Nagios?<\/strong><br>HTTP status code monitoring in Nagios checks whether a website returns the expected HTTP response codes, helping administrators verify website availability and identify errors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Which Nagios plugin is used to monitor websites using status codes?<\/strong><br>The <code>check_http<\/code> plugin is used to monitor HTTP and HTTPS websites, check connectivity, and validate the HTTP response codes returned by the web server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Which HTTP status codes can be monitored using Nagios?<\/strong><br>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&#8217;s expected behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. Can Nagios monitor HTTPS websites on custom ports?<\/strong><br>Yes. Nagios can monitor HTTPS websites on custom ports by specifying the appropriate port number and configuring the <code>check_http<\/code> command accordingly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. What happens if a website returns an unexpected HTTP status code?<\/strong><br>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Documentation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/4\/en\/monitoring-publicservices.html\" target=\"_blank\" rel=\"noopener\">Read the Nagios HTTP Monitoring Documentation<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/nagios-plugins.org\/doc\/man\/check_http.html\" target=\"_blank\" rel=\"noopener\">Read the check_http Plugin Documentation<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/4\/en\/plugins.html\" target=\"_blank\" rel=\"noopener\">Read the Nagios Plugins Documentation<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-set-up-the-website-monitoring-on-nagios\/\">How to set up the website monitoring on Nagios?<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-enable-email-notifications-for-the-nagios-alerts\/\">How to enable email notifications for the Nagios alerts<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Need Assistance?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Explore our <a href=\"https:\/\/pheonixsolutions.com\/blog\/\">Pheonix Solutions<\/a> to learn more about our hosting, server management, and infrastructure services.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: December 23, 2020Last Updated: November 22, 2026 Introduction Nagios website monitoring helps administrators monitor server availability, network services, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13768,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1019],"tags":[347,346,795,796],"class_list":["post-6019","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-aws","tag-monitoring","tag-nagios","tag-status-codes","tag-website","psol-cat-cloud-aws"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1z5","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/images-12.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=6019"}],"version-history":[{"count":6,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6019\/revisions"}],"predecessor-version":[{"id":13779,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6019\/revisions\/13779"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/13768"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}