[Launching a perl script from nagios ]

Marc Powell marc at ena.com
Thu Mar 4 14:40:42 CET 2010


On Mar 4, 2010, at 6:07 AM, badreddine meherzi wrote:

> Hi,
>  
> I'm trying to make nagios execute a perl script as host problem notification instead of sending a mail and this doesn't work. 
> so I've done the following configurations:
> The Perl script is for RT ticket creation.
> The Perl script "create_ticket.pl" works fine and a ticket is created when executed with the perl command in shell by the nagios user.

Can you post an example run? Is it different than your command_line below in any way?

> #'notify-host-by-create-ticket' command definition
> define command {
>        command_name notify-create-ticket
>        command_line /home/himilco/perlscript/create_ticket.pl

You don't pass any arguments to this command. How does it know what it's supposed to create a ticket for? Does it use environment variables or is it hard coded internally for testing? Also, it's very unusual for another user to have access to someone else's homedir. Did you modify permissions to grant extra access to /home/himilco?

>        # I tried also to put : command_line /opt/rt3/bin/rt create -t ticket set subject='ticket_from _nagios ' priority=10 queue=General  

This looks like it should work. Is the command 'rt' a perl script as well? I haven't used Request Tracker before.

> the nagios log show this line:
> ************
> Mar  4 12:01:25 localhost nagios: HOST NOTIFICATION: nagiosadmin;pc-yacine;DOWN;notify-create-ticket;CRITICAL - Host Unreachable (172.16.125.140)
> *************

Yes, that's a good sign. Nagios is trying to execute your script.

Do you have the embedded perl interpreter enabled? If so, is create_ticket.pl written to it's standards? If it's enabled, try disabling it globally or for this script in particular. The documentation for Enabling the Embedded Perl Interpreter can help you answer these questions.

Additionally, I'd just try adding a couple lines at the top of create_ticket.pl to write some text to a file in /tmp. Just something to show that it ran.

Finally, you might try modifying the command_line to capture any output from the script to a file for inspection --

>        command_line /home/himilco/perlscript/create_ticket.pl >/tmp/ticket.out 2>&1

--
Marc




------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list