<html><head><title>create_ticket.pl</title>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type"></head><body>
<h1 align="left">create_ticket.pl&nbsp;</h1>
<hr>
<ul>
  <li> 
    <pre><font face="Arial, Helvetica, sans-serif" size="3"><a href="create_ticket.html#NAME">Name</a></font></pre>
  </li>
  <li> 
    <pre><font face="Arial, Helvetica, sans-serif" size="3"><a href="create_ticket.html#DESCRIPTION">Description</a></font></pre>
  </li>
  <li> 
    <pre><font face="Arial, Helvetica, sans-serif" size="3"><a href="create_ticket.html#Announcement">Announcement</a></font></pre>
  </li>
  <li> 
    <pre><font face="Arial, Helvetica, sans-serif" size="3"><a href="create_ticket.html#Availability">Availability</a></font></pre>
  </li>
  <li> 
    <pre><font face="Arial, Helvetica, sans-serif" size="3"><a href="create_ticket.html#Author">Author</a></font></pre>
  </li>
  <li> 
    <pre><font face="Arial, Helvetica, sans-serif" size="3"><a href="create_ticket.html#Thanks">Thanks</a></font></pre>
  </li>
  <li> 
    <pre><font face="Arial, Helvetica, sans-serif" size="3"><a href="create_ticket.html#Copyright_and_Disclaimer">Copyright and Disclaimer</a> </font></pre>
 </li></ul>
<hr>

<p>
</p>
<h1><a name="NAME">Name</a></h1>
<font face="Arial, Helvetica, sans-serif" size="3">create_ticket.pl - Release 
notes of <code>create_ticket.pl</code></font> 
<p>
</p><p>
</p><hr>

<h1><a name="DESCRIPTION">Description</a></h1>
<p><code><font face="Arial, Helvetica, sans-serif" size="3">create_ticket.pl is 
  a perl script use to open a ticket in <a href="http://bestpractical.com/rt/">RT</a> 
  when an alarm is acknowledged in <a href="http://www.nagios.org/">Nagios</a></font></code><font face="Arial, Helvetica, sans-serif" size="3">. 
  There is yet another script that I found at <a href="http://www.nagiosexchange.org/">Nagios 
  Exchange</a> site that claims the same. However, it has no documenation and 
  also it has the following issues that at least prevented me using that script.</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="3">1. It wokrs where Nagios 
  and RT both are installed on the same machine</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="3">2. There are no spaces in 
  any of the parameters that we pass on to create a ticket in Nagios, including 
  the acknowledgement comments</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="3">I wrote this Perl script 
  to over come the above issues. In this script however, I'm not getting the RT 
  ticket ID which is a kind of drawback but I can't seem to find a simple way-around 
  to that problem provided that I have the Nagios and RT are running on two separarte 
  machine.</font></p>
<hr>
<h1><a name="INSTALLATION">Installation</a></h1>
<p><font face="Arial, Helvetica, sans-serif" size="3">1. Extract the zip file 
  and copy the create_ticket.pl to /path-to-Nagios/nagios/libexec/eventhandlers/ 
  (You can put the script anywhere you like but I'm using this path in my system 
  and I'll use the same here).</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="3">2. You then need to enable 
  the external command handling on your Nagios installation. Follow the instructions 
  on Nagios <a href="http://nagios.sourceforge.net/docs/2_0/extcommands.html">Documention</a>. 
  Or else you can edit my sript to work with external commands disabled. Simply 
  change teh line <font size="2">$external = 0;</font> to <font size="2">$external 
  = 1</font>;</font></p>
<p>3. If you are changing $debug to 1, make sure you have the correct path &amp; 
  filename to the $logfile with necessary access rights.</p>
<p>4. Now you need to defind the command definition. Below is what it looks like 
  in my system. I have this in /path-to-nagios/nagios/etc/misccommands.cfg</p>
<blockquote> 
  <p><font face="Arial, Helvetica, sans-serif" size="2"># 'notify-rt' command 
    definition<br>
    define command{<br>
    command_name notify-rt<br>
    command_line /usr/local/nagios/libexec/eventhandlers/create_ticket.pl -S \ 
    &quot;$HOSTNAME$^$SERVICEACKCOMMENT$^$SERVICEACKAUTHOR$^$SERVICEOUTPUT$^$SERVICESTATEID$^$NOTIFICATIONTYPE$^$SERVICEDESC$^$CONTACTEMAIL$&quot;</font></p>
  <p><font face="Arial, Helvetica, sans-serif" size="2">}</font></p>
  <p><font face="Arial, Helvetica, sans-serif" size="2"># 'host-notify-rt' command 
    definition<br>
    define command{<br>
    command_name host-notify-rt<br>
    command_line /usr/local/nagios/libexec/eventhandlers/create_ticket.pl -S \ 
    &quot;$HOSTNAME$^$HOSTACKCOMMENT$^$HOSTACKAUTHOR$^$HOSTOUTPUT$^$HOSTSTATEID$^$NOTIFICATIONTYPE$^$SERVICEDESC$^$CONTACTEMAIL$&quot;<br>
    }</font></p>
  <p><font face="Arial, Helvetica, sans-serif" size="2"><i>Note the double quotes 
    ( &quot; ) that I have used when passing the parameters with '-S' in the command 
    definitions. That will make sure we pass all the parameters whether there 
    are spaces in the parameters that we are passing or not. This may be not the 
    best way to do that however, it just worked for me.</i></font></p>
</blockquote>
<p>5. You also need to define a contact for RT. This is what I did.</p>
<blockquote> 
  <p>I defined RT as a contact in my contacts.cfg file in /path-to-nagios/nagios/etc/. 
    It looks like this</p>
  <blockquote> 
    <p><font face="Arial, Helvetica, sans-serif" size="2">define contact{<br>
      contact_name RT<br>
      alias Ticketing System<br>
      service_notification_period 24x7<br>
      host_notification_period 24x7<br>
      service_notification_options w,u,c,r<br>
      host_notification_options d,u,r<br>
      service_notification_commands notify-rt<br>
      host_notification_commands host-notify-rt<br>
      email NetworkTroubles@rt.wightman.ca ;<i>E-mail to RT Queue</i><br>
      }</font><br>
    </p>
    <p><font face="Arial, Helvetica, sans-serif" size="2">define contactgroup{<br>
      contactgroup_name admins<br>
      alias Open a ticket in Ticketing System with notification to admin<br>
      members admin, RT<br>
      }</font><br>
    </p>
  </blockquote>
  <p> <font face="Arial, Helvetica, sans-serif" size="2"><i>Note that the &quot;email&quot; 
    I have. I run RT on a server called rt and the RT queue name is 'NetworkTroubles'. 
    (Queue name is not case sensitive, I guess ?)</i></font></p>
  <p>I've then defined a service as follows:</p>
  <blockquote>
    <p><font face="Arial, Helvetica, sans-serif" size="2">define service{<br>
      use generic-service ; <i>Name of service template to use</i><br>
      host_name OfficeSwitch<br>
      service_description Interface Status ; <i>Note the space in this service 
      description</i><br>
      is_volatile 0<br>
      check_period 24x7<br>
      max_check_attempts 4<br>
      normal_check_interval 5<br>
      retry_check_interval 1<br>
      contact_groups admins<br>
      notification_options w,u,c,r<br>
      notification_interval 30<br>
      notification_period 24x7<br>
      check_command int_status!showme!FastEthernet0/1<br>
      }</font><br>
    </p>
  </blockquote>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="3">6. You then need to configure 
  the RT to complete this process. In my case what I have done is, I created a 
  queue called 'NetworkTroubles' in RT with user 'nagios' has 'CreateTicket rights.</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="3"><b>NOTE:</b> By default 
  the script create_ticket.pl sends e-mails to RT to open a ticket. The from address 
  of the e-mail is default to 'nagios@wightman.ca' You can change this by manually 
  editing the script and changing the variable '$from' at the top of the script.</font></p>
<p><br>
</p>
<p>
</p><hr>

<h1><a name="Announcement">Announcement </a></h1>
<font face="Arial, Helvetica, sans-serif" size="3">I'm pleased to announce the 
release of <code>create_ticket.pl version 1.0.0</code>. </font>
<p>&nbsp;</p>
<hr>

<h1><a name="Availability">Availability </a></h1>
create_ticket.pl is licensed under the GNU General Public License. 
<p>(Pl. also note that I have tested this only on Nagios 2.9 and RT 3.4.5 running 
  on separete servers. You are welcome to test this on other versions.)</p>
<p>
</p><p>
</p><hr>

<p>

</p><h1><a name="Author">Author</a></h1>
<pre><font face="Arial, Helvetica, sans-serif" size="3">Priyantha P Kumara &lt;priyantha_AT_wightman_DOT_ca&gt;
Hanover, ON
Canada</font>
</pre>
<hr>

<h1><a name="Thanks">Thanks </a></h1>
<p>I'd like to thank Scott for all his support whenever I run into troubles on 
  my test servers. I also want to give a BIG THANK YOU to my wife and two kids 
  for giving me time to work on this while I'm at home.</p>
<p>Also thank you in advance for everyone who is going to test this and send any 
  feedback.</p>
<p>
</p><p>
</p><hr>

<h1><a name="Copyright_and_Disclaimer">Copyright and Disclaimer </a></h1>Note that 
this document is provided `as is'. The information in it is not warranted to be 
correct. Use it at your own risk. 
<p></p>
<pre><font face="Arial, Helvetica, sans-serif" size="3">   Copyright (c) 2007 Priyantha P Kumara &lt;priyantha_AT_wightman_DOT_ca&gt;
   All rights reserved.</font>
</pre>
<p>This document may be reproduced and distributed in its entirety (including 
this authorship, copyright, and permission notice), provided that no charge is 
made for the document itself. 
</p><p>
</p><hr>
<p><small>Last modified June 1, 2007 by Priyantha P Kumara</small></p>
<dl></dl>
</body></html>