ConfigureEscalationExample: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
No edit summary
 
Line 1: Line 1:
  <nowiki>#!/usr/bin/perl
  <pre>#!/usr/bin/perl
#
#
# This script is one way to escalate ticket priorities for all queues.
# This script is one way to escalate ticket priorities for all queues.
#
#
# Author: Petter Reinholdtsen
# Author: Petter Reinholdtsen
# Date:  2004-08-31
# Date:  2004-08-31
#
#
# Based on shell version previously on
# Based on shell version previously on
# &lt;URL:http://wiki.bestpractical.com/index.cgi?ConfigureEscalationExample&gt;
# &lt;URL:http://wiki.bestpractical.com/index.cgi?ConfigureEscalationExample&gt;
# and
# and
# &lt;URL:http://wiki.bestpractical.com/index.cgi?ConfigureEscalation&gt;
# &lt;URL:http://wiki.bestpractical.com/index.cgi?ConfigureEscalation&gt;
#
#
# Run from cron as user rt-user, making sure rt-user is also a privileged
# Run from cron as user rt-user, making sure rt-user is also a privileged
# RT user with 'Unix name' set to rt-user and having global permissions
# RT user with 'Unix name' set to rt-user and having global permissions
# ShowTicket and ModifyTicket.
# ShowTicket and ModifyTicket.
   
   
use strict;
use strict;
use warnings;
use warnings;
   
   
# Location of RT3's libs and scripts
# Location of RT3's libs and scripts
use lib ("/site/rt3/lib", "/site/rt3/local/lib");
use lib ("/site/rt3/lib", "/site/rt3/local/lib");
my $crontool = "/site/rt3/bin/rt-crontool";
my $crontool = "/site/rt3/bin/rt-crontool";
   
   
package RT;
package RT;
use RT::Interface::CLI qw(CleanEnv);
use RT::Interface::CLI qw(CleanEnv);
   
   
# Clean our the environment
# Clean our the environment
CleanEnv();
CleanEnv();
   
   
# Load the RT configuration
# Load the RT configuration
RT::LoadConfig();
RT::LoadConfig();
   
   
# Initialise RT
# Initialise RT
RT::Init();
RT::Init();
   
   
my $queues = new RT::Queues($RT::SystemUser);
my $queues = new RT::Queues($RT::SystemUser);
$queues-&gt;LimitToEnabled();
$queues-&gt;LimitToEnabled();
   
   
# escalate tickets for all queues
# escalate tickets for all queues
while (my $queue = $queues-&gt;Next) {
while (my $queue = $queues-&gt;Next) {
    my $queuename = $queue-&gt;Name;
    my $queuename = $queue-&gt;Name;
    system("$crontool --search RT::Search::ActiveTicketsInQueue " .
    system("$crontool --search RT::Search::ActiveTicketsInQueue " .
            "--search-arg \"$queuename\" ".
          "--search-arg \"$queuename\" ".
            "--action RT::Action::EscalatePriority");
          "--action RT::Action::EscalatePriority");
}
}
</nowiki>
</pre>

Latest revision as of 16:31, 11 November 2016

#!/usr/bin/perl
#
# This script is one way to escalate ticket priorities for all queues.
#
# Author: Petter Reinholdtsen
# Date:   2004-08-31
#
# Based on shell version previously on
# <URL:http://wiki.bestpractical.com/index.cgi?ConfigureEscalationExample>
# and
# <URL:http://wiki.bestpractical.com/index.cgi?ConfigureEscalation>
#
# Run from cron as user rt-user, making sure rt-user is also a privileged
# RT user with 'Unix name' set to rt-user and having global permissions
# ShowTicket and ModifyTicket.
 
use strict;
use warnings;
 
# Location of RT3's libs and scripts
use lib ("/site/rt3/lib", "/site/rt3/local/lib");
my $crontool = "/site/rt3/bin/rt-crontool";
 
package RT;
use RT::Interface::CLI qw(CleanEnv);
 
# Clean our the environment
CleanEnv();
 
# Load the RT configuration
RT::LoadConfig();
 
# Initialise RT
RT::Init();
 
my $queues = new RT::Queues($RT::SystemUser);
$queues->LimitToEnabled();
 
# escalate tickets for all queues
while (my $queue = $queues->Next) {
    my $queuename = $queue->Name;
    system("$crontool --search RT::Search::ActiveTicketsInQueue " .
          "--search-arg \"$queuename\" ".
          "--action RT::Action::EscalatePriority");
}