#!/usr/bin/perl use strict; use warnings; use JIRA::Client; use Getopt::Std; use Getopt::Long qw(:config no_ignore_case bundling); my $jirauser = 'jirauser'; my $jirapasswd = 'jirapsw'; my $jiraurl = 'https://yourjiraurl'; use vars qw( $assignee $state $type $attempt $hostname $servicedesc ); GetOptions( 'help|h' => \&print_usage, 'assignee|a=s' => \$assignee, 'state|s=s' => \$state, 'type|t=s' => \$type, 'attempt|A=i' => \$attempt, 'hostname|H=s' => \$hostname, 'servicedesc|S=s' => \$servicedesc, ); if(!$assignee or !$state or !$type or !$attempt or !$hostname or !$servicedesc) { print "\tUsage: jira_eventhandler -a \n"; print "\tCreates a jira bug assigned to with a summary eq to the nagios service alias\n"; print "\tand a description eq to the nagios service output for the service the eventhandler is attached to.\n"; exit 3; #unknown } if($type ne "HARD") { # not doing anything till its reaaaally a problem exit 0; #ok } my $jira = JIRA::Client->new($jiraurl, $jirauser, $jirapasswd); my $baseurl = $jira->getServerInfo()->{baseUrl}; my $newissue = $jira->create_issue({ project => 'TST', type => 'Bug', assignee => $assignee, summary => "$hostname: $servicedesc is $state", description => "$hostname: $servicedesc is $state ($type : $attempt)", }); print "OK: Successfully created $baseurl/browse/$newissue->{key}\n"; exit 0; #ok