<?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>[LINICKX].com &#187; nagios</title>
	<atom:link href="http://www.linickx.com/tag/nagios/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linickx.com</link>
	<description>Moments of Genius followed by Trash.</description>
	<lastBuildDate>Thu, 17 May 2012 10:23:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to Monitor wordpress with Nagios</title>
		<link>http://www.linickx.com/271/how-to-monitor-wordpress-with-nagios</link>
		<comments>http://www.linickx.com/271/how-to-monitor-wordpress-with-nagios#comments</comments>
		<pubDate>Mon, 19 Mar 2007 12:07:45 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/archives/271/how-to-monitor-wordpress-with-nagios/</guid>
		<description><![CDATA[WordPress like many web applications relies on apache (or something else) to serve the HTTP pages and mysql to store the data. Your wordpress website is important to you, so you need an external monitoring system to let you know &#8230; <a href="http://www.linickx.com/271/how-to-monitor-wordpress-with-nagios">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://wordpress.org">WordPress</a> like many web applications relies on apache (<em>or something else</em>) to serve the HTTP pages and mysql to store the data. Your wordpress website is important to you, so you need an external monitoring system to let you know what&#8217;s going on.</p>
<p><a href="http://www.nagios.org">Nagios</a> is a great, enterprise class, open-source monitoring application; and what you need do is configure it to exactly represent how wordpress works; if you can get that right you can immediately get notified if any piece of the puzzle fails.</p>
<p>I&#8217;m going to write up a simple example of how to monitor wordpress and it&#8217;s associated jigsaw pieces, so we&#8217;re going to setup one host with appropriate dependant services. Ultimately, you should configure nagios to suit exactly how your environment works, but hopefully this &#8220;how to&#8221; will get you started.</p>
<p><strong>Basic Config.</strong><br />
To configure nagios you need have services (<em>such as http</em>) associated with hosts; to get started, I&#8217;m going to have to assume you have followed <a href="http://www.maxsworld.org/index.php/how-tos/nagios">another &#8220;how to&#8221;</a> and have nagios up and running, and monitoring localhost, you can even use <a href="http://www.linickx.com/index.php?content=nagios">my own config generator</a> to get you started <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Basically you should have a generic check-host-alive host.cfg entry like so:</p>
<pre class="brush: plain; title: ; notranslate">
define host{
        use                     generic-host            ; Name of host template to use
        host_name               linickx.com
        alias                   My WebSite
        address                 www.linickx.com
        check_command           check-host-alive
        max_check_attempts      10
        check_period            24x7
        notification_interval   120
        notification_period     24x7
        notification_options    d,r
        contact_groups  admins
        }
</pre>
<p>The first (<em>and easiest</em>) part of wordpress to monitor is the web-server which serves the web pages on port 80, so a <strong>/etc/nagios/serivces.cfg</strong> entry like.</p>
<pre class="brush: plain; title: ; notranslate">
define service{
	use                             generic-service         ; Name of service template to use
	host_name                       www.linickx.com
	service_description             HTTP
	is_volatile                     0
	check_period                    24x7
	max_check_attempts              10
	normal_check_interval           1
	retry_check_interval            1
	contact_groups                  admins
	notification_options            w,u,c,r
	notification_interval           960
	notification_period             24x7
	check_command                   check_http
}
</pre>
<p><strong>Getting Technical.</strong><br />
Have you noticed the deliberate mistake ? I&#8217;m using resolvable names in my config files, this is deliberate as my website is on a shared server, and check_http with an IP address is very different to check_http www.linickx.com , but in order for www.linickx.com to work, DNS needs to be working. While we are here, it makes sense to monitor that as well. In <strong>/etc/nagios/checkcommands.cfg</strong> add an entry similar to&#8230;.</p>
<pre class="brush: plain; title: ; notranslate">
# 'check_dns' command definition
define command{
        command_name    check_dns_linickx-com
        command_line    $USER1$/check_dns -H www.linickx.com -a 69.73.189.228
        }
</pre>
<p>Where the -a ip address , is the ip of your &#8220;A Record&#8221;, if you don&#8217;t know what that is you can use <a href="http://www.dnsstuff.com/tools/lookup.ch?name=www.google.com&amp;type=A">dnsstuff.com</a> to find it for you. You can now create a service that uses that command&#8230;</p>
<pre class="brush: plain; title: ; notranslate">
define service{
        use                             generic-service         ; Name of service template to use
        host_name                       linickx.com
        service_description             DNS
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              10
        normal_check_interval           5
        retry_check_interval            1
        contact_groups                  admins
        notification_options            w,u,c,r
        notification_interval           960
        notification_period             24x7
        check_command                   check_dns_linickx-com
        }
</pre>
<p>We have HTTP and DNS monitored, all the wordpress data is stored in a mySQL <a href="http://www.singlehop.com/databasehosting/">database</a>, so now you need to monitor that, to do that you need to setup another checkcommand; add the following.</p>
<pre class="brush: plain; title: ; notranslate">
# mySQL command definition
define command{
	command_name    check_mysql
	command_line    $USER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$
}
</pre>
<p>This check command will log into the database and report OK if it is working, much better than check_tcp 3306 . Now you can add the following service entry</p>
<pre class="brush: plain; title: ; notranslate">
define service{
	use                             generic-service         ; Name of service template to use
	host_name                       www.linickx.com
	service_description             mySQL
	is_volatile                     0
	check_period                    24x7
	max_check_attempts              10
	normal_check_interval           5
	retry_check_interval            1
	contact_groups                  admins
	notification_options            w,u,c,r
	notification_interval           960
	notification_period             24x7
	check_command                   check_mysql!USERNAME!PASSWORD
}
</pre>
<p>For this to work the user will need to have permissions to log into the nagios machine, so if you followed <a href="http://codex.wordpress.org/Installing_WordPress#Using_the_MySQL_Client">the wordpress codex</a> and added &#8220;TO wordpressusername@localhost&#8221; in your mysql statement, you&#8217;ll need to add that to run</p>
<pre class="brush: plain; title: ; notranslate">GRANT ALL PRIVILEGES ON databasename.* TO wordpressusername@NAGIOS-SERVER;</pre>
<p>where NAGIOS-SERVER is a resolvable name or ip address. Note: Don&#8217;t forget about firewalls ! Make sure that TCP 3306 is open between your nagios box &amp; wordpress website.</p>
<p><strong>The bit that actually monitors wordpress.</strong><br />
You are now independently checking both HTTPD &amp; MYSQL, but what if wordpress can&#8217;t actually connect (lets say wp-config.php is screwed), both these checks will pass and nagios will stay green; what you need to do is monitor a page. If that page works , everything&#8217;s fine, if the page fails (<em>and you get the default database connection error page</em>) then nagios flags and alert. We&#8217;re going to add another checkcommand</p>
<pre class="brush: plain; title: ; notranslate">
# 'check linickx.com wordpress' command definition
define command{
        command_name    check_wp_linickx
        command_line    $USER1$/check_http -H $HOSTADDRESS$ -u /blog/about-me -s &quot;About Me&quot;
        }
</pre>
<p>You can alter this in anyway you want, but what it does is it looks for http://$HOSTADDRESS$/blog/about-me (<em>so http://www.linickx.com/blog/about-me</em>) and if that page returns &#8220;About Me&#8221; then everything is OK.</p>
<p><strong>Tidying up with dependencies.</strong><br />
We&#8217;ve already established that if either mySQL, http or DNS fails, wordpress will fail, so we want to ensure we don&#8217;t get hit with double alerts about the same problem, enter dependencies. HTTP is dependant on DNS, enter the following in <strong>/etc/nagios/dependencies.cfg</strong> (<em>make sure you have cfg_file=/etc/nagios/dependencies.cfg in /etc/nagios/nagios.cfg</em> )</p>
<pre class="brush: plain; title: ; notranslate">
define servicedependency{
        host_name                       linickx.com
        service_description             DNS
        dependent_host_name             linickx.com
        dependent_service_description   HTTP
        execution_failure_criteria      n
        notification_failure_criteria   u,c
        inherits_parent         1
        }
</pre>
<p>and WordPress is dependant on HTTP &amp; mySQL , so you need&#8230;</p>
<pre class="brush: plain; title: ; notranslate">
define servicedependency{
        host_name                       linickx.com
        service_description             HTTP
        dependent_host_name             linickx.com
        dependent_service_description   WordPress
        execution_failure_criteria      n
        notification_failure_criteria   u,c
        inherits_parent         1
        }

define servicedependency{
        host_name                       linickx.com
        service_description             mySQL
        dependent_host_name             linickx.com
        dependent_service_description   WordPress
        execution_failure_criteria      n
        notification_failure_criteria   u,c
        inherits_parent         1
        }
</pre>
<p>You can check your config with <strong>nagios -v /etc/nagios/nagios.cfg</strong> , assuming you have no errors wait for checks to go green and begin testing. Tests you can run can be  anything from unplugging the cable from your nagios box to simulate a complete failure, to stopping the mysql service on your website to make sure check_mysql works.</p>
<p><strong>Making it pretty for the hell of it.</strong><br />
Nagios has a web interface, one of the things we can do is customize it to represent our config, how about a pretty icon for our website ? or a custom wordpress action ? Here&#8217;s how to setup a pretty icon and action (<em>button to click on</em>) for our wordpress service.</p>
<p>To get started, you&#8217;ll probably need a copy of the <a href="http://svn.automattic.com/wordpress/trunk/wp-admin/images/wordpress-logo.png" rel="lightbox[271]">wordpress logo from the svn</a> , I then cut the &#8220;W&#8221; out to make a square icon, but you can do what you like <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Firstly something non essential: To display any icon in nagios as a &#8220;host icon&#8221; you&#8217;re going to need it in both png and gd2 image format, you&#8217;ll have to install a conversion tool. (<em>for redhat</em>)</p>
<pre class="brush: plain; title: ; notranslate">yum install gd-progs</pre>
<p>to run the conversion, use the following&#8230;</p>
<pre class="brush: plain; title: ; notranslate">pngtogd2 wordpress-logo.png wordpress-logo.gd2 0 1</pre>
<p>that&#8217;ll give you a chunk size of 0 and no compression <a href="http://www.nagios.org/faqs/viewfaq.php?faq_id=97">as recommended for nagios</a>.</p>
<p>But if you just want service icons, then you can get away with just a png. Save any custom images in <strong>/usr/share/nagios/images/logos/</strong> make sure they&#8217;re readable ( <em>e.g. chmod 644 file</em> ) and we&#8217;re good to go.</p>
<p>So the config file, 1st make sure you have <strong>cfg_file=/etc/nagios/serviceextinfo.cfg</strong> enabled in <strong>/etc/nagios/nagios.cfg</strong> . My sericeextinfo.cfg has the following&#8230;</p>
<pre class="brush: plain; title: ; notranslate">
define serviceextinfo{
	host_name               linickx.com
	service_description     WordPress
	notes                   My website  powered by wordpress !
	icon_image              wordpress-w.png
	icon_image_alt          WordPress
	action_url              http://$HOSTADDRESS$/blog/wp-admin/
}
</pre>
<p>What this does is it adds my wordpress-w icon to the nagios status pages, and give me a &#8220;red star&#8221; type icon which when I click on takes me to my wordpress admin page&#8230; cool !</p>
<p><strong>Some compulsory Screen-shots.</strong></p>
<table align="center">
<tr>
<td><a href='http://www.linickx.com/files/2008/05/nagios-linickxdotcom-host-detail.png' rel="lightbox[271]"><img src="http://www.linickx.com/files/2008/05/nagios-linickxdotcom-host-detail-150x150.png" alt="Nagios Host Detail Example" title="nagios linickx.com host detail" width="150" height="150" class="alignnone size-thumbnail wp-image-415" /></a></td>
<td><a href='http://www.linickx.com/files/2008/05/nagios-linickxdotcom-service-wordpress-detail.png' rel="lightbox[271]"><img src="http://www.linickx.com/files/2008/05/nagios-linickxdotcom-service-wordpress-detail-150x150.png" alt="Nagios Service detail for WordPress" title="nagios linickx.com service wordpress detail" width="150" height="150" class="alignnone size-thumbnail wp-image-416" /></a></td>
</tr>
</table>
<p>That should just about wrap it up, one fully monitored wordpress installation; as you can see this can be adapted to monitor any php / mysql app <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Please <a href="http://www.linickx.com/index.php?content=contact">let me know</a> if you have any further suggestions.</p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/271/how-to-monitor-wordpress-with-nagios/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cacti &amp; Nagios &#8211; Missing Favicons</title>
		<link>http://www.linickx.com/248/cacti-nagios-missing-favicons</link>
		<comments>http://www.linickx.com/248/cacti-nagios-missing-favicons#comments</comments>
		<pubDate>Fri, 26 Jan 2007 10:37:20 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Enterprise Linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[favicon.ico]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/archives/248/cacti-nagios-missing-favicons/</guid>
		<description><![CDATA[Recently I decided to re-organise my bookmarks toolbar, and added links to my nagios and cacti installations. I noticed that the favicons where missing. For cacti, there&#8217;s a how to, but I found it a little over kill &#8211; I &#8230; <a href="http://www.linickx.com/248/cacti-nagios-missing-favicons">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I decided to re-organise my bookmarks toolbar, and added links to my <a href="http://www.nagios.org">nagios</a> and <a href="http://www.cacti.net">cacti</a> installations. I noticed that the favicons where missing.</p>
<p>For cacti,<a href="http://forums.cacti.net/about18364.html"> there&#8217;s a how to</a>, but I found it a little over kill &#8211; I didn&#8217;t need step 2 , as my catci install is an <a href="http://dag.wieers.com/packages/cacti/">rpm from dag</a>, and I didn&#8217;t bother with step 4, as it worked without it, but hey <abbr title ="Your Mileage May Vary">ymmv</abbr>!</p>
<p>Nagios was simpler, depending on how you installed nagios, will effect file permission , owners, directories etc. Again, I&#8217;ve got <a href="http://dag.wieers.com/packages/nagios/">another dag rpm</a>, so for me I logged in as root, </p>
<pre>
cd /usr/share/nagios/
wget http://www.nagios.org/images/favicon.ico
</pre>
<p>then edit index.html. just before &lt;/head&gt; , insert</p>
<pre>
&lt;link rel="shortcut icon" href="/nagios/favicon.ico" type="image/x-icon" /&gt;
</pre>
<p>refresh your browser (delete the cache if necessary), and job done ! <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/248/cacti-nagios-missing-favicons/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios Checker &#8211; Firefox Extension</title>
		<link>http://www.linickx.com/241/nagios-checker-firefox-extension</link>
		<comments>http://www.linickx.com/241/nagios-checker-firefox-extension#comments</comments>
		<pubDate>Mon, 11 Dec 2006 11:11:39 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/archives/241/nagios-checker-firefox-extension/</guid>
		<description><![CDATA[Been looking for something like this for a while&#8230;.. Nagios Checker &#124; Firefox Add-ons &#124; Mozilla Corporation The statusbar indicator of the events from the network monitoring system Nagios. Information is parsed from Nagios web interface. In the extension settings &#8230; <a href="http://www.linickx.com/241/nagios-checker-firefox-extension">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Been looking for something like this for a while&#8230;..</p>
<blockquote><p>
<a href="https://addons.mozilla.org/firefox/3607/">Nagios Checker | Firefox Add-ons | Mozilla Corporation</a><br />
The statusbar indicator of the events from the network monitoring system Nagios. Information is parsed from Nagios web interface. In the extension settings dialog simply fill the start page URL of your Nagios web interface, eg. http://www.yourfirm.com/nagios/ and let the button to locate status script url.
</p></blockquote>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/241/nagios-checker-firefox-extension/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios Ping Tool &#8211; Another Hack</title>
		<link>http://www.linickx.com/81/nagios-ping-tool-another-hack</link>
		<comments>http://www.linickx.com/81/nagios-ping-tool-another-hack#comments</comments>
		<pubDate>Wed, 09 Nov 2005 20:53:16 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[Nagios Ping and Traceroute Tool]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/?p=81</guid>
		<description><![CDATA[I&#8217;ve received a patch from ed.davison, if you have commented out hosts in your config, you&#8217;ll get odd \&#8221;address &#8211; hostname\&#8221; results in the drop down list. Ed&#8217;s patch fixes that; thankx At the moment you&#8217;d have to apply the &#8230; <a href="http://www.linickx.com/81/nagios-ping-tool-another-hack">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve received a patch from <a href="http://www.utexas.edu">ed.davison</a>, if you have commented out hosts in your config, you&#8217;ll get odd \&#8221;address &#8211; hostname\&#8221; results in the drop down list. Ed&#8217;s patch fixes that; thankx <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
<p>At the moment you&#8217;d have to apply the patch your self from the below; but I have a <em>official</em> revision in the pipeline.</p>
<div class="code">
<pre>
-- readhosts.php       2005/11/09 18:07:43     1.1
+++ readhosts.php       2005/11/09 18:08:12
@@ -23,16 +23,20 @@

       $current = trim($line);

-       if (preg_match (\"/addres/\", \"$current\")) {
-               $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
-               $ipaddress[$counter] = $keywords[1];
-               $counter++;
-       }
-
-       if (preg_match (\"/host_name/\", \"$current\")) {
-               $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
-               $node_name[$counter2] = $keywords[1];
-               $counter2++;
+       if (!preg_match (\"/^#/\", \"$current\")) {
+
+               if (preg_match (\"/addres/\", \"$current\")) {
+                       $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
+                       $ipaddress[$counter] = $keywords[1];
+                       $counter++;
+               }
+
+               if (preg_match (\"/host_name/\", \"$current\")) {
+                       $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
+                       $node_name[$counter2] = $keywords[1];
+                       $counter2++;
+               }
+
       }
</pre>
</div>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/81/nagios-ping-tool-another-hack/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nagios Ping Tool &amp; Nagios QL</title>
		<link>http://www.linickx.com/79/nagios-ping-tool-nagios-ql</link>
		<comments>http://www.linickx.com/79/nagios-ping-tool-nagios-ql#comments</comments>
		<pubDate>Tue, 08 Nov 2005 09:30:06 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[Nagios Ping and Traceroute Tool]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/?p=79</guid>
		<description><![CDATA[Recently I had a request from rex to modify my nagios ping tool (Official Nagios Exchange page); he wanted to use the tool with his nagios configuration. Rex appeared to be using Nagios QL (Which I believe to be a &#8230; <a href="http://www.linickx.com/79/nagios-ping-tool-nagios-ql">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I had a request from <a href="http://www.2020media.com">rex</a> to modify my <a href="http://www.linickx.com/index.php?content=php#nagios-ping-tool.tgz">nagios ping tool</a> (<a href="http://www.nagiosexchange.org/Utilities.16.0.html?&#038;tx_netnagext_pi1[p_view]=349">Official Nagios Exchange page</a>); he wanted to use the tool with his nagios configuration.</p>
<p>Rex appeared to be using Nagios QL (<em>Which I believe to be a nagios management tool</em>) , now <em>QL</em> handles nagios config slightly differently . The <em>Ping Tool</em> reads the nagios hosts.cfg file, and turns it into a couple of arrays to use for ping &amp; display, with <em>QL</em> they generate multiple hosts.cfg files, one for each hosts.</p>
<p>Perhaps a short way of saying it, Rex needed to read in multiple hosts.cfg files from a directory, and below is the hack to do it <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>Simply copy &amp; past the below code into a file called readhosts.php, replace your readhosts.php with the new one , and set the variable $hostfilepath in config.php, something like $hostfilepath = &#8220;/hosts&#8221;; (<em>assuming /hosts is where you keep the files <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </em> )  should do the job.</p>
<div class="code">
<pre>
&lt;?php

#This page reads in the hosts described in the config file to an array ready for use later

if ($hostfilepath == "" ) {
        ?>
	&lt;h1> Please update your config file&lt;/h1>
	&lt;h2> You need to add the line $hostfilepath = "/path/to/host/config/files"; to config.php &lt;/h2>
	&lt;?php
        exit;
}

	#We need a counter to increment for the file array.
	$counter = 0;
	# A second counter is used for the array of actual hosts
	$counter2 = 0;

if (is_dir($hostfilepath)) {

	if ($dh = opendir($hostfilepath)) {

		while (($file = readdir($dh)) !== false) {

			$firstchar = substr($file,0,1);
			if ( $firstchar !== "." ) {
				$full_file_path = "$hostfilepath/$file";

				$lines = file($full_file_path);

				make_host_array();

				#echo "$full_file_path&lt;br>";
			}
		}
       closedir($dh);
   	}
}

function make_host_array() {
	global $lines,$ipaddress,$node_name,$counter,$counter2;

	foreach ($lines as $line_num => $line) {

		$current = trim($line);

		if (preg_match ("/addres/", "$current")) {
	    		$keywords = preg_split ("/[\s,]+/", "$current");
			$ipaddress[$counter] = $keywords[1];
			$counter++;
		} 

		if (preg_match ("/host_name/", "$current")) {
	    		$keywords = preg_split ("/[\s,]+/", "$current");
			$node_name[$counter2] = $keywords[1];
			$counter2++;
		}

	}

#print_r($ipaddress);
#print_r($node_name);

}

?>
</pre>
</div>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/79/nagios-ping-tool-nagios-ql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Nagios Ping &amp; Traceroute Tool</title>
		<link>http://www.linickx.com/66/php-nagios-ping-traceroute-tool</link>
		<comments>http://www.linickx.com/66/php-nagios-ping-traceroute-tool#comments</comments>
		<pubDate>Wed, 28 Sep 2005 15:48:17 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[Nagios Ping and Traceroute Tool]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/?p=66</guid>
		<description><![CDATA[Another day, another mini project. My place of work pretty much demanded the need for our monitoring guys (i.e. people that stare at the nagios screen, waiting for red things) to have the ability to run traceroutes from nagios to &#8230; <a href="http://www.linickx.com/66/php-nagios-ping-traceroute-tool">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Another day, another mini project.</p>
<p>My place of work pretty much demanded the need for our monitoring guys (i.e. people that stare at the nagios screen, waiting for red things) to have the ability to run traceroutes from nagios to the effected node &#8211; The twist in the story was that they wanted to do it from a browser !</p>
<p>So, I thought, that&#8217;d be an easy php script then <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_cool.gif' alt=':cool:' class='wp-smiley' />  , well to be honest it took a little longer than expected, mainly because I don&#8217;t really understand regular expressions (<i>yet</i>).</p>
<p><a href="http://www.linickx.com/index.php?content=php#nagios-ping-tool.tgz">Nagios-ping-tool</a> Is a package of small scripts :</p>
<ul>
<li>config.php &#8211; some simple config variables, important for telling the script where to find your nagios hosts.cfg</li>
<li>index.php &#8211; the script that creates the buttons</li>
<li>readhosts.php &#8211; the script that reads /etc/nagios/hosts.cfg to find names &#038; ip addresses</li>
<li>header.php &#038; footer.php &#8211; my actual implementation went into another <i>skinned</i> site, so I put these in to format the pages properly</li>
</ul>
<p><a href="http://www.linickx.com/files/php/nagios-ping-tool.tgz">nagios-ping-tool.tgz can be downloaded from this site</a> or the <a href="http://www.nagiosexchange.org/Utilities.16.0.html?&#038;tx_netnagext_pi1[p_view]=349">Nagios Exchange Project Page</a></p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/66/php-nagios-ping-traceroute-tool/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Nagios Simple CFG Gen.</title>
		<link>http://www.linickx.com/59/php-nagios-simple-cfg-gen</link>
		<comments>http://www.linickx.com/59/php-nagios-simple-cfg-gen#comments</comments>
		<pubDate>Tue, 16 Aug 2005 16:51:13 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/?p=59</guid>
		<description><![CDATA[.. or nagios is great, I use it a lot. In my continuing quest to cure command line phobia I&#8217;ve written a small (&#038; Basic) php script that can generate some sample configs. Simply type in the IP of what &#8230; <a href="http://www.linickx.com/59/php-nagios-simple-cfg-gen">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.nagios.org"><img src="http://www.nagios.org/images/smalllogo7.gif" alt="Nagios" /></a><br />
.. or <a href="http://www.nagios.org">nagios</a> <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  is great, I use it a lot.</p>
<p>In my continuing quest to cure command line phobia I&#8217;ve written a small (&#038; Basic) php script that can generate some sample configs. Simply type in the IP of what you want to monitor , tick a couple of boxes, and copy &#038; paste what you get into the end of your config files &#8211; nice <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_cool.gif' alt=':cool:' class='wp-smiley' /> </p>
<p>There&#8217;s a Demo Site here : <a href="http://www.linickx.com/index.php?content=nagios">http://www.linickx.com/index.php?content=nagios</a><br />
and the Source here: <a href="http://www.linickx.com/files/php/nagios-simple-gen_php.txt">http://www.linickx.com/files/php/nagios-simple-gen_php.txt</a></p>
<p><strong>UPDATE:</strong><br />
Also available at <a href="http://www.nagiosexchange.org">nagiosexchange.org</a>: <a href="http://www.nagiosexchange.org/Configuration.20.0.html?&#038;tx_netnagext_pi1[p_view]=327">http://www.nagiosexchange.org/Configuration.20.0.html?&#038;tx_netnagext_pi1[p_view]=327</a></p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/59/php-nagios-simple-cfg-gen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

