Creating tickets via cron

Hello,

I’d like to generate a new ticket every friday morning in a particular
queue. I know the easy way to do this is just have cron email a
message in, but I’d also like it to have certain keywords and it’s
status set already.

Can rt-crontool do this? Does someone have a good example of it?

–Andy

andy> I’d like to generate a new ticket every friday morning in a particular
andy> queue. I know the easy way to do this is just have cron email a
andy> message in, but I’d also like it to have certain keywords and it’s
andy> status set already.
andy>
andy> Can rt-crontool do this? Does someone have a good example of it?

You can either send an email, using this scrip to set properties via
email, see:
http://wiki.bestpractical.com/index.cgi?SetTicketPropertiesViaMail

and search the list, or explore:

RTx-WebCronTool - web interface for the built-in “rt-crontool”
utility, allowing scheduled processes to be launched remotely.

Paulo Matos

|Sys & Net Admin | Centro de Informática |
|Faculdade de Ciências e Tecnologia | Tel: +351-21-2948596 |
|Universidade Nova de Lisboa | Fax: +351-21-2948548 |
|P-2829-516 Caparica | e-Mail: pjsm@fct.unl.pt |


pm> RTx-WebCronTool - web interface for the built-in “rt-crontool”
pm> utility, allowing scheduled processes to be launched remotely.
pm> RTx-WebCronTool-0.01 - Display RT API documentation online - metacpan.org

Please ignore this last part… this is not the answer!!

rt-crontool, is used to act on existent tickets… but it can run arbitry
code from RT, so in theory it is possible (but might be the hard way to do
what you want).

Paulo Matos

|Sys & Net Admin | Centro de Informática |
|Faculdade de Ciências e Tecnologia | Tel: +351-21-2948596 |
|Universidade Nova de Lisboa | Fax: +351-21-2948548 |
|P-2829-516 Caparica | e-Mail: pjsm@fct.unl.pt |


The easiest way that I’ve found to create RT tickets from cron is to make a small universal perl script that takes parameters. The perl script uses the RT perl interface.

A sample call to the perl script from cron would be something like this.

/home/scheduler/rt_custom.pl -subject=‘Diary for Early this week’ -owner=‘Nobody’ -requestor=‘joe@blow.com’ -queue=‘Morning Tasks’ -priority=‘99’ -work_type=‘Task’ -department=‘Unix Systems’

And the code for rt_custom.pl would be something like this. Note, I use some custom fields which will differ from your RT installation.

#!/usr/bin/perl -w

use lib (“/opt/rt3/local/lib”,“/opt/rt3/lib”);
use RT::Interface::CLI;
use RT;
use RT::Ticket;
use RT::CurrentUser;
use Getopt::Long;

$queue = ‘’;
$body = ‘’;

GetOptions (“queue=s” => $queue,
“subject=s” => $subject,
“owner=s” => $owner,
“requestor=s” => $requestor,
“priority=s” => $priority,
“body=s” => $body,
“AdminCc=s” => $AdminCc,
“cc=s” => $cc,
“site=s” => $site,
“work_type=s” => $work_type,
“department=s” => $department,
“group=s” => $group,
“RefersTo=s” => $RefersTo,
“ReferredToBy=s” => $ReferredToBy,
“DependsOn=s” => $DependsOn,
“Parents=s” => $Parents
);

setting some defaults

if ($queue eq ‘’)
{
print_usage();
exit (0);
}

if ($body eq ‘’)
{
$body=’ ';
}
RT::LoadConfig();
RT::Init();

if ($owner eq ‘’) {$owner = ‘Nobody’;}

my $CurrentUser = RT::Interface::CLI::GetCurrentUser();

use MIME::Entity;

my $ticket = new RT::Ticket($CurrentUser);
my $ticket_body = MIME::Entity->build(Data => $body,
Type => ‘text/plain’);

my %ticket_vals = ( Queue => $queue,
Subject => $subject,
Owner => $owner,
Requestor => $requestor,
InitialPriority => $priority,
# FinalPriority => ‘0’,
MIMEObj => $ticket_body,
AdminCc => $AdminCc,
Cc => $cc,
‘CustomField-1’ => $site,
‘CustomField-2’ => $work_type,
‘CustomField-9’ => $department,
‘CustomField-14’ => $group,
‘RefersTo’ => $RefersTo,
‘ReferredToBy’ => $ReferredToBy,
‘DependsOn’ => $DependsOn,
‘MemberOf’ => $Parents
);

my ($id, $transaction_object, $err) = $ticket->Create(%ticket_vals); print $err . “\n” if $err;

sub print_usage
{
print “\nusage: rt_custom.pl -queue [optional parameters]\n”;
print “\nThe queue name is manditory but all other parameters are optional.\n”;
print “The following options are supported:\n\n”;
print “-subject \n”;
print “-owner \n”;
print “-requestor \n”;
print “-priority \n”;
print “-AdminCc \n”;
print “-cc \n”;
print “-site \n”;
print “-work_type \n”;
print “-department \n”;
print “-group \n”;
print “-subject \n”;
print “-body \n”;
print “-RefersTo \n”;
print “-ReferredToBy \n”;
print “-DependsOn \n”;
print “-Parents \n”;
print “\nExample: ./rt_custom.pl -queue="Development" -subject="This is a test subject for test script" -owner=‘bob’ -requestor=‘joe@blow.com’ -priority=99 -body="This is the body of the ticket" -AdminCc="supervisor@blow.com" -cc="manager@blow.com" -site="blow.com" -work_type="Task" -department="Unix Systems"\n\n”;
}-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Paulo Matos
Sent: Thursday, January 26, 2006 2:33 PM
To: Andy Moran
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Creating tickets via cron

On Thu, 26 Jan 2006, Paulo Matos wrote:

pm> RTx-WebCronTool - web interface for the built-in “rt-crontool”
pm> utility, allowing scheduled processes to be launched remotely.
pm> RTx-WebCronTool-0.01 - Display RT API documentation online - metacpan.org

Please ignore this last part… this is not the answer!!

rt-crontool, is used to act on existent tickets… but it can run arbitry code from RT, so in theory it is possible (but might be the hard way to do what you want).

Paulo Matos

|Sys & Net Admin | Centro de Informática |
|Faculdade de Ciências e Tecnologia | Tel: +351-21-2948596 |
|Universidade Nova de Lisboa | Fax: +351-21-2948548 |
|P-2829-516 Caparica | e-Mail: pjsm@fct.unl.pt |


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT Wiki at http://wiki.bestpractical.com

Download a free sample chapter of RT Essentials from O’Reilly Media at http://rtbook.bestpractical.com

WE’RE COMING TO YOUR TOWN SOON - RT Training in Amsterdam, Boston and San Francisco - Find out more at http://bestpractical.com/services/training.html

The easiest way that I’ve found to create RT tickets from cron is to
make a small universal perl script that takes parameters. The perl
script uses the RT perl interface.

Well… The Scrip way might be easiest be cause you just have to properly
format the mail and it will be proce

Paulo Matos

|Sys & Net Admin | Centro de Informática |
|Faculdade de Ciências e Tecnologia | Tel: +351-21-2948596 |
|Universidade Nova de Lisboa | Fax: +351-21-2948548 |
|P-2829-516 Caparica | e-Mail: pjsm@fct.unl.pt |


The easiest way that I’ve found to create RT tickets from cron is to
make a small universal perl script that takes parameters. The perl
script uses the RT perl interface.

Well… The Scrip way might be easiest because you just have to properly
format the mail and it will be proce
… (damm!)… processed by RT. Something in the way “Tools->Offline”.

Paulo Matos