a perl script use to open a ticket in RT
when an alarm is acknowledged in Nagios.
There is yet another script that I found at Nagios
Exchange 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.
1. It wokrs where Nagios and RT both are installed on the same machine
2. There are no spaces in any of the parameters that we pass on to create a ticket in Nagios, including the acknowledgement comments
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.
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).
2. You then need to enable the external command handling on your Nagios installation. Follow the instructions on Nagios Documention. Or else you can edit my sript to work with external commands disabled. Simply change teh line $external = 0; to $external = 1;
3. If you are changing $debug to 1, make sure you have the correct path & filename to the $logfile with necessary access rights.
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
# 'notify-rt' command definition
command_line /usr/local/nagios/libexec/eventhandlers/create_ticket.pl -S \ "$HOSTNAME$^$SERVICEACKCOMMENT$^$SERVICEACKAUTHOR$^$SERVICEOUTPUT$^$SERVICESTATEID$^$NOTIFICATIONTYPE$^$SERVICEDESC$^$CONTACTEMAIL$"
# 'host-notify-rt' command definition
command_line /usr/local/nagios/libexec/eventhandlers/create_ticket.pl -S \ "$HOSTNAME$^$HOSTACKCOMMENT$^$HOSTACKAUTHOR$^$HOSTOUTPUT$^$HOSTSTATEID$^$NOTIFICATIONTYPE$^$SERVICEDESC$^$CONTACTEMAIL$"
Note the double quotes ( " ) 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.
5. You also need to define a contact for RT. This is what I did.
I defined RT as a contact in my contacts.cfg file in /path-to-nagios/nagios/etc/. It looks like this
alias Ticketing System
email NetworkTroubles@rt.wightman.ca ;E-mail to RT Queue
alias Open a ticket in Ticketing System with notification to admin
members admin, RT
Note that the "email" 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've then defined a service as follows:
use generic-service ; Name of service template to use
service_description Interface Status ; Note the space in this service description
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.
NOTE: 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 'email@example.com' You can change this by manually editing the script and changing the variable '$from' at the top of the script.
create_ticket.pl version 1.0.0.
(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.)
Priyantha P Kumara <priyantha_AT_wightman_DOT_ca> Hanover, ON Canada
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.
Also thank you in advance for everyone who is going to test this and send any feedback.
Copyright (c) 2007 Priyantha P Kumara <priyantha_AT_wightman_DOT_ca> All rights reserved.
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.
Last modified Aug 11, 2009 by Priyantha P Kumara