Page 2 of 4

Re: Integrate JIRA with Nagios

Posted: Tue Aug 07, 2018 11:11 am
by scottwilkerson
Lets install with cpan

Code: Select all

cpan -i JIRA::REST

Re: Integrate JIRA with Nagios

Posted: Thu Aug 09, 2018 1:45 am
by rituraj966323
Hi Team,

Please provide an update on above request.

Regards,
Rituraj

Re: Integrate JIRA with Nagios

Posted: Thu Aug 09, 2018 8:42 am
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?

Re: Integrate JIRA with Nagios

Posted: Mon Aug 13, 2018 4:16 am
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

Re: Integrate JIRA with Nagios

Posted: Mon Aug 13, 2018 6:50 am
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.

Re: Integrate JIRA with Nagios

Posted: Mon Aug 13, 2018 7:14 am
by scottwilkerson
@mcapra is correct, when testing from the command like you would need to fill with values that are not the Macros

Re: Integrate JIRA with Nagios

Posted: Fri Sep 21, 2018 5:10 am
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.

Re: Integrate JIRA with Nagios

Posted: Fri Sep 21, 2018 5:19 am
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;

Re: Integrate JIRA with Nagios

Posted: Fri Sep 21, 2018 8:16 am
by scottwilkerson
Can you share the command you are using and how you have it integrated in nagios?

Re: Integrate JIRA with Nagios

Posted: Sun Sep 23, 2018 4:36 am
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