Ticket Commands in generic Agent not working

Moderator: crythias

Post Reply
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Ticket Commands in generic Agent not working

Post by nk00559584 »

Hi All,

I am trying to run an external script with generic agent using CMD in ticket commands but it doesn't work.

Also, there is nothing in the logs.

what i am doing is:
Script is placed in /opt/otrs/bin/cgi-bin/script.sh

CMD : sh script.sh

Also, I tried using simple commands to print ticket Number into one file using command :

echo ARG[0] >& /tmp/check.log
echo ARG[0] > /tmp/check.log

Neither of them worked.

This is the permission to folder /opt/otrs
================================================
drwxr-xr-x 11 otrs apache 4096 Nov 14 14:58 otrs
================================================

Please help. Thanks in Advance

Regards,
Nitin Khaneja
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Ticket Commands in generic Agent not working

Post by reneeb »

In the generic agent it should be

Code: Select all

sh /opt/otrs/bin/cgi-bin/script.sh
And in the shell script

Code: Select all

echo $1 >> /tmp/check.log
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

Hi Reneeb,

Thanks for your reply.

I did this too. Still i am not able to trigger anything from CMD in ticket Commands in generic agent.

Kindly Suggest.

Regards,
Nitin Khaneja
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Ticket Commands in generic Agent not working

Post by reneeb »

Set the MinimumLogLevel to "debug" in SysConfig, run the GenericAgent manually and check the OTRS log
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

Hi,

Thanks for your reply.

I made the changes and there are certain logs generated.
======================================================================================================================
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::JobRun] Run GenericAgent Job 'scriptt' from db.
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::_JobRunTicket] Execute 'sh /opt/otrs/bin/cgi-bin/ans.sh' for Ticket (2018111301000045/156).
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::_JobRunTicket] Execute 'sh /opt/otrs/bin/cgi-bin/ans.sh' for Ticket (2018111401000016/157).
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::_JobRunTicket] Execute 'sh /opt/otrs/bin/cgi-bin/ans.sh' for Ticket (2018111501000014/158).
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::_JobRunTicket] Execute 'sh /opt/otrs/bin/cgi-bin/ans.sh' for Ticket (2018111501000023/159).
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::_JobRunTicket] Execute 'sh /opt/otrs/bin/cgi-bin/ans.sh' for Ticket (2018111601000012/160).
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::_JobRunTicket] Execute 'sh /opt/otrs/bin/cgi-bin/ans.sh' for Ticket (2018112101000011/161).
[Thu Nov 22 16:06:08 2018][Notice][Kernel::System::GenericAgent::_JobRunTicket] Execute 'sh /opt/otrs/bin/cgi-bin/ans.sh' for Ticket (2018112101000021/162).
========================================================================================================================

It shows script is getting executed but if i check on server, It is not executed.

What could be the issue?

Please help.

Regards,
Nitin Khaneja
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

I have also tried running the script manually from CLI using 'OTRS' user. It is working fine.

but not working from generic agent.

Kindly help.
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

Hi All,

Kindly Suggest. Issue is still not resolved.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Ticket Commands in generic Agent not working

Post by reneeb »

Do you have a relative path to the output file in your .sh or an absolute one? Can you show the ans.sh file?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

Hi Reneeb,

Thanks for your reply.
This is the ans.sh file.
=================================
#!/bin/bash

echo `date` >> /tmp/check.log
=================================

No check.log file is made in /tmp folder.

Regards,
Nitin Khaneja
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Ticket Commands in generic Agent not working

Post by root »

Hi,

Did you check the permissions of /tmp/check.log? This file can be written from the OTRS daemon and / or the web server, usually they run with different users.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

Hi Roy,

I have checked permission of /tmp/check/log file. It is correct.

=============================================
-rw-rw-rw- 1 otrs apache 58 Nov 27 02:32 check.log
=============================================

and OTRS is able to manually run the script.

Please help.

Regards,
Nitin Khaneja
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

Issue is still pending. Please help.

Regards,
Nitin Khaneja
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

Hi Team,

I am getting this error while executing Generic Agent Command.
=============================================================================================================================
Wed Dec 12 11:20:13 2018 error OTRS-otrs.Console.pl-Maint::GenericAgent::Run-01 Can't send to 'root@localhost': 5505.7.1 Unable to relay
Wed Dec 12 11:20:13 2018 error OTRS-otrs.Console.pl-Maint::GenericAgent::Run-01 There was an error executing Execute() in Kernel::System::Console::Command::Maint::GenericAgent::Run: ERROR: OTRS-otrs.Console.pl-Maint::GenericAgent::Run-01 Perl: 5.16.3 OS: linux Time: Wed Dec 12 11:20:13 2018
Wed Dec 12 11:20:13 2018 error OTRS-otrs.Console.pl-Maint::GenericAgent::Run-01 Module <ModuleName>.pm not in @INC (/opt/otrs/Custom /opt/otrs/Kernel/cpan-lib /opt/otrs /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Kindly Suggest.

Regards,
Nitin Khaneja
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Ticket Commands in generic Agent not working

Post by reneeb »

Is it a module, you created? If not, which module is it?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
nk00559584
Znuny newbie
Posts: 10
Joined: 08 Oct 2018, 14:11
Znuny Version: Community
Real Name: Nitin
Company: Tech Mahindra limited

Re: Ticket Commands in generic Agent not working

Post by nk00559584 »

I didn't make any module. I did not make any changes but this is what i found in logs.

I am still facing issue running command on generic agent. Please help.

Regards,
Nitin Khaneja
vincentb
Znuny newbie
Posts: 12
Joined: 30 Jan 2021, 07:51
Znuny Version: 6 community
Real Name: Vincent B.

A possible solution [Re: Ticket Commands in generic Agent not working]

Post by vincentb »

I had the same issue (apparently unable to create/write a file into /tmp from a bash script invoked by a generic agent)
So, for the records, I write here what was for me the solution (on CentOS).

The file was in fact written, but instead of being written in /tmp, it was written in a subdirectory of /tmp (in my case: /tmp/systemd-private-9249ca4931894c8188c41e01a43a37ee-httpd.service-kuz6g2/tmp).
This is a "security feature" called "private tmp", discussed here https://blog.oddbit.com/post/2012-11-05 ... ivate-tmp/
I identified the solution thanks to this article: https://stackoverflow.com/questions/107 ... edir-value
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: A possible solution [Re: Ticket Commands in generic Agent not working]

Post by root »

vincentb wrote: 14 Apr 2021, 09:49 I had the same issue (apparently unable to create/write a file into /tmp from a bash script invoked by a generic agent)
So, for the records, I write here what was for me the solution (on CentOS).

The file was in fact written, but instead of being written in /tmp, it was written in a subdirectory of /tmp (in my case: /tmp/systemd-private-9249ca4931894c8188c41e01a43a37ee-httpd.service-kuz6g2/tmp).
This is a "security feature" called "private tmp", discussed here https://blog.oddbit.com/post/2012-11-05 ... ivate-tmp/
I identified the solution thanks to this article: https://stackoverflow.com/questions/107 ... edir-value
Hi,

It is a security feature. And the proper solution is not to disable this. Implement your scripts by using mktemp to create temporary files or sth. like logger to log messages.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Post Reply