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

<channel>
	<title>Nagios Archives - WardNet</title>
	<atom:link href="https://www.wardnet.co.uk/category/nagios-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wardnet.co.uk/category/nagios-2/</link>
	<description>Infrastructure, ERP and General Technology Blog</description>
	<lastBuildDate>Sat, 02 Jun 2012 12:42:00 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://i0.wp.com/www.wardnet.co.uk/wp-content/uploads/2026/01/wp-1767387074640.jpg?fit=32%2C32&#038;ssl=1</url>
	<title>Nagios Archives - WardNet</title>
	<link>https://www.wardnet.co.uk/category/nagios-2/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">63479081</site>	<item>
		<title>Nagios Notification Script</title>
		<link>https://www.wardnet.co.uk/nagios-notification-script/</link>
					<comments>https://www.wardnet.co.uk/nagios-notification-script/#comments</comments>
		
		<dc:creator><![CDATA[Jonathan Ward]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 16:16:44 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[nagios]]></category>
		<guid isPermaLink="false">http://wardnet.co.uk/?p=48</guid>

					<description><![CDATA[<p>Originally posted at johnnyward.co.uk (http://www.johnnyward.co.uk/nagios-notification-script/) I decided to write my own script for Nagios to send emails to external addresses</p>
<p><a href="https://www.wardnet.co.uk/nagios-notification-script/">Nagios Notification Script</a></p>
]]></description>
										<content:encoded><![CDATA[<p><em>Originally posted at johnnyward.co.uk (<a title="Orignal Post" href="http://www.johnnyward.co.uk/nagios-notification-script/">http://www.johnnyward.co.uk/nagios-notification-script/</a>)</em></p>
<p>I decided to write my own script for Nagios to send emails to external addresses when MS Exchange goes down in our organisation (which has been happening quite often lately!)</p>
<p>my exchangescript.sh file is called by a command created in the nagios command.cfg file as below:<br />
<span style="font-family: courier new,courier; color: #008000;">#Exchange notifications</span><br />
<span style="font-family: courier new,courier;"> define command{</span><br />
<span style="font-family: courier new,courier;"> command_name notify_ex_mail</span><br />
<span style="font-family: courier new,courier;"> command_line sh /etc/nagios3/exchangescript.sh &#8220;$NOTIFICATIONTYPE$&#8221; &#8220;$SERVICEDESC$&#8221; &#8220;$HOSTALIAS$&#8221; &#8220;$HOSTADDRESS$&#8221; &#8220;$SERVICESTATE$&#8221; &#8220;$LONGDATETIME$&#8221; &#8220;$SERVICEOUTPUT$&#8221; &#8220;$CONTACTEMAIL$&#8221;</span><br />
<span style="font-family: courier new,courier;"> }</span></p>
<p>The &#8220;$PARAMETER$&#8221; inputs are created by nagios and therefore would not make sense outside of a Nagios config file.</p>
<p>my exchangescript.sh file is here:<br />
<span style="font-family: courier new,courier; color: #008000;">#!/bin/bash</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## Send mail notification when nagios detects a problem &#8211; manual overide from Nagios defaults ##</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## Script By Jonathan Ward 26/09/2011 ##</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##Parameter List as defined in /etc/nagios3/commands.cfg</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## $1 = Notification Type e.g. &#8220;PROBLEM&#8221;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## $2 = Service Description e.g. &#8220;Explorer.exe&#8221; OR &#8220;SMTP Status&#8221;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## $3 = Host Alias e.g &#8220;MyExchangeServer&#8221;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## $4 = Host Address e.g. &#8220;192.168.1.1&#8221;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## $5 = Service State e.g. &#8220;CRITICAL&#8221;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## $6 = Long Date and Time e.g. &#8220;Mon Sept 26 16:07:21 BST 2011&#8221;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## $7 = Service Output</span><br />
<span style="font-family: courier new,courier; color: #008000;"> # #$8 = Contact Email</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##Set Message Subject &#8211; spaces won&#8217;t work?</span><br />
<span style="font-family: courier new,courier;"> msgsubject=&#8217;Exchange Issue&#8217;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##Set Email Addresses with spaces not commas etc.</span><br />
<span style="font-family: courier new,courier;"> msgto=&#8221;EMAIL ADDRESSES GO HERE&#8221;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##Set Message Body</span><br />
<span style="font-family: courier new,courier;"> msgbody=&#8221;Nagios is reporting $1 on $3 \n \nService $2 State is: $5 \n \nTime Reported: $6&#8243;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##Create subject in file /etc/nagios3/mailbody</span><br />
<span style="font-family: courier new,courier; color: #008000;"> #echo -e &#8220;$msgbody&#8221; &gt; /etc/nagios3/mailbody</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##Command to send email with subject and body</span><br />
<span style="font-family: courier new,courier; color: #008000;"> #mail -s &#8220;$msgsubject&#8221; &#8220;$msgto&#8221; &lt; /etc/nagios3/mailbody #Using external file as body</span><br />
<span style="font-family: courier new,courier;"> echo -e &#8220;&#8216;$msgbody'&#8221; | mail -s &#8220;$msgsubject&#8221; &#8220;$msgto&#8221; <span style="color: #008000;">#using internal echo as body &#8211; prints -e in emails???</span></span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##delete body file for next run</span><br />
<span style="font-family: courier new,courier; color: #008000;"> #rm -f /etc/nagios3/mailbody</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##Debugging lines go here&#8230;</span><br />
<span style="font-family: courier new,courier; color: #008000;"> # echo -e &#8220;$1 \n$2 \n$3 \n$4 \n$5 \n$6 \n$7 \n$8&#8221; &gt; /root/scriptdebug #Copies values of parameters on seperate lines in /root/scriptdebug file</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##TO TEST SCRIPT##</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## /etc/nagios3/exchangescript.sh &#8220;notifcation type&#8221; &#8220;service description&#8221; &#8220;host alias&#8221; &#8220;host address&#8221; &#8220;service state&#8221; &#8220;long date time&#8221; &#8220;service output&#8221; &#8220;contact email&#8221;</span></p>
<p><a href="https://www.wardnet.co.uk/nagios-notification-script/">Nagios Notification Script</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wardnet.co.uk/nagios-notification-script/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">48</post-id>	</item>
		<item>
		<title>Linux Script for monitoring Machine Room temperatures</title>
		<link>https://www.wardnet.co.uk/linux-script-for-monitoring-machine-room-temperatures/</link>
		
		<dc:creator><![CDATA[Jonathan Ward]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 15:20:58 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[jonathan ward]]></category>
		<category><![CDATA[Machine Room]]></category>
		<category><![CDATA[Room Temperatures]]></category>
		<guid isPermaLink="false">http://wardnet.co.uk/?p=45</guid>

					<description><![CDATA[<p>Following on from one of my first projects at BMS, where I installed a server monitoring solution called Nagios, I</p>
<p><a href="https://www.wardnet.co.uk/linux-script-for-monitoring-machine-room-temperatures/">Linux Script for monitoring Machine Room temperatures</a></p>
]]></description>
										<content:encoded><![CDATA[<p>Following on from one of my first projects at BMS, where I installed a server monitoring solution called Nagios, I have taken things one step further and started using the nagios scripts to provide in depth monitoring which I can target at specific people etc. I have used my knowledge gained from my older Nagios Notifcation Email script as reposted on this blog <a title="Nagios Notification Script" href="http://wardnet.co.uk/nagios-notification-script/">here</a>.</p>
<p>The plan was to use the Dell OpenManage plugins that I spent so long configuring within Nagios, to send temperature updates via email. The final script (after 4+ hours testing etc.) looks like this:</p>
<p><span style="font-family: courier new,courier; color: #008000;">#!/bin/bash</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ##ThermoMail.sh</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## Send mail notification of Machine Room Temperatures##</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ## Script By Jonathan Ward 01/02/2012##</span></p>
<p><span style="font-family: courier new,courier; color: #008000;">##./gettemp.sh (was spereate script)##</span><br />
<span style="font-family: courier new,courier; color: #008000;"> rm /root/temperatures</span><br />
<span style="font-family: courier new,courier; color: #000000;"> echo -e &#8220;Machine Room 1 status: &#8221; &gt; /root/temperatures</span><br />
<span style="font-family: courier new,courier; color: #000000;"> /usr/lib/nagios/plugins/check_openmanage -H <span style="color: #0000ff;">[ipaddress]</span> &#8211;only temp &gt;&gt; /root/temperatures</span><br />
<span style="font-family: courier new,courier; color: #000000;"> echo -e &#8220;\n\nMachine Room 2 status: &#8221; &gt;&gt; /root/temperatures</span><br />
<span style="font-family: courier new,courier; color: #000000;"> /usr/lib/nagios/plugins/check_openmanage -H <span style="color: #0000ff;">[ipaddress]</span> &#8211;only temp &gt;&gt; /root/temperatures</span><br />
<span style="font-family: courier new,courier; color: #008000;"> ####</span></p>
<p><span style="font-family: courier new,courier; color: #008000;">##Set Message Subject</span><br />
<span style="font-family: courier new,courier; color: #000000;"> msgsubject=&#8217;Machine Room Temperatures&#8217;</span></p>
<p><span style="font-family: courier new,courier; color: #008000;">##Set Email Addresses with spaces not commas etc.</span><br />
<span style="font-family: courier new,courier; color: #000000;"> msgto=&#8221;<span style="color: #0000ff;">mail@example.com</span>&#8220;</span></p>
<p><span style="font-family: courier new,courier; color: #008000;">##Command to send email with subject and body</span><br />
<span style="font-family: courier new,courier; color: #000000;"> mail -s &#8220;$msgsubject&#8221; &#8220;$msgto&#8221; &lt; /root/temperatures</span></p>
<p><span style="font-family: courier new,courier; color: #008000;">##DEBUGGING LINES</span><br />
<span style="font-family: courier new,courier; color: #008000;"> #echo -e &#8220;$msgbody&#8221; &gt; /root/mailtest</span></p>
<p>Now I know this looks a little crude, and could be tidied up with some symbolic links etc. but it is a simple solution and I have scheduled a cron job to run the script 4 times a day&#8230;</p>
<p>&nbsp;</p>
<p>The output in the email looks like this:</p>
<p><a href="https://i0.wp.com/wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1.png"><img data-recalc-dims="1" fetchpriority="high" decoding="async" data-attachment-id="49" data-permalink="https://www.wardnet.co.uk/linux-script-for-monitoring-machine-room-temperatures/thermomailscreen1/" data-orig-file="https://i0.wp.com/www.wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1.png?fit=717%2C575&amp;ssl=1" data-orig-size="717,575" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="Mail Output" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/www.wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1.png?fit=300%2C240&amp;ssl=1" data-large-file="https://i0.wp.com/www.wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1.png?fit=717%2C575&amp;ssl=1" class="alignnone size-medium wp-image-49" title="Mail Output" src="https://i0.wp.com/wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1-300x240.png?resize=300%2C240" alt="" width="300" height="240" srcset="https://i0.wp.com/www.wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1.png?resize=300%2C240&amp;ssl=1 300w, https://i0.wp.com/www.wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1.png?resize=150%2C120&amp;ssl=1 150w, https://i0.wp.com/www.wardnet.co.uk/wp-content/uploads/2012/02/ThermoMailscreen1.png?w=717&amp;ssl=1 717w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://www.wardnet.co.uk/linux-script-for-monitoring-machine-room-temperatures/">Linux Script for monitoring Machine Room temperatures</a></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">45</post-id>	</item>
	</channel>
</rss>
