DX Application Performance Management

 View Only
Expand all | Collapse all

batch script calling perl, via action not working

  • 1.  batch script calling perl, via action not working

    Posted Sep 09, 2014 01:05 AM

    I have a very frustrating issue that I (and others) am unable to figure out. Hoping I am just overlooking something simple, and that someone here can help.

     

    We have a batch script that invoked a perl script as part of an action. This has worked great in our old 8.2 environment. After upgrading to 9.5, the action triggers, the batch script is called, but the line inside calling the perl script is never executed. (I see that the script is called via a echo/log I added to the end of the batch script which can be seen on the final line of the batch below).

     

    If I run the batch script manually from a command prompt (and pass it the same information that is being passed via the introscope action), everything works as expected. This leads me to believe that is has something to do with pathing or access when the script is called via the introscope action, but I cannot figure out how/where this issue might be.

     

    As you can see, the script is extremely simple (see below a screenshot of the action and the text from the batch script)

     

    bemalert.jpg

     

    @ECHO OFF

    setlocal

    CD d:\sysmgt

    SET DiSCONN_ALERT=%1

    start /B /WAIT d:\perl64\bin\perl.exe d:\sysmgt\ha_event.pl %DISCONN_ALERT%

    echo %DISCONN_ALERT% >>d:\sysmgt\test.log



  • 2.  Re: batch script calling perl, via action not working

    Broadcom Employee
    Posted Sep 09, 2014 09:31 AM
    You still need to add an alert element to pass. Try the EM host name for your test.


  • 3.  Re: batch script calling perl, via action not working

    Posted Sep 09, 2014 11:00 AM

    Mr. Davis,

     

    As I said earlier, the action itself is working as expected. It is passing the correct data (the entire text) to the batch script, and I can see that coming to the batch script by looking at the log file that I am creating. For some reason though, the perl script is not getting called at all.

     

    Again, just to be clear: I can see the entire message passed to my batch script, something like:

     

    "9/8/14 9:40:45 AM CDT Introscope Enterprise Manager (L4DWEPAP760:10.100.6.26) reported:  The Alert myHRAMEX_Heap Bytes in Use opened a caution alert with a target of 650000000:         SuperDomain/BTS_ITOperations-Linux_Unix_PROD|l8repa28|JBoss|A828_MyHR-AMEX_CL1_M4|GC Heap:Bytes In Use = 681776856"

     

    So this part is working as expected. When I run the batch script manually (from a command prompt separate from introscope calling it), and pass it the above argument string, everything works as expected. The perl script is called etc. When the batch script is called via introscope though, the perl script is never called (but the test log I added at the end of my script is called, so I know that a) the bat script is being called and b) the correct data is being passed to it.

     

    As I said in my original post, this is a weird one. I've spent the past day or two trying to troubleshoot and figure out whats going on. Also as I said, this works perfectly fine in our 8.2 environment using the exact same scripts (batch and perl). I'm pretty much stumped at this point.



  • 4.  Re: batch script calling perl, via action not working

    Posted Sep 09, 2014 12:16 PM

    Hi Russell,

     

    If you ask me, it seems there might be two things which are stopping your nested script to execute.

    1. Permission Issue for your script: Your Wily user might be having access and execute the script but your script is not having proper permission to execute any other operation.
    2. If your .pl is using some global Environment variables, then you should make it available in your first script using set command.

     

    Also I will suggest you, instead of using perl and other complex language to integrate, try to integrate one shell file which is calling another shell script which is simply logging into some logs. ( no start command or perl to execute. ) Just see whther that is allowing you to do or not.

     

    Hope above data points may be usefull for you.

     

    Regards,

    Vaibhav



  • 5.  Re: batch script calling perl, via action not working

    Broadcom Employee
    Posted Sep 09, 2014 12:59 PM

    Hi Russ,

     

    In the Management Module Editor, have you tried going to the action itself and clicking the "Test Now" button?  Can you verify if the perl script is called at this point?

     

    Can you try removing the start /B /WAIT from the line that calls the perl script?  I want to rule out that this is not preventing it.

     

    Also have you tried creating another perl script that will not take in any arguments and only write a string to a file?  Something simple to see if the perl script does get called.

     

    Regards,

    Matt



  • 6.  Re: batch script calling perl, via action not working

    Posted Sep 09, 2014 11:03 PM

    Hi Matt,

     

    Clicking the test now button does the same thing as the alert triggering. The batch script gets called, but the perl portion does not. I've tried removing the start command, I've tried just calling perl.exe (because its in my path) instead of the explicit path. I've tried just about everything I can think of. Nothing seems to help. Each time I try something though, I re-run the command manually to validate that it is still working.

     

    I changed my perl call to another batch script. Basically had a line inside the first batch script that gets called from Introscope that called another batch script russ.bat and it just wrote a line to a file. That worked, so the batch script calling another batch script was ok. I also tried a simple perl script that does nothing but write hello world to a log file, and that also doesn't work. So it's something in general with the perl.exe command.

     

    Here is another weird thing, if I change my command to something like: start notepad.exe and trigger the alert, I get a notepad.exe command in my task manager. Hitting test now over and over will load a bunch of them. So calling something like notepad.exe from the batch is working fine. I watch the task manager for perl.exe though, and never see it when the alert is triggered.

     

    If this didnt work when I run it manually I would say here is a problem with perl itself, but that can't be it since I can run the batch script from a command prompt and it works every time.

     

    This is so frustrating!



  • 7.  Re: batch script calling perl, via action not working

    Broadcom Employee
    Posted Sep 09, 2014 11:25 PM

    Make sure the EM service account has RWX to your Perl installation.



  • 8.  Re: batch script calling perl, via action not working

    Posted Sep 09, 2014 11:28 PM

    My EM is on a windows server, and the MoM is running as system. It has RW permissions to everything. This same exact setup worked fine on my 8.2 manager on windows 2003. Now that I have CA APM 9.5 on windows 2008 it is no longer working. I'll continue to look/test/beat my head against the wall until I figure it out.



  • 9.  Re: batch script calling perl, via action not working

    Broadcom Employee
    Posted Sep 09, 2014 11:52 PM

    You still need 'execute' permission on the files and folder.

     

    Try creating an account for the EM and give that account RWX to your Perl installation.



  • 10.  Re: batch script calling perl, via action not working
    Best Answer

    Posted Sep 10, 2014 11:15 AM

    So after much trial and error, and googling of differences in batch scripting between windows 2003 and 2008, I have finally fixed my issue. I still don't really know why the old script worked fine in the old environment, and I had to change it the way I did to make it work in the new, but at this point I don't really care since it's working.

     

    Here is my new script, which works and is triggering as expected.

     

    @ECHO OFF

    setlocal

    SET DISCONN_ALERT=%1

    cd d:\perl64\bin

    start /Dd:\sysmgt /wait d:\perl64\bin\perl.exe d:\sysmgt\ha_event.pl %DISCONN_ALERT%



  • 11.  Re: batch script calling perl, via action not working

    Posted Nov 27, 2014 06:51 AM

    Hello Russel,

     

    Looking at the above post it seems that you are trying to integrate CA Wily Event to BMC Event Management.

     

    If that is the case request your help as i am also trying the same. Also please share the ha_event.pl which will be useful for integration.

     

    Thanks & Regards

    Baskar Gajendran



  • 12.  Re: batch script calling perl, via action not working

    Posted Nov 27, 2014 09:16 AM

    Looking at the two scripts, I notice that the second [and successful !] script has this "cd d:\perl64\bin" in it.

    Possibly, AE is now able to call on perl and that is why it runs successfully.