Integrate JIRA with Nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Integrate JIRA with Nagios

Post by scottwilkerson »

Lets install with cpan

Code: Select all

cpan -i JIRA::REST
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
rituraj966323
Posts: 24
Joined: Tue Jul 17, 2018 9:40 am

Re: Integrate JIRA with Nagios

Post by rituraj966323 »

Hi Team,

Please provide an update on above request.

Regards,
Rituraj
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Integrate JIRA with Nagios

Post by scottwilkerson »

Did you install with the command given?
scottwilkerson wrote:Lets install with cpan

Code: Select all

cpan -i JIRA::REST
Do you still have the same error?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
rituraj966323
Posts: 24
Joined: Tue Jul 17, 2018 9:40 am

Re: Integrate JIRA with Nagios

Post by rituraj966323 »

Hi Team,

Jira-Perl module has been fixed by using above mentioned command.

cpan -i JIRA::REST

Installing /usr/local/share/man/man3/install.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
DAGOLDEN/install-0.01.tar.gz
/usr/bin/make install -- OK
JIRA::REST is up to date (0.019).

But getting below error post running adhoc command

[root@nagios-core /]# /usr/local/nagios/libexec/NagiosIssue2JSD.pl -s "$SERVICESTATE$" -t "$SERVICESTATETYPE$" -A "$SERVICEATTEMPT$" -H "$HOSTNAME$" -S "$SERVICEDESC$" -a "$SERVICEOUTPUT$" -d "$SHORTDATETIME$"
Value "$" invalid for option A (number expected)
USAGE:/usr/local/nagios/libexec/jira_eventhandler.pl -s -t -A -H -S

Kindly confirm if we need to add /usr/local/nagios/libexec/jira_eventhandler.pl configuration file please.

Regards,
Rituraj
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Integrate JIRA with Nagios

Post by mcapra »

I would recommend reviewing the documentation on macros:
https://assets.nagios.com/downloads/nag ... acros.html

Those macros ($SERVICESTATE$, $HOSTNAME$, etc) require an internal Nagios state in order to resolve to anything.

You can still use them in command executions, but it needs to be done in your Nagios command definitions.

If you're simply trying to test this from the command line, you should put in dummy values rather than trying to use the macros.
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Integrate JIRA with Nagios

Post by scottwilkerson »

@mcapra is correct, when testing from the command like you would need to fill with values that are not the Macros
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
rituraj966323
Posts: 24
Joined: Tue Jul 17, 2018 9:40 am

Re: Integrate JIRA with Nagios

Post by rituraj966323 »

Hi Team,

After some modiification in codebase and post resolving some OS and jIra level dependencies ,I am able to generate a jira ticket from Nagios core.Thanks much for your support.
rituraj966323
Posts: 24
Joined: Tue Jul 17, 2018 9:40 am

Re: Integrate JIRA with Nagios

Post by rituraj966323 »

But have little concerns about the $HOSTADDRESS$ parameters and notificationrecipients parameters --> Output unable to get from address directive in $HOSTADDRESS.Please check Description screenshot which i have attached earlier.
Please find the codebase below .

#!/bin/perl

use strict;
use warnings;
use JIRA::REST;
use Data::Dumper;

use Getopt::Std;
use Getopt::Long qw(:config no_ignore_case bundling);

my $jira = JIRA::REST->new({
url => '***************88',
username => '**********',
password => '****************'
#password => '*********'
});

#my $baseurl = $jira->GET('/rest/servicedeskapi/info');
##print Dumper($baseurl);

use vars qw( $state $type $attempt $hostname $servicedesc $serviceoutput $datetime $hostaddress $notificationrecipients );
GetOptions(
'help|h' => \&print_usage,
'state|s=s' => \$state,
'type|t=s' => \$type,
'attempt|A=i' => \$attempt,
'hostname|H=s' => \$hostname,
'servicedesc|S=s' => \$servicedesc,
'serviceoutput|a=s' => \$serviceoutput,
'datetime|d=s' => \$datetime,
'hostaddress|h=s' => \$hostaddress,
'notification|n=s' => \$notificationrecipients,
);


if(!$state or !$type or !$attempt or !$hostname or !$servicedesc) {
print "\tUSAGE:/usr/local/nagios/libexec/jira_eventhandler.pl -s -t -A -H -S \n";
exit 3; #unknown
}

if($type ne "HARD" or $state eq "OK" or $state eq "WARNING" ) {
# not doing anything till its reaaaally a problem
exit 0; #ok
}

my $issue = $jira->POST('/issue', undef, {
fields => {
project => { key => '*****' },
issuetype => { name => '*******' },
summary => "[24]7-NAGIOS] Hostname:$hostname Service:$servicedesc State:$state ",
description => "Hostname:$hostname\n IP:$hostaddress\n Service:$servicedesc\n State:$state\n Info:$serviceoutput\n Contact:$notificationrecipients\n DateTime:$datetime\n"
},
});

exit 0;
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Integrate JIRA with Nagios

Post by scottwilkerson »

Can you share the command you are using and how you have it integrated in nagios?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
rituraj966323
Posts: 24
Joined: Tue Jul 17, 2018 9:40 am

Re: Integrate JIRA with Nagios

Post by rituraj966323 »

Please find the request details below and confirm if any concerns

define command{
command_name jira
command_line $USER1$/NagiosIssue2JSD.pl -s "$SERVICESTATE$" -t "$SERVICESTATETYPE$" -A "$SERVICEATTEMPT$" -H "$HOSTNAME$" -S "$SERVICEDESC$" -a "$SERVICEOUTPUT$" -d "$SHORTDATETIME$"
}

Regards,
rituraj
Locked