DX Application Performance Management

  • 1.  Problem with EPA running a perl script

    Posted Jan 14, 2016 12:13 PM

    Hi all, I have a problem trying to run an EPA agent with a perl script in Linux. If I run the script on the server, the output is correct:

     

    /usr/bin/perl /apps/introscopeprod/configuration/scripts/fileSystemConn5.pl

    <metric type="IntCounter" name="fileSystemConn5:/apps/tdi/" value="91" />

     

    But when I try to run the same script with EPA agent, I have this message in log file:

     

    1/14/16 05:44:34 PM CET [INFO] [EPAgent.EPAgent fileSystemConn5] Starting plugin 'fileSystemConn5'.

    1/14/16 05:44:34 PM CET [ERROR] [EPAgent] Metric value from plugin 'Plugin fileSystemConn5' is invalid: For input string: ""

     

    And here is the perl script I'm running:

     

    ########################################################################

    # Introscope EPAgent Plugin Script

    # fileSystemConn5 per machine

    #

    ########################################################################

     

     

    #import our modules

    use FindBin;

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

            

    use Wily::PrintMetric;

     

     

    my $fileSystemConn5Command1 = `df -k /apps/tdi/ | tail -1 | cut -d' ' -f 13 | cut -d'%' -f 1`;

     

     

          Wily::PrintMetric::printMetric( type        => 'IntCounter',

                                          resource    => 'fileSystemConn5',

                                          name        => '/apps/tdi/',

                                          value       => $fileSystemConn5Command1,

                                       );

     

     

    Am I doing something wrong? does anyone have a similar problem?

     

    Thanks a lot for your help, regards

     

    Vicente



  • 2.  Re: Problem with EPA running a perl script

    Posted Jan 14, 2016 02:12 PM

    Usually, when something works when you run it from the shell (CLI) but doesn't work when you run it from the agent (or something like cron!), there's something missing in the environment.  Look at your env in your shell and see what's in there that your script may be needing.  Then define that env in your script.  Most of the time that takes care of these kinds of things.

     

    You can also try printing your commands and the different variable values out to a log file to help you see where it is failing.



  • 3.  Re: Problem with EPA running a perl script

    Posted Jan 14, 2016 09:29 PM

    Or you can just a source the environment at the beginning of your command. 


    ". /path/to/env.profile && /command/you/wish/to/exec -args"



  • 4.  Re: Problem with EPA running a perl script
    Best Answer

    Posted Jan 15, 2016 03:33 AM

    Hi Chris, thanks for the info.

     

    Yesterday I tried to answer from my mobile, but was impossible. Now I will check what you said, but I think the  problem is related to the kind of value.

     

    I mean, if I change "my $fileSystemConn5Command1 = `df -k /apps/tdi/ | tail -1 | cut -d' ' -f 13 | cut -d'%' -f 1`;" whith "my $fileSystemConn5Command1 = 91;"

     

    EPA runs correctly, it's like the value for `df -k /apps/tdi/ | tail -1 | cut -d' ' -f 13 | cut -d'%' -f 1`it's taken as a string.

     

    Thanks a lot for your help, best regards

     

    Vicente



  • 5.  Re: Problem with EPA running a perl script

    Broadcom Employee
    Posted Jan 14, 2016 04:27 PM

    Hi Vicente:

    Please let us know if Chris's answer was helpful or you need more assistance.

     

    Thanks

    Hal German



  • 6.  Re: Problem with EPA running a perl script

    Posted Jan 15, 2016 06:15 AM

    Hi all,

     

    I made a new test in debug mode, here are the results:

     

    1) I ran the perl script without introscope and this is the result  ====>  

    /apps/introscope/Introscope_epa/log> perl /apps/introscopeprod/configuration/scripts/fileSystemConn5.pl

    <metric type="IntCounter" name="fileSystemConn5:/apps/tdi/" value="91" />

     

    2) I ran the EPA agent, calling this perl script, I can see this text in the log:

     

    1/15/16 12:06:24 PM CET [INFO] [EPAgent.EPAgent fileSystemConn5] Starting plugin 'fileSystemConn5'.

    1/15/16 12:06:24 PM CET [DEBUG] [EPAgent.EPAgent fileSystemConn5] Starting plugin process: /usr/bin/perl /apps/introscopeprod/configuration/scripts/fileSystemConn5.pl

    1/15/16 12:06:24 PM CET [DEBUG] [EPAgent.EPAgent fileSystemConn5] Process has exited with: 0

    1/15/16 12:06:24 PM CET [DEBUG] [EPAgent] Process plugin parsing line: <metric type="IntCounter" name="fileSystemConn5:/apps/tdi/" value="" />

    1/15/16 12:06:24 PM CET [ERROR] [EPAgent] Metric value from plugin 'Plugin fileSystemConn5' is invalid: For input string: ""

     

     

    do you know why value is getting 0?

     

    Thanks and regards

     

    Vicente



  • 7.  Re: Problem with EPA running a perl script

    Broadcom Employee
    Posted Jan 15, 2016 06:21 AM

    Instead of debugging this, why not just use my rhelDiskStat plugin?

    At least download it and look at it to figure who what you're doing wrong.

    From what you've shown, I think you're making it more complicated than it needs to be.



  • 8.  Re: Problem with EPA running a perl script

    Broadcom Employee
    Posted Jan 15, 2016 06:26 AM

    Here is the one I created for RHEL: Disk Stats for RHEL



  • 9.  Re: Problem with EPA running a perl script

    Posted Jan 15, 2016 08:20 AM

    Thanks for the info Haruhiko, I will try it next week.

     

    Now we have solved the problem modifiying the script, here is the change:

     

    this line         =======>            my $fileSystemConn5Command1 = `df -k /apps/tdi/ | tail -1 | cut -d' ' -f 13 | cut -d'%' -f 1`;

    with this one  =======>           my $fileSystemConn5Command1 = (split /\s+/,  `df -k /apps/tdi/|tail -1 | cut -d'%' -f 1`)[4];