<?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/"
	xmlns:media="http://search.yahoo.com/mrss/" >

<channel>
	<title>Plugins &#8211; Nagios Library</title>
	<atom:link href="https://library.nagios.com/tag/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>https://library.nagios.com</link>
	<description>Complete Nagios monitoring resources and documentation</description>
	<lastBuildDate>Thu, 02 Apr 2026 18:18:50 +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>Plugins &#8211; Nagios Library</title>
	<link>https://library.nagios.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Prometheus Monitoring with Nagios XI: Installing the Exporters</title>
		<link>https://library.nagios.com/nagios-updates/prometheus-monitoring-nagios-xi/</link>
		
		<dc:creator><![CDATA[Louie Mattia]]></dc:creator>
		<pubDate>Fri, 06 Jun 2025 20:13:47 +0000</pubDate>
				<category><![CDATA[Nagios Updates]]></category>
		<category><![CDATA[Techtips]]></category>
		<category><![CDATA[Agents]]></category>
		<category><![CDATA[Network Monitoring System]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Prometheus]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=57577</guid>

					<description><![CDATA[Learn how to integrate Prometheus metrics into Nagios XI for enhanced monitoring, alerting, and visualization across Windows and Linux systems.]]></description>
										<content:encoded><![CDATA[
<p>Integrating Prometheus with Nagios XI combines powerful time-series monitoring with flexible alerting and visualization. By leveraging Prometheus’s efficient data collection and querying capabilities alongside Nagios XI’s mature alerting and escalation workflows, IT teams can monitor systems more proactively and respond to anomalies faster. In this guide, we’ll walk through configuring Prometheus to export metrics, for both Windows and Linux.</p>



<h2 class="wp-block-heading">Prerequisites </h2>



<ul class="wp-block-list">
<li>You have Internet or Ethernet access</li>



<li>Your host is running Linux or Windows</li>
</ul>



<h2 class="wp-block-heading">Installing the Windows Exporter from Prometheus Community GitHub onto  a Windows Host</h2>



<h3 class="wp-block-heading">1. Download the latest version from GitHub</h3>



<ul class="wp-block-list">
<li>Go to <a href="https://github.com/prometheus-community/windows_exporter/releases" target="_blank" rel="noreferrer noopener">https://github.com/prometheus-community/windows_exporter</a></li>



<li>Look for the latest release and download the <code>amd64.msi</code> file</li>
</ul>



<h3 class="wp-block-heading">2. Run the installer</h3>



<ul class="wp-block-list">
<li>In the initial <strong>Custom Setup</strong> section, choose <em>Entire feature will be installed on local hard drive</em> under <strong>Firewall Exception</strong>. This will add an inbound permission for the Exporter listening port. </li>
</ul>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/06/prometheus-win-exporter-firewall.png"><img fetchpriority="high" decoding="async" width="490" height="382" src="https://library.nagios.com/wp-content/uploads/2025/06/prometheus-win-exporter-firewall.png" alt="Screenshot of the Prometheus Windows Exporter installer, highlighting the Firewall Exception settings." class="wp-image-58682" title="Prometheus Monitoring with Nagios XI: Installing the Exporters 1" srcset="https://library.nagios.com/wp-content/uploads/2025/06/prometheus-win-exporter-firewall.png 490w, https://library.nagios.com/wp-content/uploads/2025/06/prometheus-win-exporter-firewall-300x234.png 300w" sizes="(max-width: 490px) 100vw, 490px" /></a><figcaption class="wp-element-caption">Enabling the Firewall Exception feature. </figcaption></figure>



<ul class="wp-block-list">
<li>Click all the options that say<strong> Next</strong> or <strong>Proceed</strong> in the installer
<ul class="wp-block-list">
<li>You do not need to change or add any other information to use the Prometheus Wizard in Nagios XI, you can simply keep the defaults. </li>
</ul>
</li>
</ul>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-02_155641_480.png"><img decoding="async" width="480" height="374" src="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-02_155641_480.png" alt="Prometheus Windows Exporter COnfiguration" class="wp-image-57648" title="Prometheus Monitoring with Nagios XI: Installing the Exporters 2" srcset="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-02_155641_480.png 480w, https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-02_155641_480-300x234.png 300w" sizes="(max-width: 480px) 100vw, 480px" /></a><figcaption class="wp-element-caption">Windows Exporter Configuration</figcaption></figure>



<ul class="wp-block-list">
<li>It will say it is installed</li>



<li>(Optional): Confirm it is up and running by entering <code>http://&lt;HOST_IP&gt;:9182/metrics</code></li>
</ul>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/06/Screenshot-2025-06-02-161132.png"><img decoding="async" width="1024" height="435" src="https://library.nagios.com/wp-content/uploads/2025/06/Screenshot-2025-06-02-161132-1024x435.png" alt="Windows Exporter Metrics" class="wp-image-57649" title="Prometheus Monitoring with Nagios XI: Installing the Exporters 3" srcset="https://library.nagios.com/wp-content/uploads/2025/06/Screenshot-2025-06-02-161132-1024x435.png 1024w, https://library.nagios.com/wp-content/uploads/2025/06/Screenshot-2025-06-02-161132-300x127.png 300w, https://library.nagios.com/wp-content/uploads/2025/06/Screenshot-2025-06-02-161132-768x326.png 768w, https://library.nagios.com/wp-content/uploads/2025/06/Screenshot-2025-06-02-161132-1536x653.png 1536w, https://library.nagios.com/wp-content/uploads/2025/06/Screenshot-2025-06-02-161132.png 1730w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Results from the metrics page</figcaption></figure>



<p>With all the above steps completed, your Windows system is now properly configured for Prometheus monitoring, and you’re ready to move on to <a href="https://library.nagios.com/techtips/how-to-integrate-the-prometheus-wizard/">integrating it with Nagios XI</a>.</p>



<h2 class="wp-block-heading">Installing and Running the Prometheus Node Exporter on a Linux Host</h2>



<h3 class="wp-block-heading">1. Download the latest version using command line</h3>



<ul class="wp-block-list">
<li>Go to <a href="https://prometheus.io/download/#node_exporter" target="_blank" rel="noopener">https://prometheus.io/docs/guides/node-exporter/</a> </li>



<li>Right click the Linux download link and select Copy Link to get exactly what you need to enter in the below <code>wget</code> command.</li>



<li>On your Linux host, open the terminal</li>



<li>Run the following command:<br></li>
</ul>



<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:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly># wget https://github.com/prometheus/node_exporter/releases/download/v&lt;VERSION>/node_exporter-&lt;VERSION>.&lt;OS>-&lt;ARCH>.tar.gz</textarea><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 dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4"># wget https://github.com/prometheus/node_exporter/releases/download/v&lt;VERSION&gt;/node_exporter-&lt;VERSION&gt;.&lt;OS&gt;-&lt;ARCH&gt;.tar.gz</span></span></code></pre></div>



<p>This will download the Node Exporter to your Linux host. </p>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095213_720.png"><img loading="lazy" decoding="async" width="720" height="85" src="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095213_720.png" alt="Node Exporter Install Success" class="wp-image-57679" title="Prometheus Monitoring with Nagios XI: Installing the Exporters 4" srcset="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095213_720.png 720w, https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095213_720-300x35.png 300w" sizes="(max-width: 720px) 100vw, 720px" /></a><figcaption class="wp-element-caption">Node Explorer Downloaded</figcaption></figure>



<h3 class="wp-block-heading">2. Run Node Explorer</h3>



<ul class="wp-block-list">
<li>Run the following commands:
<ul class="wp-block-list">
<li><code>tar xvfz node_exporter-*.*-amd64.tar.gz</code></li>



<li><code>cd node_exporter-*.*-amd64</code></li>



<li><code>./node_exporter</code></li>
</ul>
</li>
</ul>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095432_480-2.png"><img loading="lazy" decoding="async" width="480" height="67" src="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095432_480-2.png" alt="Node Exporter Directory" class="wp-image-57800" title="Prometheus Monitoring with Nagios XI: Installing the Exporters 5" srcset="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095432_480-2.png 480w, https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095432_480-2-300x42.png 300w" sizes="(max-width: 480px) 100vw, 480px" /></a><figcaption class="wp-element-caption">Node Exporter Directory Made</figcaption></figure>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095623_720.png"><img loading="lazy" decoding="async" width="720" height="495" src="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095623_720.png" alt="Running Node Exporter" class="wp-image-57683" title="Prometheus Monitoring with Nagios XI: Installing the Exporters 6" srcset="https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095623_720.png 720w, https://library.nagios.com/wp-content/uploads/2025/06/screenshot_2025-06-03_095623_720-300x206.png 300w" sizes="(max-width: 720px) 100vw, 720px" /></a><figcaption class="wp-element-caption">Node Exporter Running</figcaption></figure>



<p>With these above steps completed, your Linux host is ready for Prometheus monitoring, and we are ready to move on to <a href="https://library.nagios.com/techtips/how-to-integrate-the-prometheus-wizard/">integrating with Nagios XI</a>.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>With this, we’ve set it up the data exporters and are ready to configure monitoring in Nagios XI, enabling us to gather all of the same data the same way that Prometheus does, giving us access to the detailed information it provides while showing the data in XI in a clear way.</p>
]]></content:encoded>
					
		
		
			</item>
		<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 loading="lazy" 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 7" 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 loading="lazy" 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 8" 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 loading="lazy" 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 9" 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 10" 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>
		<item>
		<title>Plugin to Check CPU Usage</title>
		<link>https://library.nagios.com/documentation/plugin-to-check-cpu-usage/</link>
		
		<dc:creator><![CDATA[Johnny Mengistu]]></dc:creator>
		<pubDate>Thu, 06 Feb 2025 23:07:27 +0000</pubDate>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Support Tips]]></category>
		<category><![CDATA[Plugins]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=44378</guid>

					<description><![CDATA[Benefits of Using a Plugin 1. Resource Management &#8211; Since you only install the plugins you need; you can avoid unnecessary resource usage that would come with more comprehensive software packages. 2. Enhanced Functionality &#8211; Plugins add new features and capabilities to existing software without needing to modify the core program. This allows you to [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Benefits of Using a Plugin</h2>



<p><strong>1. Resource Management</strong> &#8211; Since you only install the plugins you need; you can avoid unnecessary resource usage that would come with more comprehensive software packages.</p>



<p><strong>2. Enhanced Functionality</strong> &#8211; Plugins add new features and capabilities to existing software without needing to modify the core program. This allows you to expand what your software can do.</p>



<p><strong>3. Customization</strong> &#8211; You can pick and choose exactly which additional features you want, creating a personalized setup that matches your specific needs rather than dealing with bloated software.</p>



<p><strong>4. Cost-Effective</strong> &#8211; Instead of buying entirely new software, you can often just add the specific functionality you need through plugins, which are typically less expensive or even free.</p>



<p><strong>5. Easy Updates</strong> &#8211; Plugins can be updated independently from the main software, making it easier to maintain and improve specific features without affecting the whole system.</p>



<p><strong>6. Development Efficiency</strong> &#8211; For developers, plugins provide a way to extend applications without having to rebuild them from scratch. The modular nature makes maintenance and debugging easier.</p>



<p><strong>7. Community Innovation</strong> &#8211; Popular software often has a vibrant plugin ecosystem where developers create innovative solutions for specific needs, benefiting the entire user community.</p>



<h2 class="wp-block-heading">The Purpose of a CPU Usage Plugin</h2>



<p>The purpose of a &#8220;Check CPU Usage&#8221; plugin is to monitor the percentage of CPU resources being used by the system. It checks whether the CPU usage is within an acceptable range (e.g., below 80%), and alerts if it crosses a threshold, indicating that the system is under heavy load.</p>



<p>Typically, the plugin will return one of the following statuses:</p>



<ul class="wp-block-list">
<li><strong>OK (Exit Code 0)</strong>: CPU usage is within acceptable limits.</li>



<li><strong>WARNING (Exit Code 1)</strong>: CPU usage is above normal but below the critical threshold.</li>



<li><strong>CRITICAL (Exit Code 2)</strong>: CPU usage is too high, and action should be taken.</li>



<li><strong>UNKNOWN (Exit Code 3)</strong>: The plugin encountered an error, and it could not determine the CPU usage.</li>
</ul>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Plugin-Pic.png"><img loading="lazy" decoding="async" width="609" height="331" src="https://library.nagios.com/wp-content/uploads/2025/02/Plugin-Pic.png" alt="Picture of plugin within computer screen" class="wp-image-44402" title="Plugin to Check CPU Usage 11" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Plugin-Pic.png 609w, https://library.nagios.com/wp-content/uploads/2025/02/Plugin-Pic-300x163.png 300w" sizes="(max-width: 609px) 100vw, 609px" /></a><figcaption>Plugin to Check CPU Usage 14</figcaption></figure>



<h2 class="wp-block-heading">How it Works</h2>



<p>This script checks how much disk space is being used on your system’s root drive (&#8220;/&#8221;) and compares it to two important thresholds: <strong>warning</strong> and <strong>critical</strong>.</p>



<ul class="wp-block-list">
<li><strong>Warning Threshold (80%)</strong>: This is the point at which the disk usage is high enough to warn you, but it&#8217;s not critical yet.</li>



<li><strong>Critical Threshold (90%)</strong>: This is the point at which the disk usage is so high that it’s considered an urgent issue.</li>
</ul>



<p>Based on the disk usage, the script will return one of three possible results:</p>



<p><strong>OK</strong> (if disk usage is below 80%)</p>



<p><strong>CRITICAL</strong> (if disk usage is 90% or higher)</p>



<p><strong>WARNING</strong> (if disk usage is between 80% and 90%)</p>



<p></p>



<h2 class="wp-block-heading">Breaking it Down</h2>



<p><strong>Line 1: <code>#!/bin/bash</code></strong></p>



<ul class="wp-block-list">
<li>This tells the system to run this script using <strong>bash</strong>, a common scripting language.</li>
</ul>



<p><strong>Line 3-4: Set Thresholds</strong></p>



<ul class="wp-block-list">
<li><code>WARNING_THRESHOLD=80</code> and <code>CRITICAL_THRESHOLD=90</code>: The script sets two thresholds — <strong>80%</strong> for warning and <strong>90%</strong> for critical. These numbers are used to compare against the current disk usage.</li>
</ul>



<p><strong>Line 6: Get Disk Usage</strong></p>



<ul class="wp-block-list">
<li><code>USAGE=$(df / | tail -n 1 | awk '{print $5}' | sed 's/%//')</code></li>



<li>This command checks the disk usage of the root directory (<code>/</code>).
<ul class="wp-block-list">
<li><code>df /</code> gets the disk space details.</li>



<li><code>tail -n 1</code> picks the last line of output (which contains the disk usage).</li>



<li><code>awk '{print $5}'</code> extracts the disk usage percentage.</li>



<li><code>sed 's/%//'</code> removes the &#8220;%&#8221; symbol from the usage number.</li>
</ul>
</li>
</ul>



<p><strong>Line 9-16: Compare Disk Usage to Thresholds</strong></p>



<ul class="wp-block-list">
<li>The script then checks if the disk usage (<code>$USAGE</code>) is above the thresholds:
<ul class="wp-block-list">
<li>If <strong>disk usage is 90% or more</strong>: it prints a <strong>CRITICAL</strong> message, along with performance data, and exits with code <code>2</code> (to indicate a critical issue).</li>



<li>If <strong>disk usage is between 80% and 90%</strong>: it prints a <strong>WARNING</strong> message, along with performance data, and exits with code <code>1</code>.</li>



<li>If <strong>disk usage is less than 80%</strong>: it prints an <strong>OK</strong> message, along with performance data, and exits with code <code>0</code> (which means everything is fine).</li>
</ul>
</li>
</ul>



<h2 class="wp-block-heading">CPU Usage Code</h2>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Example-in-VScode.png"><img loading="lazy" decoding="async" width="1024" height="465" data-id="44433" src="https://library.nagios.com/wp-content/uploads/2025/02/Example-in-VScode-1024x465.png" alt="A picture of bash code in VScode editor for CPU plugin" class="wp-image-44433" title="Plugin to Check CPU Usage 12" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Example-in-VScode-1024x465.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Example-in-VScode-300x136.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Example-in-VScode-768x349.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Example-in-VScode.png 1275w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption>Plugin to Check CPU Usage 15</figcaption></figure>
</figure>



<ul class="wp-block-list">
<li>The script checks the disk usage percentage on the root filesystem (<code>/</code>).</li>



<li>It compares this percentage with <strong>warning</strong> and <strong>critical</strong> levels.</li>



<li>Based on the result, it gives a message like &#8220;OK&#8221;, &#8220;WARNING&#8221;, or &#8220;CRITICAL&#8221;.</li>



<li>It also outputs performance data to Nagios in a format it can understand.</li>
</ul>



<p></p>



<h2 class="wp-block-heading">Example Output in Nagios XI</h2>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/CPU-XI-screenshot.png"><img loading="lazy" decoding="async" width="1024" height="428" data-id="44434" src="https://library.nagios.com/wp-content/uploads/2025/02/CPU-XI-screenshot-1024x428.png" alt="Overview picture of Host Status Detail within Nagios XI" class="wp-image-44434" title="Plugin to Check CPU Usage 13" srcset="https://library.nagios.com/wp-content/uploads/2025/02/CPU-XI-screenshot-1024x428.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/CPU-XI-screenshot-300x126.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/CPU-XI-screenshot-768x321.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/CPU-XI-screenshot.png 1164w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption>Plugin to Check CPU Usage 16</figcaption></figure>
</figure>



<p></p>



<p></p>



<h2 class="wp-block-heading">Summary</h2>



<p>A &#8220;Check CPU Usage&#8221; Nagios plugin works by gathering the system&#8217;s CPU usage data, comparing it against defined thresholds, and returning an appropriate status and message. By creating this plugin, you can effectively monitor CPU performance on your systems and ensure that administrators are alerted if CPU usage exceeds acceptable limits.</p>



<p>This plugin can be customized with different thresholds, enhanced with more sophisticated checks, or extended to monitor specific processes or resource consumption on the server.</p>



<p>You can access the full code on GitHub: <a href="https://github.com/NagiosEnterprises/plugins-extra.git" data-type="link" data-id="https://github.com/NagiosEnterprises/plugins-extra.git" target="_blank" rel="noreferrer noopener">CPU Plugin</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Guide to Writing Custom Plugins in Nagios XI</title>
		<link>https://library.nagios.com/training/guide-to-writing-custom-plugins/</link>
		
		<dc:creator><![CDATA[Nicole Vagle]]></dc:creator>
		<pubDate>Thu, 06 Feb 2025 21:56:26 +0000</pubDate>
				<category><![CDATA[Training]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Setup & Installation]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=41154</guid>

					<description><![CDATA[Overview This guide walks you through the steps of building a custom Nagios XI plugin, using a simple script that monitors the last 1-minute load average of the host. This article will go over these following steps: Step 1: Create a Bash Script Plugin in Nagios XI In order to write a script in the [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Overview</h2>



<p>This guide walks you through the steps of building a custom Nagios XI plugin, using a simple script that monitors the last 1-minute load average of the host.</p>



<p>This article will go over these following steps:</p>



<ul class="wp-block-list">
<li>Creating a bash script plugin in the Nagios XI host
<ul class="wp-block-list">
<li>Includes testing the script</li>
</ul>
</li>



<li>Adding the script as a Command in Nagios XI</li>



<li>Using the Command to make a monitoring Service</li>



<li>Where to find more options for the Service</li>
</ul>



<h2 class="wp-block-heading">Step 1: Create a Bash Script Plugin in Nagios XI</h2>



<p>In order to write a script in the Nagios XI host, you must first log in using the <strong>root</strong> user.</p>



<p>Use the following commands to get to the directory that holds all of the plugins for Nagios XI. <strong>Nano</strong> is a text editor that will be used to make the script.</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:#D4D4D4;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>cd /usr/local/nagios/libexec
nano check_load_average.sh</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 dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">cd</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">/usr/local/nagios/libexec</span></span>
<span class="line"><span style="color: #DCDCAA">nano</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">check_load_average.sh</span></span></code></pre></div>



<p>Now that you are in nano, you can start writing your script. The script below takes in the threshold arguments passed in through the command and sets the variables to those values. Then it compares the load value with the threshold values (critical and warning) and returns a message based on how it compared to the thresholds.</p>



<p>You can find the following code here: <a href="https://github.com/NagiosEnterprises/plugins-extra/tree/check_load_average" target="_blank" rel="noopener">https://github.com/NagiosEnterprises/plugins-extra/tree/check_load_average</a>.</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:#D4D4D4;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>#!/bin/bash

# Variables
LOAD_AVG=""
WARN=""
CRIT=""


# Parse arguments
while getopts "w:c:" arg; do
  case $arg in
    w) WARN=${OPTARG} ;;
    c) CRIT=${OPTARG} ;;
  esac
done


# Validate args
if [&#91;-z "$WARN" || -z "$CRIT" &#93;]; then
  echo "UNKNOWN - Invalid arguments. USAGE: $0 -w &lt;warning_threshold> -c &lt;critical_threshold>"
  echo "w: $WARN c: $CRIT"
  exit 3
fi


# Set load average variable
LOAD_AVG=$(uptime | awk -F 'load average: ' '{print $2}' | cut -d',' -f1)


# Compare with thresholds | give computer readable info for performance graphs
if (( $(echo "$LOAD_AVG > $CRIT" | bc -l) )); then
  echo "CRITICAL - Load Average is $LOAD_AVG in the last minute (threshold: $CRIT) | loadaverage=$LOAD_AVG"
  exit 2
elif (( $(echo "$LOAD_AVG > $WARN" | bc -l) )); then
  echo "WARNING - Load Average is $LOAD_AVG in the last minute (threshold: $WARN) | loadaverage=$LOAD_AVG"
  exit 1
else
  echo "OK - Load Average is $LOAD_AVG in the last minute | loadaverage=$LOAD_AVG"
  exit 0
fi
</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 dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">#!/bin/bash</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># Variables</span></span>
<span class="line"><span style="color: #9CDCFE">LOAD_AVG</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;&quot;</span></span>
<span class="line"><span style="color: #9CDCFE">WARN</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;&quot;</span></span>
<span class="line"><span style="color: #9CDCFE">CRIT</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># Parse arguments</span></span>
<span class="line"><span style="color: #C586C0">while</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">getopts</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;w:c:&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">arg</span><span style="color: #D4D4D4">; </span><span style="color: #C586C0">do</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #C586C0">case</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$arg</span><span style="color: #D4D4D4"> </span><span style="color: #C586C0">in</span></span>
<span class="line"><span style="color: #D4D4D4">    w) WARN=${</span><span style="color: #9CDCFE">OPTARG</span><span style="color: #D4D4D4">} ;;</span></span>
<span class="line"><span style="color: #D4D4D4">    c) CRIT=${</span><span style="color: #9CDCFE">OPTARG</span><span style="color: #D4D4D4">} ;;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #C586C0">esac</span></span>
<span class="line"><span style="color: #C586C0">done</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># Validate args</span></span>
<span class="line"><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> [&#91;-z </span><span style="color: #CE9178">&quot;</span><span style="color: #9CDCFE">$WARN</span><span style="color: #CE9178">&quot;</span><span style="color: #D4D4D4"> || -z </span><span style="color: #CE9178">&quot;</span><span style="color: #9CDCFE">$CRIT</span><span style="color: #CE9178">&quot;</span><span style="color: #D4D4D4"> &#93;]; </span><span style="color: #C586C0">then</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;UNKNOWN - Invalid arguments. USAGE: </span><span style="color: #9CDCFE">$0</span><span style="color: #CE9178"> -w &lt;warning_threshold&gt; -c &lt;critical_threshold&gt;&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;w: </span><span style="color: #9CDCFE">$WARN</span><span style="color: #CE9178"> c: </span><span style="color: #9CDCFE">$CRIT</span><span style="color: #CE9178">&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">exit</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">3</span></span>
<span class="line"><span style="color: #C586C0">fi</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># Set load average variable</span></span>
<span class="line"><span style="color: #9CDCFE">LOAD_AVG</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">$(</span><span style="color: #DCDCAA">uptime</span><span style="color: #CE9178"> </span><span style="color: #D4D4D4">|</span><span style="color: #CE9178"> </span><span style="color: #DCDCAA">awk</span><span style="color: #CE9178"> </span><span style="color: #569CD6">-F</span><span style="color: #CE9178"> &#39;load average: &#39; &#39;{print $2}&#39; </span><span style="color: #D4D4D4">|</span><span style="color: #CE9178"> </span><span style="color: #DCDCAA">cut</span><span style="color: #CE9178"> </span><span style="color: #569CD6">-d</span><span style="color: #CE9178">&#39;,&#39; </span><span style="color: #569CD6">-f1</span><span style="color: #CE9178">)</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># Compare with thresholds | give computer readable info for performance graphs</span></span>
<span class="line"><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> (( $(echo &quot;</span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #D4D4D4"> &gt; </span><span style="color: #9CDCFE">$CRIT</span><span style="color: #D4D4D4">&quot; | bc -l) )); </span><span style="color: #C586C0">then</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;CRITICAL - Load Average is </span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #CE9178"> in the last minute (threshold: </span><span style="color: #9CDCFE">$CRIT</span><span style="color: #CE9178">) | loadaverage=</span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #CE9178">&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">exit</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">2</span></span>
<span class="line"><span style="color: #C586C0">elif</span><span style="color: #D4D4D4"> (( $(echo &quot;</span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #D4D4D4"> &gt; </span><span style="color: #9CDCFE">$WARN</span><span style="color: #D4D4D4">&quot; | bc -l) )); </span><span style="color: #C586C0">then</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;WARNING - Load Average is </span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #CE9178"> in the last minute (threshold: </span><span style="color: #9CDCFE">$WARN</span><span style="color: #CE9178">) | loadaverage=</span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #CE9178">&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">exit</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">1</span></span>
<span class="line"><span style="color: #C586C0">else</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;OK - Load Average is </span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #CE9178"> in the last minute | loadaverage=</span><span style="color: #9CDCFE">$LOAD_AVG</span><span style="color: #CE9178">&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">exit</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">0</span></span>
<span class="line"><span style="color: #C586C0">fi</span></span>
<span class="line"></span></code></pre></div>



<p>To close nano, use the keys <code>^X</code>, <code>y</code>, then <code>[Enter]</code></p>



<p>When you first close the script, you will not have permission to execute it. To get permission use the following commands:</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:#D4D4D4;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>chmod +x /usr/local/nagios/libexec/check_load_average.sh</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 dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">chmod</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">+x</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">/usr/local/nagios/libexec/check_load_average.sh</span></span></code></pre></div>



<p>To make sure the script is working properly, type in this command and substitute the parameters:</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:#D4D4D4;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>./check_load_average.sh -w &lt;warning_threshold> -c &lt;critical_threshold></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 dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">./check_load_average.sh</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-w</span><span style="color: #D4D4D4"> &lt;</span><span style="color: #CE9178">warning_threshol</span><span style="color: #D4D4D4">d&gt; </span><span style="color: #569CD6">-c</span><span style="color: #D4D4D4"> &lt;</span><span style="color: #CE9178">critical_threshol</span><span style="color: #D4D4D4">d&gt;</span></span></code></pre></div>



<p>The output could be one of four options. It would appear like this:</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:#D4D4D4;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># An Unknown Response 
UNKNOWN - Invalid arguments. USAGE: $0 -w &lt;warning_threshold> -c &lt;critical_threshold>

# A Critical Response
CRITICAL - Load Average is 1.26 in the last minute (threshold: .04) | loadaverage=1.26

# A Warning Response
WARNING - Load Average is 0.83 in the last minute (threshold: .3) | loadaverage=0.83

# An OK Response
OK - Load Average is 2.21 in the last minute | loadaverage=2.21
</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 dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955"># An Unknown Response </span></span>
<span class="line"><span style="color: #DCDCAA">UNKNOWN</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">-</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Invalid</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">arguments.</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">USAGE:</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$0</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-w</span><span style="color: #D4D4D4"> &lt;</span><span style="color: #CE9178">warning_threshol</span><span style="color: #D4D4D4">d&gt; </span><span style="color: #569CD6">-c</span><span style="color: #D4D4D4"> &lt;</span><span style="color: #CE9178">critical_threshol</span><span style="color: #D4D4D4">d&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># A Critical Response</span></span>
<span class="line"><span style="color: #DCDCAA">CRITICAL</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">-</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Load</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Average</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">is</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">1.26</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">in</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">the</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">last</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">minute</span><span style="color: #D4D4D4"> (threshold: </span><span style="color: #CE9178">.04</span><span style="color: #D4D4D4">) | </span><span style="color: #9CDCFE">loadaverage</span><span style="color: #D4D4D4">=</span><span style="color: #B5CEA8">1.26</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># A Warning Response</span></span>
<span class="line"><span style="color: #DCDCAA">WARNING</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">-</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Load</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Average</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">is</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">0.83</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">in</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">the</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">last</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">minute</span><span style="color: #D4D4D4"> (threshold: </span><span style="color: #CE9178">.3</span><span style="color: #D4D4D4">) | </span><span style="color: #9CDCFE">loadaverage</span><span style="color: #D4D4D4">=</span><span style="color: #B5CEA8">0.83</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># An OK Response</span></span>
<span class="line"><span style="color: #DCDCAA">OK</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">-</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Load</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Average</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">is</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">2.21</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">in</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">the</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">last</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">minute</span><span style="color: #D4D4D4"> | </span><span style="color: #9CDCFE">loadaverage</span><span style="color: #D4D4D4">=</span><span style="color: #B5CEA8">2.21</span></span>
<span class="line"></span></code></pre></div>



<h2 class="wp-block-heading">Step 2: Setting up a Command in Nagios XI</h2>



<p>Now that the script is running in the host, the next step is to add it as a command. To do that, go to <strong>Core Configuration Manager</strong> and go to <strong>Commands</strong>.</p>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-162940-2.png"><img loading="lazy" decoding="async" width="1024" height="402" src="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-162940-2-1024x402.png" alt="Navigating to Commands" class="wp-image-41250" title="Guide to Writing Custom Plugins in Nagios XI 17" srcset="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-162940-2-1024x402.png 1024w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-162940-2-300x118.png 300w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-162940-2-768x301.png 768w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-162940-2-1536x603.png 1536w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-162940-2.png 1917w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Navigating to Commands</figcaption></figure>



<p>At the top of the <strong>Commands</strong> page is button, select <strong>+ Add New</strong>.</p>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/01/image.png"><img loading="lazy" decoding="async" width="1024" height="665" src="https://library.nagios.com/wp-content/uploads/2025/01/image-1024x665.png" alt="Adding a new Command" class="wp-image-41254" title="Guide to Writing Custom Plugins in Nagios XI 18" srcset="https://library.nagios.com/wp-content/uploads/2025/01/image-1024x665.png 1024w, https://library.nagios.com/wp-content/uploads/2025/01/image-300x195.png 300w, https://library.nagios.com/wp-content/uploads/2025/01/image-768x499.png 768w, https://library.nagios.com/wp-content/uploads/2025/01/image.png 1371w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Adding a new Command</figcaption></figure>



<p>Fill out the fields. It should look like this after.</p>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104424.png"><img loading="lazy" decoding="async" width="1024" height="523" data-id="68692" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104424-1024x523.png" alt="Screenshot 2026 03 19 104424" class="wp-image-68692" title="Guide to Writing Custom Plugins in Nagios XI 19" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104424-1024x523.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104424-300x153.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104424-768x393.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104424.png 1203w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Nagios XI Command Settings</figcaption></figure>
</figure>



<p>Select <strong>Save</strong>. At the top right of the Command page will be a message saying <strong>Apply Configuration</strong>. Go through the apply configuration process.</p>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-164132.png"><img loading="lazy" decoding="async" width="823" height="328" src="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-164132.png" alt="Apply Configuaration" class="wp-image-41263" title="Guide to Writing Custom Plugins in Nagios XI 20" srcset="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-164132.png 823w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-164132-300x120.png 300w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-16-164132-768x306.png 768w" sizes="(max-width: 823px) 100vw, 823px" /></a><figcaption class="wp-element-caption">Apply Configuration</figcaption></figure>



<h2 class="wp-block-heading">Step 3: Setting Up a Service in Nagios XI</h2>



<p>On the side bar, go under <strong>Monitoring</strong> and select <strong>Services</strong>. </p>



<p>An easy way to get a new service up and running is to copy an existing service and edit it to fit your needs. To do that, go under actions and select copy on any of services. The copied service will be inactive and unapplied. Select the <strong>edit icon</strong> under actions to make the changes to fit the plugin.</p>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-17-165105.png"><img loading="lazy" decoding="async" width="1024" height="442" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-17-165105-1024x442.png" alt="Screenshot 2026 03 17 165105" class="wp-image-68662" title="Guide to Writing Custom Plugins in Nagios XI 21" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-17-165105-1024x442.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-17-165105-300x129.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-17-165105-768x331.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-17-165105-1536x663.png 1536w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-17-165105.png 1916w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Copying an existing service</figcaption></figure>



<p>Change the <strong>Config Name</strong> and other fields to whatever values you want. Make sure to select <strong>Active</strong> on the bottom left. The other settings tabs can also be changed to fit specific needs.</p>



<p>At the bottom right of the <strong>Common Settings</strong> tab, is a <strong>Run Check Command</strong> button. This can be used to test if the command works as expected before saving the changes.</p>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104643.png"><img loading="lazy" decoding="async" width="1024" height="727" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104643-1024x727.png" alt="Screenshot 2026 03 19 104643" class="wp-image-68694" title="Guide to Writing Custom Plugins in Nagios XI 22" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104643-1024x727.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104643-300x213.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104643-768x546.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-104643.png 1160w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Service Management Settings</figcaption></figure>



<p>When the settings are all complete, select <strong>Save</strong>. A message will appear on the top of the service page saying that changes were made, and you need to <strong>Apply Configuration</strong>. Follow that process the same as you did with Commands.</p>



<h2 class="wp-block-heading">Where to Find More Service Settings</h2>



<p>On the Home page under <strong>Details</strong>, select <strong>Service Status</strong>. This will bring up all the services that are being used. </p>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140726.png"><img loading="lazy" decoding="async" width="582" height="480" src="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140726.png" alt="Navigation to More Service Options" class="wp-image-41332" title="Guide to Writing Custom Plugins in Nagios XI 23" srcset="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140726.png 582w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140726-300x247.png 300w" sizes="(max-width: 582px) 100vw, 582px" /></a><figcaption class="wp-element-caption">Service Details Navigation</figcaption></figure>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105629.png"><img loading="lazy" decoding="async" width="1024" height="594" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105629-1024x594.png" alt="Screenshot 2026 03 19 105629" class="wp-image-68700" title="Guide to Writing Custom Plugins in Nagios XI 24" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105629-1024x594.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105629-300x174.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105629-768x445.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105629.png 1193w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Service Status page with New Service</figcaption></figure>



<p>Find the New Service you just created and select it. The <strong>Service Status Detail</strong> page will show up with multiple tabs of more settings.</p>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105823.png"><img loading="lazy" decoding="async" width="824" height="538" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105823.png" alt="Screenshot 2026 03 19 105823" class="wp-image-68701" title="Guide to Writing Custom Plugins in Nagios XI 25" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105823.png 824w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105823-300x196.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2026-03-19-105823-768x501.png 768w" sizes="(max-width: 824px) 100vw, 824px" /></a><figcaption class="wp-element-caption">Service Status Details Page</figcaption></figure>



<p>Now you have the steps to make your own Nagios Plugin.</p>



<h2 class="wp-block-heading">For More Help</h2>



<p>For any support related questions please visit the&nbsp;<a href="http://support.nagios.com/forum/" target="_blank" rel="noreferrer noopener">Nagios Support Forums</a>&nbsp;at:</p>



<p><a href="http://support.nagios.com/forum/" target="_blank" rel="noreferrer noopener">http://support.nagios.com/forum/</a>,</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Nagios XI Space Weather Plugin</title>
		<link>https://library.nagios.com/monitoring/nagios-xi-space-weather-plugin/</link>
		
		<dc:creator><![CDATA[Caleb DePaulis]]></dc:creator>
		<pubDate>Thu, 06 Feb 2025 21:38:37 +0000</pubDate>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Environmental Monitoring]]></category>
		<category><![CDATA[Plugins]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=44188</guid>

					<description><![CDATA[The Nagios space weather plugin enables the monitoring of space weather metrics, detection services, NOAA alerts, and aurora forecasts for any location. This article outlines the plugin&#8217;s functionality, provides data examples, and demonstrates its use in Nagios XI. For more information on the importance of space weather monitoring, refer to this article here, which describes [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The Nagios space weather plugin enables the monitoring of space weather metrics, detection services, NOAA alerts, and aurora forecasts for any location. This article outlines the plugin&#8217;s functionality, provides data examples, and demonstrates its use in Nagios XI. For more information on the importance of space weather monitoring, refer to this article <a href="https://library.nagios.com/monitoring/why-to-monitor-space-weather/" target="_blank" rel="noreferrer noopener">here</a>, which describes the different aspects of space weather to monitor and why they matter.</p>



<h2 class="wp-block-heading">Understanding the Space Weather Plugin</h2>



<p>The space weather plugin monitors a variety of solar and space-related phenomena that can impact Earth’s systems, offering critical insights for industries and individuals dependent on satellite communications, aviation, and power grids. It tracks solar flares, geomagnetic storms, radio outages, solar radiation, and coronal mass ejections (CMEs), all of which can disrupt technology and infrastructure. The plugin also measures solar wind speed and density, which influence how the solar wind interacts with Earth’s magnetosphere. Additionally, it monitors magnetic field components like Bt and Bz, aiding in the prediction of space weather disturbances that could affect our planet.</p>



<p>The plugin also uses the Kp index to assess global geomagnetic activity. The 3-day forecast feature provides users with the highest Kp value predicted in the upcoming 3-day period and when it occurs, helping them gauge the intensity of space weather activity. With features like the hemispheric power index for both the northern and southern hemispheres, it allows for region-specific monitoring. Aurora chances are calculated based on current solar activity, giving users further insight into space weather’s impact on Earth’s atmosphere. This tool helps users stay informed, enabling them to make timely decisions and prepare for potential disruptions caused by space weather.</p>



<h2 class="wp-block-heading">How This Plugin Works</h2>



<p>This plugin operates by accessing and processing online data, primarily sourced from NASA and NOAA. The data is typically retrieved from websites that provide JSON-formatted data, which allows the Python script to easily read and extract valuable information. For sources that are not formatted as JSON, the plugin uses a slightly more complex process to parse the data and make it readable for extracting the desired information. Once the data is collected, the plugin evaluates the values to determine if the current conditions are categorized as OK, WARNING, or CRITICAL.</p>



<h3 class="wp-block-heading">Collecting the Data</h3>



<p>The following code snippet demonstrates how the plugin retrieves solar wind speed data:</p>



<div class="wp-block-group is-layout-constrained wp-block-group-is-layout-constrained">
<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>def check_wind_speed():
    url = "https://services.swpc.noaa.gov/products/solar-wind/plasma-2-hour.json" 
    try:
        response = requests.get(url)
        response.raise_for_status()  # Checks if the request was successful

        data = response.json()
        if not data or len(data) &lt; 2:
            return None

        latest_entry = data&#91;-1&#93;
        wind_speed_value = latest_entry&#91;2&#93;  
        return wind_speed_value
    except requests.exceptions.HTTPError as e:
        print(f"HTTP error occurred: {e}")
    except Exception as e:
        print(f"An error occurred: {e}")
    return wind_speed_value</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: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">check_wind_speed</span><span style="color: #ADBAC7">():</span></span>
<span class="line"><span style="color: #ADBAC7">    url </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;https://services.swpc.noaa.gov/products/solar-wind/plasma-2-hour.json&quot;</span><span style="color: #ADBAC7"> </span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">try</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        response </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> requests.get(url)</span></span>
<span class="line"><span style="color: #ADBAC7">        response.raise_for_status()  </span><span style="color: #768390"># Checks if the request was successful</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        data </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> response.json()</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">not</span><span style="color: #ADBAC7"> data </span><span style="color: #F47067">or</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">len</span><span style="color: #ADBAC7">(data) </span><span style="color: #F47067">&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        latest_entry </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> data&#91;</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">&#93;</span></span>
<span class="line"><span style="color: #ADBAC7">        wind_speed_value </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> latest_entry&#91;</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">&#93;  </span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> wind_speed_value</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">except</span><span style="color: #ADBAC7"> requests.exceptions.HTTPError </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> e:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;HTTP error occurred: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">except</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">Exception</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> e:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;An error occurred: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> wind_speed_value</span></span></code></pre></div>
</div>



<p>This function uses the <code>requests</code> module in Python to access a JSON file from NOAA. After confirming a successful connection, it extracts the most recent entry in the JSON file and retrieves the value at index 2, which corresponds to the solar wind speed. Below is an example of the JSON format returned by the API:</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>[
  &#91;
    "time_tag",
    "density",
    "speed",
    "temperature"
  &#93;,
  &#91;
    "2025-02-06 17:59:00.000",
    "0.55",
    "482.3",
    "252385"
  &#93;
]</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: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">  &#91;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;time_tag&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;density&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;speed&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;temperature&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">  &#93;,</span></span>
<span class="line"><span style="color: #ADBAC7">  &#91;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;2025-02-06 17:59:00.000&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;0.55&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;482.3&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;252385&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">  &#93;</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre></div>



<p>As shown, the first entry in the JSON file represents the field labels (time, density, speed, and temperature), while the second entry contains the latest data, including the solar wind speed, which is stored at index 2. This structure makes it very easy to extract the required data, allowing it to be compared against the warning and critical thresholds set by the user. By checking the wind speed value against these thresholds, the plugin can quickly determine if the space weather conditions are within acceptable limits or if they require attention.</p>



<h3 class="wp-block-heading">Processing and Sending Data to Nagios XI</h3>



<p>Once the values are collected from the data retrieval function, the next step is to determine the severity of the value and send the result to Nagios XI. The following code snippet demonstrates how the severity is assessed:</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>if args.wind_speed:
        warning_default = 400
        critical_default = 700
        if args.warning:
            warning_default = args.warning
        if args.critical:
            critical_default = args.critical
        wind_speed = check_wind_speed()
        if wind_speed == None:
            print("Wind speed not found.")
            exit(3)
        elif float(wind_speed) > critical_default:
            print(f"CRITICAL - Solar wind speed is HIGH: {wind_speed} km/s | WindSpeed={wind_speed};{warning_default};{critical_default};;")
            exit(2)
        elif float(wind_speed) > warning_default: 
            print(f"WARNING - Solar wind speed is MILD: {wind_speed} km/s | WindSpeed={wind_speed};{warning_default};{critical_default};;")
            exit(1) 
        else:
            print(f"OK - Solar wind speed is LOW: {wind_speed} km/s | WindSpeed={wind_speed};{warning_default};{critical_default};;")
            exit(0)</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: #F47067">if</span><span style="color: #ADBAC7"> args.wind_speed:</span></span>
<span class="line"><span style="color: #ADBAC7">        warning_default </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span></span>
<span class="line"><span style="color: #ADBAC7">        critical_default </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">700</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> args.warning:</span></span>
<span class="line"><span style="color: #ADBAC7">            warning_default </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> args.warning</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> args.critical:</span></span>
<span class="line"><span style="color: #ADBAC7">            critical_default </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> args.critical</span></span>
<span class="line"><span style="color: #ADBAC7">        wind_speed </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> check_wind_speed()</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> wind_speed </span><span style="color: #F47067">==</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Wind speed not found.&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">exit</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">elif</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">(wind_speed) </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> critical_default:</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;CRITICAL - Solar wind speed is HIGH: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">wind_speed</span><span style="color: #F47067">}</span><span style="color: #96D0FF"> km/s | WindSpeed=</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">wind_speed</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">warning_default</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">critical_default</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;;&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">exit</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">elif</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">(wind_speed) </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> warning_default: </span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;WARNING - Solar wind speed is MILD: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">wind_speed</span><span style="color: #F47067">}</span><span style="color: #96D0FF"> km/s | WindSpeed=</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">wind_speed</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">warning_default</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">critical_default</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;;&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">exit</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">) </span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;OK - Solar wind speed is LOW: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">wind_speed</span><span style="color: #F47067">}</span><span style="color: #96D0FF"> km/s | WindSpeed=</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">wind_speed</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">warning_default</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">critical_default</span><span style="color: #F47067">}</span><span style="color: #96D0FF">;;&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">exit</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">)</span></span></code></pre></div>



<p>The first thing this block of code does is check if the wind speed argument has been passed through. Next, it sets either default values or user-defined values for the warning and critical thresholds, depending on what has been specified. After that, it calls the <code>check_wind_speed()</code> function and compares the value to the defined thresholds within the <code>if</code> statements. Based on the comparison, it sends a message and an exit status code to Nagios XI for interpretation. The last part of the message is separated by a pipe (|), and it is formatted like this: <code>&lt;Value_Name&gt;=&lt;Value&gt;;&lt;Warning_Threshold&gt;;&lt;Critical_Threshold&gt;;;</code>. This format allows Nagios XI to graph the chosen value over time, facilitating the monitoring and alerting of space weather conditions.</p>



<h2 class="wp-block-heading">How it Looks in Nagios</h2>



<p>Now that you understand how the code works, let&#8217;s take a look at how it appears in Nagios XI, along with an example of the graphs generated by Nagios:</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="661" src="https://library.nagios.com/wp-content/uploads/2025/02/image-60-1024x661.png" alt="An Image showing a list of services from the space weather plugin on Nagios XI." class="wp-image-44343" title="Nagios XI Space Weather Plugin 26" srcset="https://library.nagios.com/wp-content/uploads/2025/02/image-60-1024x661.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/image-60-300x194.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/image-60-768x496.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/image-60.png 1255w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="448" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-145338-1024x448.png" alt="Image of Solar Wind Graph" class="wp-image-44748" title="Nagios XI Space Weather Plugin 27" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-145338-1024x448.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-145338-300x131.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-145338-768x336.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-145338.png 1190w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>The space weather plugin offers a wide range of metrics and detection services, allowing you to monitor the specific conditions that best fit your needs. As shown in the images above, all the data is conveniently centralized in one place, making it easier to access than browsing multiple websites. Additionally, it provides visualizations through graphs, enabling you to easily spot trends in space weather activity.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>The Nagios space weather plugin offers a powerful solution for monitoring and managing space weather conditions that can impact various technologies and industries. By providing real-time data on solar activity, including solar wind speed, geomagnetic storms, and aurora forecasts, it enables users to stay informed and make proactive decisions. The integration with Nagios XI allows for seamless alerting and graphical representation of key metrics, ensuring that space weather disruptions are quickly identified and addressed. With this plugin, organizations can enhance their preparedness and response to space weather events, safeguarding critical infrastructure and operations.</p>



<h2 class="wp-block-heading">Install the Plugin</h2>



<p>To get started with the plugin, simply visit <a href="https://github.com/NagiosEnterprises/wizards-extra/tree/main/spaceweatherwizard" target="_blank" rel="noreferrer noopener">Nagios Enterprises GitHub</a> repository and download the ZIP file. Once downloaded, open Nagios in your browser, navigate to <strong>Admin &gt; System Extensions &gt; Manage Config Wizards</strong>, then click <strong>Browse</strong> and upload the file. This will add the wizard and plugin to your Nagios instance and get you set up to monitor space weather conditions. To learn more about the wizard before using it, press <a href="https://library.nagios.com/monitoring/space-weather-configuration-wizard/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>If you&#8217;d like to create your own plugin, click the link <a href="https://library.nagios.com/training/guide-to-writing-custom-plugins/" target="_blank" rel="noreferrer noopener">here</a> for a tutorial using bash, or if you&#8217;d prefer a video watch the video below to get a better understanding of how creating and configuring plugins work.</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Creating A Nagios Plugin In Bash For Monitoring CPU Usage With Nagios XI - Caleb DePaulis" width="800" height="450" src="https://www.youtube.com/embed/DB-H_CKn_Wk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>
]]></content:encoded>
					
		
		
		<media:content url="https://www.youtube.com/embed/DB-H_CKn_Wk" medium="video">
			<media:player url="https://www.youtube.com/embed/DB-H_CKn_Wk" />
			<media:title type="plain">Plugins Archives - Nagios Library</media:title>
			<media:description type="html"><![CDATA[Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.]]></media:description>
			<media:thumbnail url="https://library.nagios.com/wp-content/uploads/2025/02/istockphoto-1403644222-612x612-1.jpg" />
			<media:rating scheme="urn:simple">nonadult</media:rating>
		</media:content>
	</item>
		<item>
		<title>Enhancing Power Monitoring With Nagios XI</title>
		<link>https://library.nagios.com/monitoring/enhancing-power-monitoring-with-nagios-xi/</link>
		
		<dc:creator><![CDATA[Jack Brisben]]></dc:creator>
		<pubDate>Thu, 06 Feb 2025 21:08:25 +0000</pubDate>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Setup & Installation]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=44149</guid>

					<description><![CDATA[Introduction: The Need for Power Monitoring in Data Centers. In the digital age, power consumption is a critical aspect of IT infrastructure, especially in data centers. Monitoring power consumption helps ensure operational efficiency, reduces energy costs, and prevents unexpected power-related outages. The Check_Power plugin for Nagios XI is designed to track power consumption in real [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">Introduction: The Need for Power Monitoring in Data Centers.</h3>



<p>In the digital age, power consumption is a critical aspect of IT infrastructure, especially in data centers. Monitoring power consumption helps ensure operational efficiency, reduces energy costs, and prevents unexpected power-related outages. The <strong>Check_Power</strong> plugin for Nagios XI is designed to track power consumption in real time, assess its impact, and report any critical deviations. This plugin adds an additional layer of monitoring for organizations looking to keep track of energy use and optimize their IT infrastructure.</p>



<p>In this article, we will walk you through integrating the <strong>Check_Power</strong> Java plugin with Nagios XI. This plugin fetches data from a power API, calculates the Power Usage Effectiveness (PUE), and sends alerts based on the power consumption and PUE values.</p>



<h3 class="wp-block-heading">Overview of the Nagios Check Power Plugin</h3>



<p>The <strong>Check_Power</strong> plugin is a Java-based solution that connects to a given power API endpoint, retrieves the current power consumption value, and calculates the <strong>PUE</strong> for your data center&#8217;s efficiency. The plugin categorizes the power consumption status as:</p>



<ul class="wp-block-list">
<li><strong>OK</strong>: Power consumption is within acceptable limits.</li>



<li><strong>WARNING</strong>: Power consumption is above average but not critical.</li>



<li><strong>CRITICAL</strong>: Power consumption exceeds safe thresholds, triggering an alert.</li>
</ul>



<p>The PUE value is also calculated using a fixed formula for energy efficiency in data centers:</p>



<p class="has-text-align-center"><strong>PUE = Total&nbsp;Facility&nbsp;Energy / IT Energy</strong></p>



<p>This plugin serves as an essential tool for power monitoring in both smaller and larger IT environments.</p>



<h3 class="wp-block-heading">How It Works</h3>



<ol class="wp-block-list">
<li><strong>Fetch Power Data</strong>: The plugin makes a GET request to the specified power API endpoint and retrieves the power consumption data.</li>



<li><strong>Calculate PUE</strong>: The plugin calculates the <strong>Power Usage Effectiveness (PUE)</strong> value based on the total facility energy and IT energy.</li>



<li><strong>Evaluate Power Status</strong>: The plugin checks the retrieved power consumption and returns an alert status based on defined thresholds (e.g., critical for &gt;1000W, warning for &gt;500W).</li>



<li><strong>Alert Reporting</strong>: The plugin sends the status message and power consumption details back to Nagios XI for monitoring.</li>
</ol>



<h3 class="wp-block-heading">Preview of Nagios XI Power Consumption Plugin Code</h3>



<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>import java.io.*;
import java.net.*;

public class Check_Power {

    public static final int OK = 0;
    public static final int WARNING = 1;
    public static final int CRITICAL = 2;
    public static final int UNKNOWN = 3;

    private static final double efficiencyThreshold = 1.5;

    public static void main(String[] args) {
        
        if (args.length != 1) {
            System.err.println("UNKNOWN - Missing power API endpoint URL argument.");
            System.exit(UNKNOWN);
        }

        String powerAPIEndpoint = args&#91;0&#93;; // Get the URL from the command-line argument

        try {
            double powerConsumption = getPowerConsumption(powerAPIEndpoint);
            double pue = calculatePUE();

            String status = checkPowerStatus(powerConsumption);
            String message = String.format("Power consumption: %.2f W | PUE: %.2f", powerConsumption, pue);

            System.out.println(status + " - " + message);
            System.exit(getExitCode(status));

        } catch (Exception e) {
            System.err.println("UNKNOWN - Error: " + e.getMessage());
            System.exit(UNKNOWN);
        }
    }

    private static double getPowerConsumption(String powerAPIEndpoint) throws IOException {
        URL url = new URL(powerAPIEndpoint);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");

        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String inputLine;
        StringBuilder response = new StringBuilder();

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

       
        String jsonResponse = response.toString();
        System.out.println("Raw JSON Response: " + jsonResponse);

        return parsePowerConsumption(jsonResponse);
    }

    private static double parsePowerConsumption(String jsonResponse) {
    
        try {
            
            int startIdx = jsonResponse.indexOf(":") + 1;
            int endIdx = jsonResponse.indexOf("}");
            String powerValueString = jsonResponse.substring(startIdx, endIdx).trim();
            return Double.parseDouble(powerValueString);
        } catch (Exception e) {
            System.err.println("Error parsing power consumption: " + e.getMessage());
            return 0.0; 
        }
    }

    private static double calculatePUE() {
        double totalFacilityEnergy = 5000;
        double itEnergy = 3000;
        return totalFacilityEnergy / itEnergy;
    }

    private static String checkPowerStatus(double powerConsumption) {
        if (powerConsumption > 1000) {
            return "CRITICAL";
        } else if (powerConsumption > 500) {
            return "WARNING";
        } else {
            return "OK";
        }
    }

    private static int getExitCode(String status) {
        switch (status) {    
            case "OK":
                return OK;
            case "WARNING":
                return WARNING;
            case "CRITICAL":
                return CRITICAL;
            default:
                return UNKNOWN;
        }
    }
}
</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: #F47067">import</span><span style="color: #ADBAC7"> java.io.</span><span style="color: #6CB6FF">*</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">import java.net.</span><span style="color: #6CB6FF">*</span><span style="color: #ADBAC7">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">public class Check_Power {</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    public static final int OK = 0;</span></span>
<span class="line"><span style="color: #ADBAC7">    public static final int WARNING = 1;</span></span>
<span class="line"><span style="color: #ADBAC7">    public static final int CRITICAL = 2;</span></span>
<span class="line"><span style="color: #ADBAC7">    public static final int UNKNOWN = 3;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    private static final double efficiencyThreshold = 1.5;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    public static void main(String[] args) {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span></span>
<span class="line"><span style="color: #ADBAC7">        if (args.length != 1) {</span></span>
<span class="line"><span style="color: #ADBAC7">            System.err.println(&quot;UNKNOWN - Missing power API endpoint URL argument.&quot;);</span></span>
<span class="line"><span style="color: #ADBAC7">            System.exit(UNKNOWN);</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        String powerAPIEndpoint = args&#91;0&#93;; </span><span style="color: #768390">// Get the URL from the command-line argument</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        try {</span></span>
<span class="line"><span style="color: #ADBAC7">            double powerConsumption = getPowerConsumption(powerAPIEndpoint);</span></span>
<span class="line"><span style="color: #ADBAC7">            double pue = calculatePUE();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">            String status = checkPowerStatus(powerConsumption);</span></span>
<span class="line"><span style="color: #ADBAC7">            String message = String.format(&quot;Power consumption: %.2f W | PUE: %.2f&quot;, powerConsumption, pue);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">            System.out.println(status + &quot; - &quot; + message);</span></span>
<span class="line"><span style="color: #ADBAC7">            System.exit(getExitCode(status));</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        } catch (Exception e) {</span></span>
<span class="line"><span style="color: #ADBAC7">            System.err.println(&quot;UNKNOWN - Error: &quot; + e.getMessage());</span></span>
<span class="line"><span style="color: #ADBAC7">            System.exit(UNKNOWN);</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    private static double getPowerConsumption(String powerAPIEndpoint) throws IOException {</span></span>
<span class="line"><span style="color: #ADBAC7">        URL url = new URL(powerAPIEndpoint);</span></span>
<span class="line"><span style="color: #ADBAC7">        HttpURLConnection connection = (HttpURLConnection) url.openConnection();</span></span>
<span class="line"><span style="color: #ADBAC7">        connection.setRequestMethod(&quot;GET&quot;);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));</span></span>
<span class="line"><span style="color: #ADBAC7">        String inputLine;</span></span>
<span class="line"><span style="color: #ADBAC7">        StringBuilder response = new StringBuilder();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        while ((inputLine = in.readLine()) != null) {</span></span>
<span class="line"><span style="color: #ADBAC7">            response.append(inputLine);</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">        in.close();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">       </span></span>
<span class="line"><span style="color: #ADBAC7">        String jsonResponse = response.toString();</span></span>
<span class="line"><span style="color: #ADBAC7">        System.out.println(</span><span style="color: #96D0FF">&quot;Raw JSON Response: &quot;</span><span style="color: #ADBAC7"> + jsonResponse);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        return parsePowerConsumption(jsonResponse);</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    private static double parsePowerConsumption(String jsonResponse) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span></span>
<span class="line"><span style="color: #ADBAC7">        try {</span></span>
<span class="line"><span style="color: #ADBAC7">            </span></span>
<span class="line"><span style="color: #ADBAC7">            int startIdx = jsonResponse.indexOf(&quot;:&quot;) + 1;</span></span>
<span class="line"><span style="color: #ADBAC7">            int endIdx = jsonResponse.indexOf(&quot;}</span><span style="color: #96D0FF">&quot;)</span><span style="color: #FF938A; font-style: italic">;</span></span>
<span class="line"><span style="color: #ADBAC7">            String powerValueString = jsonResponse.substring(startIdx, endIdx).trim();</span></span>
<span class="line"><span style="color: #ADBAC7">            return Double.parseDouble(powerValueString);</span></span>
<span class="line"><span style="color: #ADBAC7">        } catch (Exception e) {</span></span>
<span class="line"><span style="color: #ADBAC7">            System.err.println(&quot;Error parsing power consumption: &quot; + e.getMessage());</span></span>
<span class="line"><span style="color: #ADBAC7">            return 0.0; </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    private static double calculatePUE() {</span></span>
<span class="line"><span style="color: #ADBAC7">        double totalFacilityEnergy = 5000;</span></span>
<span class="line"><span style="color: #ADBAC7">        double itEnergy = 3000;</span></span>
<span class="line"><span style="color: #ADBAC7">        return totalFacilityEnergy / itEnergy;</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    private static String checkPowerStatus(double powerConsumption) {</span></span>
<span class="line"><span style="color: #ADBAC7">        if (powerConsumption &gt; 1000) {</span></span>
<span class="line"><span style="color: #ADBAC7">            return &quot;CRITICAL&quot;;</span></span>
<span class="line"><span style="color: #ADBAC7">        } else if (powerConsumption &gt; 500) {</span></span>
<span class="line"><span style="color: #ADBAC7">            return &quot;WARNING&quot;;</span></span>
<span class="line"><span style="color: #ADBAC7">        } else {</span></span>
<span class="line"><span style="color: #ADBAC7">            return &quot;OK&quot;;</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    private static int getExitCode(String status) {</span></span>
<span class="line"><span style="color: #ADBAC7">        switch (status) {    </span></span>
<span class="line"><span style="color: #ADBAC7">            case &quot;OK&quot;:</span></span>
<span class="line"><span style="color: #ADBAC7">                return OK;</span></span>
<span class="line"><span style="color: #ADBAC7">            case &quot;WARNING&quot;:</span></span>
<span class="line"><span style="color: #ADBAC7">                return WARNING;</span></span>
<span class="line"><span style="color: #ADBAC7">            case &quot;CRITICAL&quot;:</span></span>
<span class="line"><span style="color: #ADBAC7">                return CRITICAL;</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">default</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">                return UNKNOWN;</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span></code></pre></div>



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



<h3 class="wp-block-heading">Output on Nagios-XI</h3>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-01-17-152902.png"><img loading="lazy" decoding="async" width="1024" height="380" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-01-17-152902-1024x380.png" alt="Screenshot 2025 01 17 152902" class="wp-image-44215" title="Enhancing Power Monitoring With Nagios XI 28" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-01-17-152902-1024x380.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-01-17-152902-300x111.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-01-17-152902-768x285.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-01-17-152902.png 1170w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption>Enhancing Power Monitoring With Nagios XI 29</figcaption></figure>



<h3 class="wp-block-heading">Integrating the Check Power Plugin into Nagios XI</h3>



<p>To integrate the <strong>Check_Power</strong> plugin with Nagios XI, follow these steps:</p>



<ol class="wp-block-list">
<li><strong>Upload the Plugin to Nagios XI</strong>:
<ul class="wp-block-list">
<li>Log into the Nagios XI Web Interface.</li>



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



<li>Click <strong>Browse</strong>, select the compiled <strong>Check_Power.jar</strong> file, and click <strong>Upload Plugin</strong>.</li>
</ul>
</li>



<li><strong>Set Executable Permissions</strong>:
<ul class="wp-block-list">
<li>After uploading, ensure the plugin is executable:</li>
</ul>
</li>
</ol>



<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>chmod +x /usr/local/nagios/libexec/check_power.jar
</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: #adbac7">chmod +x /usr/local/nagios/libexec/check_power.jar</span></span>
<span class="line"><span style="color: #adbac7"></span></span></code></pre></div>



<p>     3.  <strong>Define the Plugin Command</strong>:</p>



<p><strong>Command Line</strong>:</p>



<p>Go to <strong>Configure &gt; Core Config Manager &gt; Commands &gt; Add New</strong>.</p>



<p>Add the following details:</p>



<p><strong>Command Name</strong>: <code>check_power</code></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>java -jar $USER1$/check_power.jar $HOSTADDRESS$ $ARG1$
</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: #adbac7">java -jar $USER1$/check_power.jar $HOSTADDRESS$ $ARG1$</span></span>
<span class="line"><span style="color: #adbac7"></span></span></code></pre></div>



<ul class="wp-block-list">
<li><strong>Command Type</strong>: Check command.</li>
</ul>



<p><strong>Configure Power Monitoring Service</strong>:</p>



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



<li>Fill in the necessary fields:
<ul class="wp-block-list">
<li><strong>Service Name</strong>: Power Monitoring</li>



<li><strong>Host</strong>: Select the desired host.</li>



<li><strong>Check Command</strong>: <code>check_power!http://your-power-api-endpoint.com</code></li>
</ul>
</li>



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



<h3 class="wp-block-heading">AI Assistance Acknowledgment</h3>



<p>This plugin and article development were assisted by AI, demonstrating how artificial intelligence can streamline IT solutions and inspire innovation. We encourage others to explore AI-driven development to enhance their IT operations.</p>



<h3 class="wp-block-heading">Why This Plugin is Valuable for IT Security and Monitoring</h3>



<ol class="wp-block-list">
<li><strong>Real-Time Power Consumption Monitoring</strong>: Track energy consumption and detect inefficiencies in real-time.</li>



<li><strong>Energy Efficiency Reporting</strong>: The calculated PUE value provides insight into the efficiency of the entire data center&#8217;s energy use.</li>



<li><strong>Proactive Alerting</strong>: Alerts on power consumption thresholds help prevent potential damage to IT infrastructure.</li>



<li><strong>Seamless Integration</strong>: Easily integrates with Nagios XI, leveraging its centralized monitoring and alerting system.</li>
</ol>



<h3 class="wp-block-heading">Best Practices for Using the Check Power Plugin</h3>



<ol class="wp-block-list">
<li><strong>Set Up Regular Monitoring</strong>: Schedule periodic checks to consistently track power usage and avoid unexpected surges.</li>



<li><strong>Optimize Energy Consumption</strong>: Leverage the PUE value to identify opportunities to improve the energy efficiency of your data center.</li>



<li><strong>Integrate with Other IT Management Tools</strong>: Combine with other Nagios XI plugins for a comprehensive IT management strategy.</li>
</ol>



<h3 class="wp-block-heading">Conclusion: Strengthening Energy Management with the Check_Power Plugin</h3>



<p>The <strong>Check_Power</strong> plugin for Nagios XI is a powerful tool for monitoring power consumption and improving the overall energy efficiency of data centers. By proactively tracking power usage and calculating the PUE, IT teams can enhance their infrastructure’s performance, reduce energy costs, and prevent potential issues before they arise. With easy integration into Nagios XI, this plugin provides an accessible, efficient solution for IT professionals striving for better energy management and sustainability.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Easily Monitor Website Response Time &#8211; a Nagios XI Plugin for 2025</title>
		<link>https://library.nagios.com/monitoring/website-time-plugin/</link>
		
		<dc:creator><![CDATA[Louie Mattia]]></dc:creator>
		<pubDate>Thu, 06 Feb 2025 18:31:58 +0000</pubDate>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Plugins]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=41445</guid>

					<description><![CDATA[What is this for? Nagios XI is equipped with a variety of wizards and plugins designed to monitor various systems, including operating systems, routers, devices, and websites. While many of these plugins are designed to track different services, none specifically monitor website traffic or track how frequently a website is visited. Why it was made [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">What is this for?</h2>



<p>Nagios XI is equipped with a variety of wizards and plugins designed to monitor various systems, including operating systems, routers, devices, and websites. While many of these plugins are designed to track different services, none specifically monitor website traffic or track how frequently a website is visited.</p>



<h2 class="wp-block-heading">Why it was made</h2>



<p>This plugin was created to fill that gap. The goal is to monitor how often a website is visited based on response time. Although not every user may need this functionality, there are specific use cases where it can be highly beneficial. For example, marketing teams can use this plugin to assess how frequently their online products are being viewed, while schools or organizations may wish to track how often certain websites are being accessed. The core idea is simple: the more frequently a website is visited, the slower its response time becomes. By monitoring response times, we can infer the frequency of website visits.</p>



<h2 class="wp-block-heading">Overview of Plugin</h2>



<p>This Nagios XI plugin is written in Python and requires minimal setup. The only additional piece of information required from the user is the URL of the website you wish to monitor. Once configured, the plugin tracks website response time and provides insights into its visit frequency.</p>



<h2 class="wp-block-heading">Nagios XI Website Time Plugin Code</h2>



<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
import sys
import requests
import time
import argparse

'''
This website is to monitor the usage of websites
This is done by measuring the response time
Louie Mattia Jan 2025
'''

parser = argparse.ArgumentParser()

# Add the website name when calling
parser.add_argument( '-H',
                    '--host',
                    required=True,
                    type=str,
                    help='The website that will be checked')

args = parser.parse_args()

# Assign website name as variable fo use
website = args.host

# Set timeout timer (allow the program to give up)
TIMEOUT = 10 # Seconds

# Threshold times for Warning and Critical
### Try to add for editable values in XI later, get this working first
WARN_START = 2
CRIT_START = 5

# Output parameters, defaults for Nagios
# DONT CHANGE, IT WILL NOT WORK OTHERWISE
OK = 0
WARNING = 1
CRITICAL = 2
UNKNOWN = 3

def check_response():
    # Make sure it can grab the time properly
    try:
        start = time.time()
        response = requests.get(website, timeout=TIMEOUT)
        # How long did it take to respond
        response_time = time.time() - start

        # Status code 200 means its reachable
        if response.status_code == 200:
            # At this point, check if the repsonse time is critial
            if response_time >= CRIT_START:
                print(f"Response time {response_time:.2f}s exceeds {CRIT_START}s, this site is busy")
                return CRITICAL
            # If not, is it at the warning?
            elif response_time >= WARN_START:
                print(f"Response time {response_time:.2f}s exceeds {WARN_START}s, this site is getting active")
                return WARNING
            # Looks like its fine if it makes it here
            else:
                print(f"This website is calm for now, response time is {response_time:.2f}")
                return OK
        # If different status code, something is up
        else:
            code = response.status_code
            print(f"Status code returned {code:.2f}")
            return CRITICAL
    except requests.exceptions.RequestException as e:
        print("Website cannot be reached")
        return CRITICAL

if __name__ == "__main__":
        exit = check_response()
        sys.exit(exit)
</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</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> sys</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> requests</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> time</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #96D0FF">&#39;&#39;&#39;</span></span>
<span class="line"><span style="color: #96D0FF">This website is to monitor the usage of websites</span></span>
<span class="line"><span style="color: #96D0FF">This is done by measuring the response time</span></span>
<span class="line"><span style="color: #96D0FF">Louie Mattia Jan 2025</span></span>
<span class="line"><span style="color: #96D0FF">&#39;&#39;&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">parser </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> argparse.ArgumentParser()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># Add the website name when calling</span></span>
<span class="line"><span style="color: #ADBAC7">parser.add_argument( </span><span style="color: #96D0FF">&#39;-H&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #96D0FF">&#39;--host&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">required</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">help</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;The website that will be checked&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">args </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> parser.parse_args()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># Assign website name as variable fo use</span></span>
<span class="line"><span style="color: #ADBAC7">website </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> args.host</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># Set timeout timer (allow the program to give up)</span></span>
<span class="line"><span style="color: #6CB6FF">TIMEOUT</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># Seconds</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># Threshold times for Warning and Critical</span></span>
<span class="line"><span style="color: #768390">### Try to add for editable values in XI later, get this working first</span></span>
<span class="line"><span style="color: #6CB6FF">WARN_START</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span>
<span class="line"><span style="color: #6CB6FF">CRIT_START</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">5</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># Output parameters, defaults for Nagios</span></span>
<span class="line"><span style="color: #768390"># DONT CHANGE, IT WILL NOT WORK OTHERWISE</span></span>
<span class="line"><span style="color: #6CB6FF">OK</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span></span>
<span class="line"><span style="color: #6CB6FF">WARNING</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span></span>
<span class="line"><span style="color: #6CB6FF">CRITICAL</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span>
<span class="line"><span style="color: #6CB6FF">UNKNOWN</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">check_response</span><span style="color: #ADBAC7">():</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390"># Make sure it can grab the time properly</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">try</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        start </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> time.time()</span></span>
<span class="line"><span style="color: #ADBAC7">        response </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> requests.get(website, </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">TIMEOUT</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># How long did it take to respond</span></span>
<span class="line"><span style="color: #ADBAC7">        response_time </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> time.time() </span><span style="color: #F47067">-</span><span style="color: #ADBAC7"> start</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># Status code 200 means its reachable</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> response.status_code </span><span style="color: #F47067">==</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390"># At this point, check if the repsonse time is critial</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> response_time </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">CRIT_START</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;Response time </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">response_time</span><span style="color: #F47067">:.2f}</span><span style="color: #96D0FF">s exceeds </span><span style="color: #F47067">{</span><span style="color: #6CB6FF">CRIT_START</span><span style="color: #F47067">}</span><span style="color: #96D0FF">s, this site is busy&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">CRITICAL</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390"># If not, is it at the warning?</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">elif</span><span style="color: #ADBAC7"> response_time </span><span style="color: #F47067">&gt;=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">WARN_START</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;Response time </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">response_time</span><span style="color: #F47067">:.2f}</span><span style="color: #96D0FF">s exceeds </span><span style="color: #F47067">{</span><span style="color: #6CB6FF">WARN_START</span><span style="color: #F47067">}</span><span style="color: #96D0FF">s, this site is getting active&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">WARNING</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390"># Looks like its fine if it makes it here</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;This website is calm for now, response time is </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">response_time</span><span style="color: #F47067">:.2f}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">OK</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># If different status code, something is up</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">            code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> response.status_code</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;Status code returned </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">code</span><span style="color: #F47067">:.2f}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">CRITICAL</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">except</span><span style="color: #ADBAC7"> requests.exceptions.RequestException </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> e:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Website cannot be reached&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">CRITICAL</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">if</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__name__</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">==</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;__main__&quot;</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">exit</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> check_response()</span></span>
<span class="line"><span style="color: #ADBAC7">        sys.exit(</span><span style="color: #6CB6FF">exit</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span></code></pre></div>



<p>You can access the code through Github using this link: <a href="https://github.com/NagiosEnterprises/plugins-extra/blob/website_time/website_time.py" target="_blank" rel="noopener">https://github.com/NagiosEnterprises/plugins-extra/blob/website_time/website_time.py</a></p>



<h2 class="wp-block-heading">Output on Nagios XI</h2>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-06-103411.png"><img loading="lazy" decoding="async" width="755" height="384" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-06-103411.png" alt="Screenshot 2025 02 06 103411" class="wp-image-44201" title="Easily Monitor Website Response Time - a Nagios XI Plugin for 2025 30" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-06-103411.png 755w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-06-103411-300x153.png 300w" sizes="(max-width: 755px) 100vw, 755px" /></a><figcaption class="wp-element-caption">Website Time Output</figcaption></figure>



<p>As you can see, it gives us the time it took for the website to respond along with a little message about how often it was visited.</p>



<h2 class="wp-block-heading">Integrating into Nagios XI</h2>



<ol class="wp-block-list">
<li>Integrate into Nagios XI
<ol class="wp-block-list">
<li>Navigate to Admin&gt;System Extensions&gt;Manage Plugins</li>



<li>Click browse, locate the plugin file, and hit upload</li>
</ol>
</li>



<li>Define Plugin as Nagios Command
<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: website_time(or any name you prefer, as long as you can identify the command)</li>



<li>Command Line: <code>python3 $USER1$/website_time.py -H https://$HOSTADDRESS$</code>
<ul class="wp-block-list">
<li>Ensure the <code>https://</code> prefix is included for the command to work correctly</li>
</ul>
</li>



<li>Command Type: Check Command</li>
</ul>
</li>



<li>After filling in the details, save the command.</li>
</ol>
</li>



<li>Configure for a service
<ol class="wp-block-list">
<li>Go 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: Website Time</li>



<li>Host: Any applicable website</li>



<li>Check Command: website_time</li>
</ul>
</li>



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



<h2 class="wp-block-heading">AI Assistance Acknowledged </h2>



<p>This plugin was developed with the assistance of AI, highlighting how AI can streamline the development process. We encourage developers to leverage AI tools to enhance their IT operations and improve efficiency.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>While it doesn&#8217;t directly track visits, slower response times can provide valuable insights into how often a website is being accessed. This can be especially useful for organizations wanting to understand traffic patterns or measure the performance impact of high traffic levels. Whether for marketing teams analyzing engagement or IT teams tracking website performance, this plugin helps users gain useful data based on inferred visit frequency, ultimately supporting better decision-making and resource management.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Why Monitor Space Weather: Critical Insights</title>
		<link>https://library.nagios.com/monitoring/why-to-monitor-space-weather/</link>
		
		<dc:creator><![CDATA[Caleb DePaulis]]></dc:creator>
		<pubDate>Wed, 05 Feb 2025 21:20:13 +0000</pubDate>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Plugins]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=44000</guid>

					<description><![CDATA[As the Sun reaches its current solar maximum, a range of potential hazards emerge, posing significant risks to both space-based and Earth-based technologies. This article will offer an in-depth examination of space weather, including the various phenomena that occur during this active phase of the Sun&#8217;s 11-year cycle. It will also explore the specific dangers [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>As the Sun reaches its current solar maximum, a range of potential hazards emerge, posing significant risks to both space-based and Earth-based technologies. This article will offer an in-depth examination of space weather, including the various phenomena that occur during this active phase of the Sun&#8217;s 11-year cycle. It will also explore the specific dangers associated with solar maxima, such as increased solar flares and coronal mass ejections, and explain why it is crucial to continuously monitor these events to mitigate their impact on modern infrastructure and communication systems.<br></p>



<h2 class="wp-block-heading">What is Space Weather?</h2>



<p>Space weather refers to the environmental conditions in space that can affect Earth and our technology, primarily driven by the activity of the Sun. It encompasses a variety of phenomena, including solar flares, coronal mass ejections (CMEs), solar wind, and geomagnetic storms, all of which are caused by the Sun&#8217;s activity.</p>



<p>At the core of space weather are solar emissions, such as energetic particles and radiation, which can be emitted during periods of heightened solar activity, like solar flares or the ejection of large masses of solar material. These solar events can travel through space, impacting the Earth’s magnetosphere and ionosphere. When these high-energy particles interact with Earth’s magnetic field, they can cause geomagnetic storms, disrupting satellite communications, GPS systems, power grids, and even posing risks to astronauts and spacecraft.</p>



<p>In addition to solar emissions, space weather also includes the behavior of the solar wind—a constant stream of charged particles emitted by the Sun. While typically less intense, the solar wind can also affect satellite operations and the behavior of Earth’s magnetosphere. This constant solar activity, though often invisible to the naked eye, can have significant effects on modern technological systems, highlighting the need for vigilant monitoring and understanding of space weather.</p>



<h2 class="wp-block-heading">Challenges in Predicting Space Weather</h2>



<p>Predicting space weather is challenging due to the complex and unpredictable nature of the Sun’s activity. Unlike terrestrial weather, which relies on observable patterns, space weather is driven by solar events like flares and coronal mass ejections (CMEs) that are difficult to predict in terms of timing, location, and intensity. The Sun’s magnetic field is dynamic and not fully understood, adding to the uncertainty.</p>



<p>Additionally, solar events travel through space at varying speeds, making it hard to predict their exact arrival at Earth. While we can observe solar activity and model space weather, the unpredictable behavior of the Sun and Earth&#8217;s magnetic field interactions make precise forecasts difficult. Current predictions are often based on trends or probabilities rather than certainty, as researchers continue to improve observation techniques and modeling methods.</p>



<p>Solar storms are typically predicted with certainty only 1 to 3 days before arrival due to the difficulty in forecasting solar flares and CMEs. These events release high-speed particles that take 15 to 90 hours to reach Earth, limiting long-term warnings. While we can detect solar activity as it happens, the variable travel time makes early preparation challenging.</p>



<h2 class="wp-block-heading">Why Should Space Weather be Monitored?</h2>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="756" src="https://library.nagios.com/wp-content/uploads/2025/02/Coronal_mass_ejection_CME_blast_and_subsequent_impact_at_Earth_pillars_3bcdc3-1024x756.jpg" alt="An image that shows the earths magnetic field combating the severe space weather form the sun." class="wp-image-44036" title="Why Monitor Space Weather: Critical Insights 31" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Coronal_mass_ejection_CME_blast_and_subsequent_impact_at_Earth_pillars_3bcdc3-1024x756.jpg 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Coronal_mass_ejection_CME_blast_and_subsequent_impact_at_Earth_pillars_3bcdc3-300x222.jpg 300w, https://library.nagios.com/wp-content/uploads/2025/02/Coronal_mass_ejection_CME_blast_and_subsequent_impact_at_Earth_pillars_3bcdc3-768x567.jpg 768w, https://library.nagios.com/wp-content/uploads/2025/02/Coronal_mass_ejection_CME_blast_and_subsequent_impact_at_Earth_pillars_3bcdc3-1536x1134.jpg 1536w, https://library.nagios.com/wp-content/uploads/2025/02/Coronal_mass_ejection_CME_blast_and_subsequent_impact_at_Earth_pillars_3bcdc3.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Space weather is increasingly important to monitor as it has the potential to significantly impact modern technology and human activities. Solar events such as solar flares, coronal mass ejections (CMEs), and variations in solar wind can disrupt communications, damage infrastructure, and pose risks to both space missions and daily life on Earth. Understanding space weather allows for early warnings, enabling mitigation strategies to minimize damage and prevent costly or dangerous disruptions. For more information and updates, you can visit the <a href="https://www.swpc.noaa.gov/" data-type="link" data-id="https://www.swpc.noaa.gov/" target="_blank" rel="noopener">NOAA Space Weather Prediction Center</a>. Below are key space weather phenomena that highlight the need for constant monitoring.</p>



<h3 class="wp-block-heading">Geomagnetic Storms</h3>



<p>Geomagnetic storms occur when solar wind or a CME interacts with Earth&#8217;s magnetosphere, causing disturbances in the magnetic field. These storms can induce electric currents in power lines, leading to transformer damage and widespread power outages. Geomagnetic storms also have the potential to affect satellite orbits, damaging or even disabling satellites, and can cause navigation system failures. Additionally, the storm&#8217;s effects on Earth’s ionosphere can disrupt high-frequency radio communications, making global communication difficult.</p>



<h3 class="wp-block-heading">Radio Blackouts</h3>



<p>Radio blackouts occur when solar flares increase in intensity, sending out bursts of electromagnetic radiation that can interfere with radio signals. These blackouts primarily affect high-frequency (HF) radio communications, which are widely used by aviation, maritime, and military operations for long-range communication. Solar flares can cause these radio signals to be absorbed or refracted in the ionosphere, leading to complete loss of communication in certain regions, especially during the peak of a solar flare.</p>



<h3 class="wp-block-heading">Solar Radiation Storms</h3>



<p>Solar radiation storms are characterized by the release of high-energy particles, such as protons and electrons, from the Sun during solar flares or CMEs. These storms pose a serious threat to astronauts and spacecraft, as the particles can damage electronic components and increase radiation exposure, potentially compromising mission safety. At lower altitudes, the effects are less severe, but radiation from solar storms can still disrupt aviation systems, particularly for flights that cross polar regions, where the atmosphere provides less shielding from cosmic radiation.</p>



<h2 class="wp-block-heading"><strong>What is Typically Monitored in Space Weather?</strong></h2>



<p>To predict space weather, scientists track several key factors to assess the potential risks of solar events like coronal mass ejections (CMEs) and solar flares. These measurements provide early warnings and help mitigate the effects of solar activity on Earth’s infrastructure.</p>



<h3 class="wp-block-heading"><strong>Solar Activity and Sunspot Cycles</strong></h3>



<p>The Sun follows an 11-year solar cycle of high and low activity, marked by the appearance of sunspots. Sunspots indicate increased solar flares and CMEs. Monitoring sunspot activity helps predict periods of heightened solar events.</p>



<h3 class="wp-block-heading"><strong>Coronal Mass Ejections (CMEs)</strong></h3>



<p>CMEs are large bursts of solar wind and magnetic fields released from the Sun’s corona. These can take 15-90 hours to reach Earth. CMEs are monitored using spacecraft like SOHO and SDO to track their speed, size, and direction, as they can cause geomagnetic storms that disrupt satellite operations and power grids.</p>



<p><strong>Why CMEs are Dangerous</strong>: The magnetic fields carried by CMEs can significantly disturb Earth’s magnetosphere, leading to intense geomagnetic storms that may damage satellites, power systems, and communication infrastructure.</p>



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



<p>Solar flares are intense bursts of radiation, monitored using X-ray and UV instruments like the GOES satellites. These flares emit large amounts of radiation that can disrupt satellite communication, GPS systems, and cause radio blackouts, especially on high-frequency radio bands.</p>



<p><strong>Why Solar Flares are Dangerous</strong>: Solar flares release radiation that can interfere with electronics, pose risks to astronauts, and disrupt long-range communications.</p>



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



<p>Solar wind, a constant stream of charged particles, is monitored to predict solar activity. It can distort Earth’s magnetic field, contributing to geomagnetic storms and affecting satellite systems.</p>



<p><strong>Why Solar Wind is Dangerous</strong>: High-intensity solar wind can amplify the effects of CMEs and solar flares, further disrupting communications and satellite operations.</p>



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



<p>Plasma density indicates the concentration of charged particles in solar wind and CMEs. Higher plasma density leads to stronger interactions with Earth’s magnetosphere, increasing the potential for geomagnetic storms.</p>



<h3 class="wp-block-heading"><strong>Bz and Bt Components</strong></h3>



<p>Bz refers to the solar wind’s magnetic field component along the Sun-Earth axis, while Bt measures the magnetic field in the plane of the solar wind. When Bz points southward, it can cause stronger geomagnetic storms by more easily interacting with Earth&#8217;s magnetic field.</p>



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



<p>The Kp index measures geomagnetic activity on a scale of 0 to 9, with higher values indicating more intense space weather. It helps assess the severity of solar wind and CME impacts, predicting disruptions to satellite communications and power systems.</p>



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



<p>Hemispheric power tracks the energy released during geomagnetic storms, which is measured in gigawatts. Higher hemispheric power indicates a more intense storm, which can cause significant disruptions to Earth’s infrastructure, including satellites and power grids.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>By monitoring these factors—solar activity, CMEs, solar flares, plasma density, Bz/Bt components, and space weather indices like Kp and hemispheric power—scientists can predict and understand the severity of solar events. This information helps prepare for and mitigate potential disruptions to communications, navigation systems, and power grids.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Space weather plays a critical role in shaping the impact on our technological systems and daily lives. As solar activity reaches its maximum, the risks posed by solar flares, CMEs, and other space weather phenomena grow more significant. Monitoring these events is essential to predicting and mitigating their potential impact on everything from communication systems to satellite operations. With advancements in space weather forecasting, we are better equipped to understand and respond to these challenges, but continued vigilance and preparedness are key to minimizing disruptions. By staying informed and proactive, we can better protect our infrastructure and ensure the resilience of modern society.</p>



<h2 class="wp-block-heading">Start Monitoring Space Weather Using Nagios XI</h2>



<p>To start monitoring space weather with Nagios XI, visit the <a href="https://github.com/NagiosEnterprises/wizards-extra/tree/main/spaceweatherwizard" target="_blank" rel="noopener">Nagios Enterprises GitHub</a> link provided and download the ZIP file. Once the download is complete, open Nagios in your browser, go to <strong>Admin > System Extensions > Manage Config Wizards</strong>, then click <strong>Browse</strong> to upload the file. This will add the wizard and plugin to your Nagios instance, setting you up to monitor space weather conditions.</p>



<p>For a deeper understanding of the plugin and its functionality, click <a href="https://library.nagios.com/monitoring/nagios-xi-space-weather-plugin/">here </a>to read a detailed article. If you&#8217;d like more information about the configuration wizard for this plugin, click <a href="https://library.nagios.com/monitoring/space-weather-configuration-wizard/">here</a>.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Enhance Security with Nagios XI Port Monitoring Plugin</title>
		<link>https://library.nagios.com/solutions/port-monitoring-plugin-nagios-xi/</link>
		
		<dc:creator><![CDATA[Ayub Huruse]]></dc:creator>
		<pubDate>Tue, 04 Feb 2025 16:09:14 +0000</pubDate>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[Industry Insights]]></category>
		<category><![CDATA[Plugins]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=41324</guid>

					<description><![CDATA[Introduction: Why Port Monitoring Matters in Security Nagios XI port monitoring plugin is essential for proactive cybersecurity defense. Monitoring open ports helps prevent unauthorized access and potential cyber threats. While Nagios XI provides powerful monitoring capabilities, integrating a custom Nagios XI port monitoring plugin enhances network security by detecting unexpected open ports before they become [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction: Why Port Monitoring Matters in Security</h2>



<p>Nagios XI port monitoring plugin is essential for proactive cybersecurity defense. Monitoring open ports helps prevent unauthorized access and potential cyber threats. While Nagios XI provides powerful monitoring capabilities, integrating a custom <a href="https://www.nagios.com/products/nagios-xi/" target="_blank" rel="noopener">Nagios XI</a> port monitoring plugin enhances network security by detecting unexpected open ports before they become vulnerabilities.</p>



<p>This article introduces a lightweight and efficient Bash script that functions as a Nagios XI port monitoring plugin to scan and detect open ports. By adding this custom monitoring solution, IT teams can proactively secure their networks and improve compliance with security policies.</p>



<h2 class="wp-block-heading">Overview of the Nagios Port Monitoring Plugin</h2>



<p>This Nagios XI port monitoring plugin is a Bash script that uses netcat (nc) to scan a target system’s open ports. It accepts two arguments:</p>



<ul class="wp-block-list">
<li>Host/IP Address – The system to be scanned.</li>



<li>Port Number – The port to check for accessibility.</li>
</ul>



<h3 class="wp-block-heading">How It Works</h3>



<ul class="wp-block-list">
<li>If the port is open, the script returns a <strong>CRITICAL </strong>status, triggering an alert in Nagios XI.</li>



<li>If the port is closed, it returns an <strong>OK </strong>status, confirming that no risk is detected.</li>
</ul>



<p>By using this Nagios XI port monitoring plugin, IT teams can detect unauthorized open ports in real time, allowing for quick mitigation of potential security risks.</p>



<h2 class="wp-block-heading">Nagios XI Port Monitoring Plugin Code</h2>



<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"><span role="button" data-code="#!/bin/bash
HOST=$1
PORT=$2
if [ -z &quot;$HOST&quot; ] || [ -z &quot;$PORT&quot; ]; then
    echo &quot;Usage: $0  &quot;
    exit 1
fi
# Check if the specific port is open
nc -z -v -w2 $HOST $PORT 2&gt;&amp;1 | grep -q &quot;succeeded&quot;
if [ $? -eq 0 ]; then
    echo &quot;CRITICAL: Port $PORT is open on $HOST&quot;
    exit 2
else
    echo &quot;OK: No open port $PORT detected on $HOST&quot;
    exit 0
fi" style="color:#adbac7" aria-label="Copy" class="code-block-pro-copy-button"></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e"><code><span class="line"><span style="color: #adbac7">#!/bin/bash</span></span>
<span class="line"><span style="color: #adbac7">HOST=$1</span></span>
<span class="line"><span style="color: #adbac7">PORT=$2</span></span>
<span class="line"><span style="color: #adbac7">if [ -z &quot;$HOST&quot; ] || [ -z &quot;$PORT&quot; ]; then</span></span>
<span class="line"><span style="color: #adbac7">    echo &quot;Usage: $0  &quot;</span></span>
<span class="line"><span style="color: #adbac7">    exit 1</span></span>
<span class="line"><span style="color: #adbac7">fi</span></span>
<span class="line"><span style="color: #adbac7"># Check if the specific port is open</span></span>
<span class="line"><span style="color: #adbac7">nc -z -v -w2 $HOST $PORT 2&gt;&amp;1 | grep -q &quot;succeeded&quot;</span></span>
<span class="line"><span style="color: #adbac7">if [ $? -eq 0 ]; then</span></span>
<span class="line"><span style="color: #adbac7">    echo &quot;CRITICAL: Port $PORT is open on $HOST&quot;</span></span>
<span class="line"><span style="color: #adbac7">    exit 2</span></span>
<span class="line"><span style="color: #adbac7">else</span></span>
<span class="line"><span style="color: #adbac7">    echo &quot;OK: No open port $PORT detected on $HOST&quot;</span></span>
<span class="line"><span style="color: #adbac7">    exit 0</span></span>
<span class="line"><span style="color: #adbac7">fi</span></span></code></pre></div>



<p>You can access the code on Github: <a href="https://github.com/NagiosEnterprises/plugins-extra/blob/port_checking_plugin/port_plugin.sh" target="_blank" rel="noopener">https://github.com/NagiosEnterprises/plugins extra/blob/main/port_plugin.sh</a></p>



<h2 class="wp-block-heading">Output on Nagios-XI:</h2>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-15-104210.png"><img loading="lazy" decoding="async" width="792" height="363" src="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-15-104210.png" alt="port checking plugin output with 40 threshold." class="wp-image-41554" title="Enhance Security with Nagios XI Port Monitoring Plugin 32" srcset="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-15-104210.png 792w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-15-104210-300x138.png 300w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-15-104210-768x352.png 768w" sizes="(max-width: 792px) 100vw, 792px" /></a><figcaption class="wp-element-caption">Example output of the host status detail.</figcaption></figure>



<h2 class="wp-block-heading">Example of a Performance Graph:</h2>



<figure class="wp-block-image size-large"><a href="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-114435.png"><img loading="lazy" decoding="async" width="1024" height="490" src="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-114435-1024x490.png" alt="Screenshot 2025 02 07 114435" class="wp-image-44601" title="Enhance Security with Nagios XI Port Monitoring Plugin 33" srcset="https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-114435-1024x490.png 1024w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-114435-300x144.png 300w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-114435-768x368.png 768w, https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-07-114435.png 1270w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Example output of the Performance Graph</figcaption></figure>



<h2 class="wp-block-heading">Integrating the Plugin into Nagios XI</h2>



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



<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 Plugin.</li>
</ol>



<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"><span role="button" data-code="chmod +x /usr/local/nagios/libexec/check_port.sh" style="color:#adbac7" aria-label="Copy" class="code-block-pro-copy-button"></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e"><code><span class="line"><span style="color: #adbac7">chmod +x /usr/local/nagios/libexec/check_port.sh</span></span></code></pre></div>



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



<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: check_port</li>



<li>Command Line:</li>
</ul>
</li>
</ol>



<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"><span role="button" data-code="$USER1$/check_port.sh $HOSTADDRESS$ $ARG1$" style="color:#adbac7" aria-label="Copy" class="code-block-pro-copy-button"></span><pre class="shiki github-dark-dimmed" style="background-color: #22272e"><code><span class="line"><span style="color: #adbac7">$USER1$/check_port.sh $HOSTADDRESS$ $ARG1$</span></span></code></pre></div>



<ul class="wp-block-list">
<li>Command Type: check command</li>
</ul>



<p>3. Click Save Command, then Apply Configuration.</p>



<h2 class="wp-block-heading">3. Configure a Port Monitoring Service</h2>



<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: Port Monitoring</li>



<li>Host: Select the target server.</li>



<li>Check Command: check_port!22 (Replace 22 with the desired port number).</li>
</ul>
</li>



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



<h2 class="wp-block-heading">AI Assistance Acknowledgment</h2>



<p>This plugin and article development were assisted by AI, demonstrating how artificial intelligence can streamline IT solutions and inspire innovation. We encourage others to explore AI-driven development to enhance their IT operations.</p>



<h2 class="wp-block-heading">Why This Plugin is Valuable for IT Security</h2>



<ul class="wp-block-list">
<li><strong>Proactive Security Monitoring</strong> – Detects unauthorized open ports before they become security vulnerabilities.</li>



<li><strong>Firewall and Compliance Verification</strong> – Ensures that firewall rules and security policies are effectively enforced.</li>



<li><strong>Lightweight and Efficient</strong> – Uses minimal system resources, making it ideal for continuous monitoring.</li>



<li><strong>Seamless Integration with Nagios XI</strong> – Works within the Nagios XI interface for centralized monitoring and alerting.</li>
</ul>



<p>This Nagios XI port monitoring plugin is efficient and lightweight, ensuring seamless integration with Nagios XI for enhanced security monitoring.</p>



<h2 class="wp-block-heading">Best Practices for Using the Nagios XI Port Monitoring Plugin</h2>



<ul class="wp-block-list">
<li>Regularly update firewall rules to prevent unauthorized access.</li>



<li>Schedule frequent scans using the Nagios XI port monitoring plugin to detect unexpected changes in network security</li>



<li>Use alerts and logs generated by Nagios XI to analyze potential attack patterns.</li>



<li>Combine with other security tools like intrusion detection systems (IDS) and SIEM solutions for enhanced threat monitoring.</li>
</ul>



<h2 class="wp-block-heading">Conclusion: Strengthening Security with the Nagios XI Port Monitoring Plugin</h2>



<p>The Nagios XI port monitoring plugin provides a critical security enhancement, allowing IT teams to monitor and secure open ports in real time. By integrating this plugin, organizations can proactively detect potential threats, comply with security policies, and protect their networks from cyberattacks.</p>



<p>By continuously monitoring unexpected open ports, IT teams can strengthen their security posture and mitigate risks before they escalate into major threats. Implementing this Nagios XI port monitoring plugin is a cost-effective and efficient approach to enhancing cybersecurity defenses.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using PowerShell to Write a Nagios Plugin on Windows in 4 Easy Steps</title>
		<link>https://library.nagios.com/documentation/nagios-powershell-plugin/</link>
		
		<dc:creator><![CDATA[Tucker Falen]]></dc:creator>
		<pubDate>Mon, 03 Feb 2025 17:45:52 +0000</pubDate>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://library.nagios.com/?p=41197</guid>

					<description><![CDATA[PowerShell is a powerful tool for automating system tasks, and when combined with Nagios, it allows you to create custom plugins tailored to your needs. In this article, I&#8217;ll show you how to write a Nagios plugin using PowerShell to detect a specific process running on a Windows system. By leveraging the Nagios Cross Platform [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>PowerShell is a powerful tool for automating system tasks, and when combined with Nagios, it allows you to create custom plugins tailored to your needs. In this article, I&#8217;ll show you how to write a Nagios plugin using PowerShell to detect a specific process running on a Windows system. By leveraging the Nagios Cross Platform Agent (NCPA), you can integrate your script with Nagios XI for seamless monitoring and alerting. This will help you track critical applications and ensure your servers remain healthy and operational! </p>



<p>Still need to install Nagios? <a href="https://library.nagios.com/techtips/getting-started-with-nagios-xi-installation-and-use/" target="_blank" data-type="link" data-id="https://library.nagios.com/techtips/getting-started-with-nagios-xi-installation-and-use/" rel="noreferrer noopener">Follow this guide!</a></p>



<h2 class="wp-block-heading">Getting Started with NCPA</h2>



<p>First, you&#8217;ll need to download and install the <strong>Nagios Cross Platform Agent</strong> (NCPA) on the Windows machine you want to monitor. NCPA acts as a bridge between your Windows system and Nagios XI, enabling communication and monitoring of various metrics, including custom scripts like the one we&#8217;ll be creating. You can download NCPA and access its documentation <a href="https://www.nagios.org/ncpa/" target="_blank" rel="noopener">here</a>.</p>



<h3 class="wp-block-heading">Using the NCPA Configuration Wizard</h3>



<p>After installing NCPA on your Windows machine, the next step is to configure it in Nagios XI using the <strong>NCPA Configuration Wizard.</strong> Simply enter the IP address of your Windows machine and the token you generated during the NCPA installation, and you&#8217;ll be all set to start monitoring.</p>



<h2 class="wp-block-heading">Creating a Script</h2>



<p>You can create any PowerShell script you&#8217;d like, but for this example I created a simple script for monitoring the running status and CPU processing time of a program. I used notepad++ to create the script on the windows machine that I am monitoring. You can download the script I used directly from github right <a href="https://github.com/NagiosEnterprises/plugins-extra/tree/check_process" data-type="link" data-id="https://github.com/NagiosEnterprises/plugins-extra/tree/check_process" target="_blank" rel="noopener">here</a>.<br><em><strong>Note: </strong>Notepad++ will need to be ran as administrator in order to save the script to the plugins folder.</em></p>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-104658.png"><img loading="lazy" decoding="async" width="749" height="424" src="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-104658.png" alt="Example powershell script" class="wp-image-41251" title="Using PowerShell to Write a Nagios Plugin on Windows in 4 Easy Steps 34" srcset="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-104658.png 749w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-104658-300x170.png 300w" sizes="(max-width: 749px) 100vw, 749px" /></a><figcaption class="wp-element-caption"> </figcaption></figure>



<h3 class="wp-block-heading">Saving Your Script</h3>



<p>Once you have created your script you will save it to <em>C:/Program Files/Nagios/NCPA/plugins</em> folder. Make sure to save the script as a .ps1 PowerShell script.<br><strong><em>Note: </em></strong><em>If you cannot find the &#8216;Nagios&#8217; folder it may be in Program Files (x86) instead</em></p>



<h3 class="wp-block-heading">Testing Your Script</h3>



<p>Now that your script has been saved, it is time to test it and make sure it&#8217;s free from syntax errors. Open PowerShell on your Windows machine and navigate to your plugins folder that you saved the script to using the <em>cd</em> command to change directory. Before running the script, you&#8217;ll need to enable script execution by entering the command: <code>Set-ExecutionPolicy RemoteSigned -Scope CurrentUser</code>. This will allow you to execute the script. </p>



<p>Now you can execute your script by typing <code>./myscriptname.ps1</code> and any arguments will be included after. For example, to run my script I did <code>./checkprocesses2.ps1 msedge -w 500</code>. This lets me check if msedge is running and will generate a warning if it has used over 500 seconds of CPU processing time.</p>



<h4 class="wp-block-heading">Testing Your Script on Your Nagios XI Server</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="571" height="142" src="https://library.nagios.com/wp-content/uploads/2025/01/NagiosXI_lib.png" alt="Nagios XI" class="wp-image-40503" title="Using PowerShell to Write a Nagios Plugin on Windows in 4 Easy Steps 35" srcset="https://library.nagios.com/wp-content/uploads/2025/01/NagiosXI_lib.png 571w, https://library.nagios.com/wp-content/uploads/2025/01/NagiosXI_lib-300x75.png 300w" sizes="(max-width: 571px) 100vw, 571px" /><figcaption class="wp-element-caption"> </figcaption></figure>



<p>Once you have confirmed that your script is running correctly, you will test it on the Nagios XI server to make sure that the NCPA API is communicating with Nagios XI correctly. Run the command below to test this, but replace the &lt;&gt; with your own values.</p>



<pre class="wp-block-code"><code class="">/usr/local/nagios/libexec/check_ncpa.py -H &lt;windows ip&gt; -t &lt;yourtoken&gt; -P 5693 -M 'plugins/&lt;scriptname.ps1&gt;' -a &lt;arguments&gt;</code></pre>



<p>For example this is what I entered:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="773" height="138" src="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140827-1.png" alt="Nagios XI output of running PowerShell script" class="wp-image-41335" title="Using PowerShell to Write a Nagios Plugin on Windows in 4 Easy Steps 36" srcset="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140827-1.png 773w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140827-1-300x54.png 300w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-140827-1-768x137.png 768w" sizes="(max-width: 773px) 100vw, 773px" /><figcaption class="wp-element-caption"> </figcaption></figure>



<p>If you got an output that was not an error you can confirm that NCPA is working as intended!</p>



<h2 class="wp-block-heading">Adding the Command to Nagios XI</h2>



<p>Once you&#8217;ve confirmed that everything is working correctly, you&#8217;re ready to add your command to Nagios XI. From the homepage, click the gear icon on the left to access the settings menu. Then, navigate to <strong>Core Config Manager</strong> &gt; <strong>Commands</strong> and click <strong>Add New</strong>. This will take you to the Command Management page. Enter a name for your command, and in the <strong>Command Line</strong> field, input the command below, making sure to replace <code><em>check_process2.ps1</em></code> with the name of your script.</p>



<pre class="wp-block-code"><code class="">$USER1$/check_ncpa.py -H $HOSTADDRESS$ -t $ARG1$ -P 5693 -M 'plugins/check_process2.ps1' -a $ARG3$</code></pre>



<p>Leave everything else as default, then save and apply the configuration. </p>



<h2 class="wp-block-heading">Adding the Service to Nagios XI</h2>



<p>Now that your command is created, you can set up the service. Return to the gear icon on the left and navigate to <strong>Core Config Manager</strong> &gt; <strong>Services</strong>, then click <strong>Add New</strong>. This will take you to the Service Management page. Enter a configuration name and description. </p>



<p>Next, click <strong>Manage Hosts</strong> and select the Windows host you added earlier during the NCPA Configuration Wizard setup. Then, under <strong>Check Command</strong>, select the command you created in the previous step. Be sure to replace each <code>$ARG$</code> placeholder with the appropriate information. To test the configuration, click <strong>Run Check Command</strong> at the bottom, and enter the Windows machine’s IP address.</p>



<p> Once you&#8217;ve confirmed that the test is successful, you&#8217;ll need to complete the required fields in the <strong>Check Settings</strong> and <strong>Alert Settings</strong> tabs. Finally, click <strong>Save</strong> and apply the configuration to finish setting up your service.</p>



<figure class="wp-block-image size-full"><a href="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-144030.png"><img loading="lazy" decoding="async" width="828" height="822" src="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-144030.png" alt="Service management screen on Nagios XI " class="wp-image-41342" title="Using PowerShell to Write a Nagios Plugin on Windows in 4 Easy Steps 37" srcset="https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-144030.png 828w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-144030-300x298.png 300w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-144030-150x150.png 150w, https://library.nagios.com/wp-content/uploads/2025/01/Screenshot-2025-01-21-144030-768x762.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><figcaption class="wp-element-caption"> </figcaption></figure>



<h2 class="wp-block-heading">Finishing Up</h2>



<p>Congratulations! You&#8217;ve successfully created a custom Nagios plugin using PowerShell to monitor a specific process on a Windows system. By leveraging the power of NCPA and Nagios XI, you&#8217;ve set up seamless monitoring, ensuring that critical applications are being tracked and your servers are running smoothly. With the steps outlined in this article, you can now easily manage and monitor your systems with greater precision.</p>



<p>As you continue to refine your monitoring setup, feel free to experiment with additional scripts and configurations to meet your specific needs. Remember, custom Nagios plugins allow you to tailor the monitoring experience to your environment, providing better insights and more effective alerts. Thanks for following along, and happy monitoring!</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
