title: Monitoring URLs with Nagios
body: <p>I'm trying to monitor actual URLs, and not only hosts, with Nagios, as I operate a shared server with several websites, and I don't think its enough just to monitor the basic HTTP service (I'm including at the very bottom of this question a small explanation of what I'm envisioning).</p>
  
  <p>(Side note: please note that I have Nagios installed and running inside a chroot on a CentOS system. I built nagios from source, and have used yum to install into this root all dependencies needed, etc...)</p>
  
  <hr>
  
  <p>I first found <a href="http://exchange.nagios.org/directory/Plugins/Websites,-Forms-and-Transactions/check_url/details" rel="nofollow noreferrer">check_url</a>, but after installing it into /usr/lib/nagios/libexec, I kept getting a "return code of 255 is out of bounds" error. That's when I decided to start writing this question (but wait! There's another plugin I decided to try first!)</p>
  
  <p>After reviewing <a href="https://stackoverflow.com/questions/1461826/nagios-return-code-of-255-is-out-of-bounds">This Question</a> that had almost practically the same problem I'm having with check_url, I decided to open up a new question on the subject because
  a) I'm not using NRPE with this check
  b) I tried the suggestions made on the earlier question to which I linked, but none of them worked. For example...</p>
  
  <pre><code>./check_url some-domain.com | echo $0
  </code></pre>
  
  <p>returns "0" (which indicates the check was successful)</p>
  
  <p>I then followed the debugging instructions on <a href="http://support.nagios.com/knowledgebase/faqs/index.php?option=com_content&amp;view=article&amp;id=52&amp;catid=35&amp;faq_id=162" rel="nofollow noreferrer">Nagios Suppor</a>t to create a temp file called debug_check_url, and put the following in it (to then be called by my command definition):</p>
  
  <pre><code>#!/bin/sh
  echo `date` &gt;&gt; /tmp/debug_check_url_plugin
  echo $*  /tmp/debug_check_url_plugin
  /usr/local/nagios/libexec/check_url $*
  </code></pre>
  
  <p>Assuming I'm not in "debugging mode", my command definition for running check_url is as follows (inside command.cfg):</p>
  
  <pre><code>'check_url' command definition
  define command{
         command_name    check_url
         command_line    $USER1$/check_url $url$
  }
  </code></pre>
  
  <p>(Incidentally, you can also view what I was using in my service config file at the very bottom of this question)</p>
  
  <hr>
  
  <p>Before publishing this question, however, I decided to give 1 more shot at figuring out a solution. I found the <a href="http://exchange.nagios.org/directory/Plugins/Websites,-Forms-and-Transactions/check_url_status/details" rel="nofollow noreferrer">check_url_status</a> plugin, and decided to give that one a shot. To do that, here's what I did:</p>
  
  <ol>
  <li>mkdir /usr/lib/nagios/libexec/check_url_status/</li>
  <li>downloaded both check_url_status and utils.pm</li>
  <li>Per the user comment / review on the check_url_status plugin page, I changed "lib" to the proper directory of /usr/lib/nagios/libexec/.</li>
  <li><p>Run the following:</p>
  
  <p>./check_user_status -U some-domain.com.
  When I run the above command, I kept getting the following error:</p></li>
  </ol>
  
  <blockquote>
    <p>bash-4.1# ./check_url_status -U mydomain.com
    Can't locate utils.pm in @INC (@INC contains: /usr/lib/nagios/libexec/ /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5) at ./check_url_status line 34.
    BEGIN failed--compilation aborted at ./check_url_status line 34.</p>
  </blockquote>
  
  <hr>
  
  <p>So at this point, I give up, and have a couple of questions:</p>
  
  <ol>
  <li><strong>Which of these two plugins would you recommend? check_url or check_url_status?</strong>
  (After reading the description of check_url_status, I feel that this one might be the better choice. Your thoughts?)</li>
  <li><strong>Now, how would I fix my problem with whichever plugin you recommended?</strong></li>
  </ol>
  
  <hr>
  
  <p>At the beginning of this question, I mentioned I would include a small explanation of what I'm envisioning. I have a file called services.cfg which is where I have all of my service definitions located (imagine that!). </p>
  
  <p>The following is a snippet of my service definition file, which I wrote to use check_url (because at that time, I thought everything worked). I'll build a service for each URL I want to monitor:</p>
  
  <pre><code>###
  # Monitoring Individual URLs...
  #
  ###
  define service{
          host_name                       {my-shared-web-server}
          service_description             URL: somedomain.com
          check_command                   check_url!somedomain.com
          max_check_attempts              5
          check_interval                  3
          retry_interval                  1
          check_period                    24x7
          notification_interval           30
          notification_period             workhours
  }
  </code></pre>