Hi,<div><br></div><div>I've created a bash script which will do what I want it to do, using the RT Tool since this ended up being the easiest for me (I'll look into improving this further, but for now this works).<div>
<br></div><div>Below the code of what I've created:</div><div><br></div><div><span class="Apple-style-span" style="color: rgb(34, 34, 34); "><font class="Apple-style-span" face="'courier new', monospace"><div>
#!/bin/bash</div><div><br></div><div>for i in `/opt/rt4/bin/rt ls -t ticket "Status!='resolved' and Status!='rejected' and Status!='spam' and Status!='deleted'" -f status | grep ^[0-9] | cut -f 1`; do</div>
<div> status=`/opt/rt4/bin/rt ls -t ticket "id=$i" -f status | grep ^[0-9] | cut -f 2`</div><div> cnew=`/opt/rt4/bin/rt ls -t ticket "id=$i" -f CF-'Counter New' | grep ^[0-9] | cut -f 2`</div>
<div> copen=`/opt/rt4/bin/rt ls -t ticket "id=$i" -f CF-'Counter Open' | grep ^[0-9] | cut -f 2`</div><div> if [ "$status" = "new" ]</div><div> then</div><div> cnew=$(( $cnew + 5 ))</div>
<div> /opt/rt4/bin/rt edit ticket/$i set CF-'Counter New'=$cnew</div><div> fi</div><div> if [ "$status" = "open" ]</div><div> then</div><div> copen=$(( $copen + 5 ))</div><div> /opt/rt4/bin/rt edit ticket/$i set CF-'Counter Open'=$copen</div>
<div> fi</div><div>done</div></font></span></div><div><br></div><div>In the for statement I'm listing all the ticket ID's.</div><div>Then I'm extracting specific fields from the ticket by looking it up, I've found that I need to somehow do it this way because when fields are empty the entire scrip kinda breaks (e.g. if I put the output into an array, the array expects space separated input and it will not understand when 1 field is empty).</div>
<div><br></div><div>Thus, even if it's kinda ugly I request information three times.</div><div><br></div><div>From there an if statement checks the ticket status, for each status it will do almost the same (again, I'll probably make this nicer) and increase the value of the counter CF by 5 (for 5 minutes).</div>
<div><br></div><div>The downside of this script is that it isn't exactly "fast", takes roughly 1 second for each ticket. In our case a typical daily "active" tickets in queue are roughly 120 so it will take 2 minutes to run. Since we run it every 5 minutes this is (barely) within the allowed time.</div>
<div><br></div><div>As for improvements, next step is to make this scrip faster and probably do things via the RT-Crontool. </div><div><br></div><div>But for now I'm happy with this :-) (this gives me some time to think-up a better solution)</div>
<div><br><div>-- Bart<br>
<br><br><div class="gmail_quote">Op 23 november 2011 20:29 schreef Bart <span dir="ltr"><<a href="mailto:bart@pleh.info">bart@pleh.info</a>></span> het volgende:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Did some reading on the RT-Tool page ( <a href="http://requesttracker.wikia.com/wiki/UseRtTool" target="_blank">http://requesttracker.wikia.com/wiki/UseRtTool</a> ) and found this command:<div><br></div><div><font face="'courier new', monospace">bin/rt list -i "Queue = 'testqueue'" | bin/rt edit - set status=resolved</font></div>
<div><br></div><div>I'm lacking the documentation and our test environment a.t.m. (am at home). So I'll do some experimenting in the test environment tomorrow at work, hopefully it will show me some nice results ^_^</div>
<div><br></div><div><br clear="all">-- Bart<br>
<br><br><div class="gmail_quote">Op 23 november 2011 19:57 schreef Bart <span dir="ltr"><<a href="mailto:bart@pleh.info" target="_blank">bart@pleh.info</a>></span> het volgende:<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Yan,<div><br></div><div>I'll also have a look at the rt script and see if I can manage it using that, thanks :)</div><div><br clear="all">-- Bart<br>
<br><br><div class="gmail_quote">Op 23 november 2011 19:50 schreef Yan Seiner <span dir="ltr"><<a href="mailto:yan@seiner.com" target="_blank">yan@seiner.com</a>></span> het volgende:<div><div><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Wouldn't this work (snippet from a bigger script):<br>
<br>
# and set custom fields<br>
/opt/rt4/bin/rt edit ticket/${ticket} set 'CF.{contractor}'="${contractor}"<br>
/opt/rt4/bin/rt edit ticket/${ticket} set 'CF.{amount}'="${amount}"<br>
<br>
That's how I set custom fields. You could get the value that way,<br>
increment it or whatever in a script, and then set it again.<br>
<div><div><br>
<br>
<br>
On Wed, November 23, 2011 10:23 am, Bart wrote:<br>
> Hi Kevin,<br>
><br>
> Thanks for the reply,<br>
><br>
> Guess I'll have to learn Perl a bit more then and experiment a little with<br>
> this.<br>
><br>
> Will post the results once I've gained some progress.<br>
><br>
> -- Bart<br>
><br>
><br>
> Op 23 november 2011 18:08 schreef Kevin Falcone<br>
> <<a href="mailto:falcone@bestpractical.com" target="_blank">falcone@bestpractical.com</a>>het volgende:<br>
><br>
>> On Wed, Nov 23, 2011 at 05:25:01PM +0100, Bart wrote:<br>
>> > I've then created a simple rt-crontool command to see if I could<br>
>> find<br>
>> a ticket and if I could<br>
>> > set a value when I found that ticket. This worked as well, below<br>
>> the<br>
>> result:<br>
>> > /opt/rt4/bin/rt-crontool \<br>
>> > --search RT::Search::FromSQL \<br>
>> > --search-arg "status = 'open'" \<br>
>> > --action RT::Action::SetPriority --action-arg 3 \<br>
>> > --verbose<br>
>> > So now for the question(s):<br>
>> ><br>
>> > * First a simple one, how do I set a value for a custom field?<br>
>> > * And the more difficult one, how do I increase a value instead<br>
>> of<br>
>> replacing it? (adding +<br>
>> > or something like that doesn't seem to work)<br>
>> ><br>
>> > Hopefully this is possible with the rt-crontool, if not then I'd<br>
>> like<br>
>> to hear your thoughts on<br>
>> > how I'd be able to do the above in a different manner.<br>
>><br>
>> Unfortunately, you'll need to write your own RT::Action to change the CF<br>
>><br>
>> You could turn this into a pretty trivial perl script using the RT API<br>
>> and calling $tickets->FromSQL("status = 'open'") and then iterating<br>
>> the list to call AddCustomFieldValue<br>
>><br>
>> -kevin<br>
>><br>
>> --------<br>
>> RT Training Sessions (<a href="http://bestpractical.com/services/training.html" target="_blank">http://bestpractical.com/services/training.html</a>)<br>
>> * Barcelona, Spain — November 28 & 29, 2011<br>
>><br>
><br>
><br>
</div></div>> !DSPAM:4ecd3a6094962612618147!<br>
<div>> --------<br>
> RT Training Sessions (<a href="http://bestpractical.com/services/training.html" target="_blank">http://bestpractical.com/services/training.html</a>)<br>
> * Barcelona, Spain ? November 28 & 29, 2011<br>
><br>
</div>> !DSPAM:4ecd3a6094962612618147!<br>
><br>
<span><font color="#888888"><br>
<br>
--<br>
Pain is temporary. It may last a minute, or an hour, or a day, or a year,<br>
but eventually it will subside and something else will take its place. If<br>
I quit, however, it lasts forever.<br>
<br>
</font></span></blockquote></div></div></div><br></div>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div></div></div>