I've been surfing the documentation as well as navigating through modules all day to get this working.
I have a script on a file server (which is on its web server), and I would like this to be called and executed on my OTRS system whenever there's a high priority ticket that's been created.
Can someone please advise how to do this? Is this even possible from the OTRS Agent interface??????
Execute external script?
Moderator: crythias
Execute external script?
OTRS 3.1.6
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Execute external script?
There is no direct web-based-creation of event to call an external command. It's *possible* that generic agent might do it .. up to 10 minutes later.
It is not possible from the OTRS Agent Interface (this would be a bad security issue to do it from the *agent* side. Admin-not as bad) It could, theoretically, run as a ticket event (program) from the command side.
You can, of course, use a notification event upon a specific priority.
It is not possible from the OTRS Agent Interface (this would be a bad security issue to do it from the *agent* side. Admin-not as bad) It could, theoretically, run as a ticket event (program) from the command side.
You can, of course, use a notification event upon a specific priority.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Re: Execute external script?
Thanks for your response. Definitely understandable. I've actually been playing with the "Ticket Commands" section too, but if I understand correctly, this does not run commands from the system itself, correct? Appears that this would have to be some type of OTRS specific command.crythias wrote:There is no direct web-based-creation of event to call an external command. It's *possible* that generic agent might do it .. up to 10 minutes later.
It is not possible from the OTRS Agent Interface (this would be a bad security issue to do it from the *agent* side. Admin-not as bad) It could, theoretically, run as a ticket event (program) from the command side.
You can, of course, use a notification event upon a specific priority.
Also, in regards to the "Admin-not so bad", would you mind elaborating a little more about this? I am logged into the system as an administrator.
OTRS 3.1.6
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Execute external script?
This I don't know. I've never tried it.altjx wrote:Appears that this would have to be some type of OTRS specific command.
There's Agent interface, and Admin section to change things. "Agents" shouldn't be able to do things that can run as shell. This is bad.altjx wrote:"Admin-not so bad", would you mind elaborating a little more about this? I am logged into the system as an administrator.
an admin *setting* that will do it is ... well, not optimal, but better.
I have a really ... I don't know if this will work ... sample based upon my tutorial:
Kernel/Config/RunSomething.xml
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<otrs_config version="1.0" init="Changes">
<ConfigItem Name="Ticket::EventModulePost###RunSomething" Required="0" Valid="1">
<Description Lang="en">Module to Run arbitrary command if event changes</Description>
<Group>RunSomething</Group>
<SubGroup>EventModule</SubGroup>
<Setting>
<Hash>
<Item Key="Module">Kernel::System::Ticket::Event::RunSomething</Item>
<Item Key="Event">(TicketCreate|TicketPriorityUpdate)</Item>
<Item Key="Trigger">5 - High</Item>
<Item Key="Command">/usr/sbin/echo "Hello, World"</Item>
</Hash>
</Setting>
</ConfigItem>
</otrs_config>
Code: Select all
# --
# Kernel/System/Ticket/Event/RunSomething.pm - event module
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::System::Ticket::Event::RunSomething;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = qw($Revision: 1.2 $) [1];
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
for (
qw(
ConfigObject CustomerGroupObject CustomerUserObject DBObject EncodeObject GroupObject
HTMLUtilsObject LinkObject LockObject LogObject LoopProtectionObject MainObject
PriorityObject QueueObject SendmailObject ServiceObject SLAObject StateObject
TicketObject TimeObject TypeObject UserObject ValidObject
)
)
{
$Self->{$_} = $Param{$_} || die "Got no $_!";
}
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(Data Event Config)) {
if ( !$Param{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
return;
}
}
my %Ticket = $Self->{TicketObject}->TicketGet(
TicketID => $Param{Data}->{TicketID},
UserID => 1,
);
return 1 if !%Ticket;
#broken return 1 if $Ticket{Priority} ne $Param{Priority};
eval 'exec $Param{Command} $Ticket{TicketNumber} "$Ticket{Title}"';
return 1;
}
1;
Edit - I know it won't ... I'm not testing Config {Trigger} ...
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Re: Execute external script?
Hmm, oh ok. Thanks man. I'll give this a shot, and if I can't get it working, I'll keep doing some more reading. I really appreciate your help.crythias wrote:This I don't know. I've never tried it.altjx wrote:Appears that this would have to be some type of OTRS specific command.
There's Agent interface, and Admin section to change things. "Agents" shouldn't be able to do things that can run as shell. This is bad.altjx wrote:"Admin-not so bad", would you mind elaborating a little more about this? I am logged into the system as an administrator.
an admin *setting* that will do it is ... well, not optimal, but better.
I have a really ... I don't know if this will work ... sample based upon my tutorial:
Kernel/Config/RunSomething.xmlKernel/System/Ticket/Event/RunSomething.pm:Code: Select all
<?xml version="1.0" encoding="utf-8" ?> <otrs_config version="1.0" init="Changes"> <ConfigItem Name="Ticket::EventModulePost###RunSomething" Required="0" Valid="1"> <Description Lang="en">Module to Run arbitrary command if event changes</Description> <Group>RunSomething</Group> <SubGroup>EventModule</SubGroup> <Setting> <Hash> <Item Key="Module">Kernel::System::Ticket::Event::RunSomething</Item> <Item Key="Event">(TicketCreate|TicketPriorityUpdate)</Item> <Item Key="Trigger">5 - High</Item> <Item Key="Command">/usr/sbin/echo "Hello, World"</Item> </Hash> </Setting> </ConfigItem> </otrs_config>
Note: I created this without testing. I have no idea if it will or should even work. There's no ability for it to not do bad things like destroy your entire filesystem, etc.Code: Select all
# -- # Kernel/System/Ticket/Event/RunSomething.pm - event module # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see # the enclosed file COPYING for license information (AGPL). If you # did not receive this file, see http://www.gnu.org/licenses/agpl.txt. # -- package Kernel::System::Ticket::Event::RunSomething; use strict; use warnings; use vars qw($VERSION); $VERSION = qw($Revision: 1.2 $) [1]; sub new { my ( $Type, %Param ) = @_; # allocate new hash for object my $Self = {}; bless( $Self, $Type ); # get needed objects for ( qw( ConfigObject CustomerGroupObject CustomerUserObject DBObject EncodeObject GroupObject HTMLUtilsObject LinkObject LockObject LogObject LoopProtectionObject MainObject PriorityObject QueueObject SendmailObject ServiceObject SLAObject StateObject TicketObject TimeObject TypeObject UserObject ValidObject ) ) { $Self->{$_} = $Param{$_} || die "Got no $_!"; } return $Self; } sub Run { my ( $Self, %Param ) = @_; # check needed stuff for (qw(Data Event Config Trigger Command)) { if ( !$Param{$_} ) { $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" ); return; } } my %Ticket = $Self->{TicketObject}->TicketGet( TicketID => $Param{Data}->{TicketID}, UserID => 1, ); return 1 if !%Ticket; return 1 if $Ticket{Priority} ne $Param{Priority}; eval 'exec $Param{Command} $Ticket{TicketNumber} "$Ticket{Title}"'; return 1; } 1;
Edit - I know it won't ... I'm not testing Config {Trigger} ...
OTRS 3.1.6