<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Response Time &#8211; Nagios Library</title>
	<atom:link href="https://library.nagios.com/tag/response-time/feed/" rel="self" type="application/rss+xml" />
	<link>https://library.nagios.com</link>
	<description>Complete Nagios monitoring resources and documentation</description>
	<lastBuildDate>Mon, 23 Feb 2026 18:52:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://library.nagios.com/wp-content/uploads/2024/11/Nagios-Blue-N.svg</url>
	<title>Response Time &#8211; Nagios Library</title>
	<link>https://library.nagios.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Website Performance Monitoring with a Custom Nagios XI Plugin</title>
		<link>https://library.nagios.com/monitoring/website-performance-monitoring-with-a-custom-nagios-xi-plugin/</link>
		
		<dc:creator><![CDATA[Ayoub Louragli]]></dc:creator>
		<pubDate>Fri, 07 Feb 2025 16:36:50 +0000</pubDate>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Response Time]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=44458</guid>

					<description><![CDATA[Introduction Monitoring website performance is crucial for ensuring high availability and optimal user experience. Slow response times can lead to lost customers and impact business reputation. In this guide, we introduce a custom Nagios XI plugin that monitors website response times and alerts administrators when predefined thresholds are exceeded. The Need for Website Response Time [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading"><strong>Introduction</strong></h3>



<p>Monitoring website performance is crucial for ensuring high availability and optimal user experience. Slow response times can lead to lost customers and impact business reputation. In this guide, we introduce a custom <a href="https://www.nagios.com/" target="_blank" rel="noopener">Nagios</a> XI plugin that monitors website response times and alerts administrators when predefined thresholds are exceeded.</p>



<h3 class="wp-block-heading"><strong>The Need for Website Response Time Monitoring</strong></h3>



<p>Website response time is a key performance metric that reflects how quickly a site responds to user requests. High latency may indicate issues such as server overload, network congestion, or backend inefficiencies. By integrating our custom <strong>check_response_time</strong> plugin into Nagios XI, administrators can:</p>



<ul class="wp-block-list">
<li>Monitor website uptime and response times</li>



<li>Set warning and critical thresholds for response time alerts</li>



<li>Receive real-time notifications when performance degrades</li>
</ul>



<h3 class="wp-block-heading"><strong>Plugin Overview</strong></h3>



<p>Our <strong>check_response_time</strong> plugin is written in Python and utilizes the <code>requests</code> library to fetch a webpage and measure its response time. It classifies the results into three states:</p>



<ul class="wp-block-list">
<li><strong>OK:</strong> Response time is within acceptable limits</li>



<li><strong>WARNING:</strong> Response time exceeds the warning threshold</li>



<li><strong>CRITICAL:</strong> Response time exceeds the critical threshold</li>
</ul>



<p>Additionally, it handles common network errors, ensuring reliable monitoring.</p>



<h4 class="wp-block-heading"><strong>Plugin Code</strong></h4>



<p>Below is the Python code for the Nagios XI plugin:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-Geist-Mono" style="font-size:.875rem;font-family:Code-Pro-Geist-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#adbac7;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>#!/usr/bin/env python3&lt;br>&lt;br>import sys&lt;br>import requests&lt;br>import argparse&lt;br>&lt;br>def check_website_health(url, warning_threshold, critical_threshold):&lt;br>    try:&lt;br>        response = requests.get(url, timeout=10)&lt;br>        load_time = response.elapsed.total_seconds() * 1000  # convert to milliseconds&lt;br>&lt;br>        if response.status_code != 200:&lt;br>            return (2, f"Website is down. Status Code: {response.status_code}")&lt;br>&lt;br>        if load_time >= critical_threshold:&lt;br>            return (2, f"CRITICAL - Response time {load_time:.2f} ms exceeds critical threshold of {critical_threshold} ms")&lt;br>        elif load_time >= warning_threshold:&lt;br>            return (1, f"WARNING - Response time {load_time:.2f} ms exceeds warning threshold of {warning_threshold} ms")&lt;br>        else:&lt;br>            return (0, f"OK - Response time {load_time:.2f} ms")&lt;br>    except requests.exceptions.RequestException as e:&lt;br>        return (3, f"Error checking website: {str(e)}")&lt;br>&lt;br>def main():&lt;br>    parser = argparse.ArgumentParser(description="Check website response time")&lt;br>    parser.add_argument("-H", "--host", required=True, help="Host URL")&lt;br>    parser.add_argument("-w", "--warning", type=int, required=True, help="Warning threshold in ms")&lt;br>    parser.add_argument("-c", "--critical", type=int, required=True, help="Critical threshold in ms")&lt;br>    args = parser.parse_args()&lt;br>&lt;br>    url = args.host&lt;br>    if not url.startswith('http://') and not url.startswith('https://'):&lt;br>        url = 'http://' + url&lt;br>&lt;br>    status, message = check_website_health(url, args.warning, args.critical)&lt;br>    print(message)&lt;br>    sys.exit(status)&lt;br>&lt;br>if __name__ == '__main__':&lt;br>    main()</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e" tabindex="0"><code><span class="line"><span style="color: #768390">#!/usr/bin/env python3&lt;br&gt;&lt;br&gt;import sys&lt;br&gt;import requests&lt;br&gt;import argparse&lt;br&gt;&lt;br&gt;def check_website_health(url, warning_threshold, critical_threshold):&lt;br&gt;    try:&lt;br&gt;        response = requests.get(url, timeout=10)&lt;br&gt;        load_time = response.elapsed.total_seconds() * 1000  # convert to milliseconds&lt;br&gt;&lt;br&gt;        if response.status_code != 200:&lt;br&gt;            return (2, f&quot;Website is down. Status Code: {response.status_code}&quot;)&lt;br&gt;&lt;br&gt;        if load_time &gt;= critical_threshold:&lt;br&gt;            return (2, f&quot;CRITICAL - Response time {load_time:.2f} ms exceeds critical threshold of {critical_threshold} ms&quot;)&lt;br&gt;        elif load_time &gt;= warning_threshold:&lt;br&gt;            return (1, f&quot;WARNING - Response time {load_time:.2f} ms exceeds warning threshold of {warning_threshold} ms&quot;)&lt;br&gt;        else:&lt;br&gt;            return (0, f&quot;OK - Response time {load_time:.2f} ms&quot;)&lt;br&gt;    except requests.exceptions.RequestException as e:&lt;br&gt;        return (3, f&quot;Error checking website: {str(e)}&quot;)&lt;br&gt;&lt;br&gt;def main():&lt;br&gt;    parser = argparse.ArgumentParser(description=&quot;Check website response time&quot;)&lt;br&gt;    parser.add_argument(&quot;-H&quot;, &quot;--host&quot;, required=True, help=&quot;Host URL&quot;)&lt;br&gt;    parser.add_argument(&quot;-w&quot;, &quot;--warning&quot;, type=int, required=True, help=&quot;Warning threshold in ms&quot;)&lt;br&gt;    parser.add_argument(&quot;-c&quot;, &quot;--critical&quot;, type=int, required=True, help=&quot;Critical threshold in ms&quot;)&lt;br&gt;    args = parser.parse_args()&lt;br&gt;&lt;br&gt;    url = args.host&lt;br&gt;    if not url.startswith(&#39;http://&#39;) and not url.startswith(&#39;https://&#39;):&lt;br&gt;        url = &#39;http://&#39; + url&lt;br&gt;&lt;br&gt;    status, message = check_website_health(url, args.warning, args.critical)&lt;br&gt;    print(message)&lt;br&gt;    sys.exit(status)&lt;br&gt;&lt;br&gt;if __name__ == &#39;__main__&#39;:&lt;br&gt;    main()</span></span></code></pre></div>



<p>You can access the code on Github:<a href="https://github.com/NagiosEnterprises/plugins-extra/tree/check_response_time" target="_blank" rel="noopener"> Here</a></p>



<h3 class="wp-block-heading"><strong>How to Use the Plugin in Nagios XI</strong></h3>



<h3 class="wp-block-heading">1. Upload the Plugin to Nagios XI</h3>



<ol class="wp-block-list">
<li>Log in to the Nagios XI Web Interface.</li>



<li>Navigate to Admin &gt; System Extensions &gt; Manage Plugins.</li>



<li>Click Browse, select the script file, and click Upload &amp; Install.</li>
</ol>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/02/image-77.png"><img fetchpriority="high" decoding="async" width="932" height="335" src="https://library.nagios.com/wp-content/uploads/2025/02/image-77.png" alt="image 77" class="wp-image-44474" title="Website Performance Monitoring with a Custom Nagios XI Plugin 1" srcset="https://library.nagios.com/wp-content/uploads/2025/02/image-77.png 932w, https://library.nagios.com/wp-content/uploads/2025/02/image-77-300x108.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/image-77-768x276.png 768w" sizes="(max-width: 932px) 100vw, 932px" /></a><figcaption class="wp-element-caption">Manage the plugin</figcaption></figure>



<h3 class="wp-block-heading">2. Define the Plugin as a Nagios XI Command</h3>



<ol class="wp-block-list">
<li>Go to Configure &gt; Core Config Manager &gt; Commands &gt; Add New.</li>



<li>Enter the following details:
<ul class="wp-block-list">
<li>Command Name</li>



<li>Command Line</li>



<li>Command Type: check command</li>
</ul>
</li>
</ol>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-082459.png"><img decoding="async" width="1024" height="572" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-082459-1024x572.png" alt="Screenshot 2025 02 07 082459" class="wp-image-44477" title="Website Performance Monitoring with a Custom Nagios XI Plugin 2" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-082459-1024x572.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-082459-300x168.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-082459-768x429.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-082459.png 1084w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Adding the command</figcaption></figure>



<h3 class="wp-block-heading">3. Configure a Nagios XI Service</h3>



<ol class="wp-block-list">
<li>Navigate to Configure &gt; Core Config Manager &gt; Services &gt; Add New.</li>



<li>Fill in the required fields:
<ul class="wp-block-list">
<li>Service Name</li>



<li>Host: Select the target host</li>



<li>Check Command</li>



<li>*In this example, a <strong>WARNING</strong> alert is triggered if the response time exceeds <strong>500ms</strong>, and a <strong>CRITICAL</strong> alert is triggered if it exceeds <strong>1000ms</strong>.</li>
</ul>
</li>



<li>Configure the Check Settings and Alert Settings.</li>



<li>Save the service and apply the configuration.</li>
</ol>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-084046.png"><img decoding="async" width="1024" height="618" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-084046-1024x618.png" alt="Screenshot 2025 02 07 084046" class="wp-image-44481" title="Website Performance Monitoring with a Custom Nagios XI Plugin 3" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-084046-1024x618.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-084046-300x181.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-084046-768x463.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-084046.png 1132w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Adding the service</figcaption></figure>



<h3 class="wp-block-heading">Testing the Plugin</h3>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-083035.png"><img loading="lazy" decoding="async" width="1024" height="613" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-083035-1024x613.png" alt="Screenshot 2025 02 07 083035" class="wp-image-44485" title="Website Performance Monitoring with a Custom Nagios XI Plugin 4" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-083035-1024x613.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-083035-300x180.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-083035-768x460.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-083035.png 1035w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Check service status example</figcaption></figure>



<h3 class="wp-block-heading"><strong>Conclusion</strong></h3>



<p>By integrating the <strong>check_response_time</strong> plugin into Nagios XI, administrators gain real-time insights into website performance and uptime. This proactive approach helps mitigate potential downtime and ensures a seamless user experience.</p>



<p>Try deploying this plugin in your Nagios XI setup today and take control of your website performance monitoring!</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
