DX Application Performance Management

Expand all | Collapse all

EPAgent - Running perl script

  • 1.  EPAgent - Running perl script

    Posted May 01, 2016 02:44 AM

    Hello,

     

    I'm trying to run a remote shell script from epagent,

    i wrote a perl script that run this local shell script.

     

    The agent is installed on windows server 2008 R2, both perl and shell script are located at the ~/epapluging/lib/

    When the epagent run the script i recieve this error:

    INFO   | jvm 1    | 2016/05/01 09:30:25 | 5/01/16 09:30:25 AM IDT [ERROR] [EPAgent.EPAgent DS] [ stderr ] [tammpreds1] Connecting to remote server failed with the following error messag

    INFO   | jvm 1    | 2016/05/01 09:30:25 | 5/01/16 09:30:25 AM IDT [ERROR] [EPAgent.EPAgent DS] [ stderr ] e : Access is denied. For more information, see the about_Remote_Troubleshootin

    INFO   | jvm 1    | 2016/05/01 09:30:25 | 5/01/16 09:30:25 AM IDT [ERROR] [EPAgent.EPAgent DS] [ stderr ] g Help topic.

    INFO   | jvm 1    | 2016/05/01 09:30:25 | 5/01/16 09:30:25 AM IDT [ERROR] [EPAgent.EPAgent DS] [ stderr ]     + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException

    INFO   | jvm 1    | 2016/05/01 09:30:25 | 5/01/16 09:30:25 AM IDT [ERROR] [EPAgent.EPAgent DS] [ stderr ]     + FullyQualifiedErrorId : PSSessionStateBroken

     

    The script i running without an error manualy via cmd:

    perl "<script path>"

    output: <metric type="IntCounter" name="DS Sessions|Sessions:Count" value="245" />

     

    Please assist.

    Regards,

    Tamir



  • 2.  Re: EPAgent - Running perl script

    Posted May 01, 2016 09:56 PM

    Google indicates that it's powershell providing this error.  My first guess is that powershell is your default execution environment and not cmd, therefore that's the shell being used when commands are executed from Java.  You may try running your script from powershell to see if the output is correct.



  • 3.  Re: EPAgent - Running perl script

    Broadcom Employee
    Posted May 01, 2016 10:25 PM

    Thanks Tim, I concur.

    We have not had a similar error reported previously in our problem database so the root cause if likely something generic rather than EPAgent specific.



  • 4.  Re: EPAgent - Running perl script

    Posted May 02, 2016 02:19 AM

    Hi Tim,

     

    You are correct, the error is coming from powershell. But if i'm running the script manually the is no error.

    I tried changing the default execution enviroment to cmd.exe or even perl without a success,

    Can you please tell me how the EPAgent is running the script?

    And here is a part of my perl script:

     

    use FindBin;
    use lib ("$FindBin::Bin", "$FindBin::Bin/../lib/perl");
    use Wily::PrintMetric;

    use strict;

    my ($out,$reg,$val);
    $val = 0;
    $out = `C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -executionpolicy bypass -File "D:\\Program Files\\CA\\Wily\\EPAgent\\epaplugins\\lib\\check_sessins.ps1"`;

     

    Regards,

    Tamir



  • 5.  Re: EPAgent - Running perl script

    Broadcom Employee
    Posted May 02, 2016 03:53 AM

    $out should be just the command to be executed with double quotes around the whole string.

     

    To execute $out, surround it with backticks (e.g. `$out`).

     

    If you are providing a return code for the execution, you can capture it like this:

     

    $returnValue=`$out`



  • 6.  Re: EPAgent - Running perl script

    Posted May 02, 2016 04:05 AM

    Hi,

    The backticks are srounding the command.

    But even when i changed it like you requested i'm still getting the same error.

    Manually works OK



  • 7.  Re: EPAgent - Running perl script

    Broadcom Employee
    Posted May 02, 2016 04:23 AM

    Show us your updated $out command assignment string.



  • 8.  Re: EPAgent - Running perl script

    Posted May 02, 2016 04:28 AM

    $out = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -executionpolicy bypass -File \"D:\\Program Files\\CA\\Wily\\EPAgent\\epaplugins\\lib\\check_sessins.ps1\"";

     

    This is also running manually without an error.



  • 9.  Re: EPAgent - Running perl script

    Broadcom Employee
    Posted May 02, 2016 04:43 AM

    Your command is wrong you cannot have two sets of double quotes.

     

    Also, your script is in the wrong location. place the file in a directory under epaplugins, not the lib folder. That folder is for the custom Perl modules used by plugins.



  • 10.  Re: EPAgent - Running perl script

    Posted May 02, 2016 04:51 AM

    Because of the white at 'Program Files' i have to use ' double quotes ("),

    i added backslash (\) before it.

    It can;t be the error cause, the script is still running fine manually.

     

    Also at the IntroscopeEPAgent.properties file this is the command-

    introscope.epagent.stateless.DS.command=perl "D:/Program Files/CA/Wily/EPAgent/epaplugins/ds_sessions.pl"

    Already at the new location



  • 11.  Re: EPAgent - Running perl script
    Best Answer

    Posted May 02, 2016 09:11 AM

    I disagree with your conclusion.  You have three execution environments: EPAgent, Perl, and PowerShell (plus, the script within PowerShell).  We know the error comes from PowerShell, so it has to be the invocation of PowerShell within Perl or contents within the PowerShell script.  Remember that running it under EPA will be a different user id, so running it manually may not be an accurate test. 

     

    To simplify your test, substitute a different PowerShell script.  You just need it to return a value.  This will let you know whether it is contents within the script, or the invocation from Perl causing the problem.



  • 12.  Re: EPAgent - Running perl script

    Posted May 02, 2016 09:14 AM

    For clarification purposes: update your perl script to something like this:

    $out = `C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -executionpolicy bypass -File "D:\\Program Files\\CA\\Wily\\EPAgent\\epaplugins\\test\\test.ps1"`;

    where test.ps1 just returns a numeric value.



  • 13.  Re: EPAgent - Running perl script

    Posted May 02, 2016 11:00 AM

    I've changed the ps script with a return value of 10,

    and i got the result just fine from the EPAgent.

     

    <metric type="IntCounter" name="DS Sessions|Sessions:Count" value="10" />

     

    Do you know to tell which user is running with EPAgent?



  • 14.  Re: EPAgent - Running perl script

    Broadcom Employee
    Posted May 02, 2016 11:14 AM

    Depends on what you changed the Windows service to after installation.



  • 15.  Re: EPAgent - Running perl script

    Posted May 03, 2016 12:42 AM

    Hi,

     

    I've changed the "LogOn As" at the EPAgent service  and it fixed my problem.

    10x for the help.