Topic
14 replies Latest Post - ‏2012-10-04T20:37:59Z by SystemAdmin
SystemAdmin
SystemAdmin
102 Posts
ACCEPTED ANSWER

Pinned topic Executing a simple java program when health policy is violated

‏2011-12-22T04:58:06Z |
Hi ,

Please help me configuring a custom health action.
When a particular health policy is violated, i want a single java class file to get executed.
It is a simple program containing its own 'main' method that prints some 'sysout' in the logs.
Expectation is that the java program should be executed and I should be able to view these sysouts in my cluster member logs when health policy is violated .

Please tell me what other settings are needed, apart from those done in the attached screenshot, and whether the mentioned settings are proper.

Regards,
Paresh
Updated on 2012-10-04T20:37:59Z at 2012-10-04T20:37:59Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    102 Posts
    ACCEPTED ANSWER

    Re: Executing a simple java program when health policy is violated

    ‏2011-12-29T04:04:35Z  in response to SystemAdmin
    Hi ,

    Can anyone please assist me here.I have been looking for a solution for this problem since a long time.

    Regards,
    Paresh
    • vadrian
      vadrian
      2 Posts
      ACCEPTED ANSWER

      Re: Executing a simple java program when health policy is violated

      ‏2011-12-29T14:25:33Z  in response to SystemAdmin
      Hi Paresh,
      What is the problem? Do you see the health policy being triggered?
      Is an FFDC generated in the logs/ffdc directory?
      Are any messages in the server's "logs" directory on the target machine?
      Adrian
      • SystemAdmin
        SystemAdmin
        102 Posts
        ACCEPTED ANSWER

        Re: Executing a simple java program when health policy is violated

        ‏2011-12-30T09:01:14Z  in response to vadrian
        Hi Adrian,

        What i want to know, is that how do we configure a custom health action.
        How do i make a standalone java program or a script get executed when a health policy is violated.
        I am sure that health policy is getting violated because they get displayed to me in my "Runtime Tasks" section within "Task Management" panel.

        But how do we configure a custom health action using admin console.
        What value should i provide for these fields specific to custom health action in WAS admin console
        Executable
        Executable arguments
        Name of a variable for referencing a user name in executable arguments
        The user name to be substituted for the user name variable at invocation time
        Name of a variable for referencing a password in executable arguments
        The password to be substituted for the password variable at invocation time

        I have earlier attached the screenshot of the admin console screen specific to custom health actions, with the above mentioned fields in it.
        Regards,
        Paresh
        • vadrian
          vadrian
          2 Posts
          ACCEPTED ANSWER

          Re: Executing a simple java program when health policy is violated

          ‏2011-12-30T13:47:18Z  in response to SystemAdmin
          Hi,

          This documentation should be of assistance: http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.ops.doc%2Finfo%2Fodoe_task%2Ftodhealthpolicy.html

          One way to use custom actions is to define a simple script which will execute whatever you want; for example, on linux, define a bash script which establishes some context (e.g. switches users), and invokes a wsadmin / jython script, supplying it with the parameters you want. The script's environment will contain variable definitions for the sick server ($server) and node ($node). Additionally, on my linux-based system, I have $USER, which is the user the server is running under, and $WAS_CELL_NAME. If the script needs to run as a different user, then that has to be accomplished from the script -- the custom health definition doesn't provide a way to do that.

          The server does not expose any passwords to the script's environment, so authentication/authorization has to be established some other way, e.g. using su from the server's user ID.
          • SystemAdmin
            SystemAdmin
            102 Posts
            ACCEPTED ANSWER

            Re: Executing a simple java program when health policy is violated

            ‏2012-05-29T05:36:34Z  in response to vadrian
            Hi All,

            I have never been able to make use of custom health actions.Although Adrian did try to assist me, but i have not been able to figure it out yet.
            Please assist me in executing a script as part of a custom health action.

            Whenever i try to get a script invoked as part of custom health action when a health policy is violated, it fails.
            I have set the 'Reaction mode' as 'Supervise', and every time it gets triggered, i submit the custom Health action to get executed, but my script never gets executed.
            I keep getting Status message as "Failed: WXDH1024E: The attempt to start and complete custom task AlertScript failed.".

            Here 'AlertScript' is a dummy script that contains only plain echo statements and should get invoked at the time of policy violation.

            The command that it tries to execute (as seen in Runtime Tasks , task specific panel ) is
            AdminTask.executeHealthAction().

            When i try to manually execute this command manually also, it fails.

            The Custom Action 'AlertScript' was created with the following details :

            Executable /...../Alert.sh Full path till the script location
            Executable arguments None
            Name of a variable for referencing a user name in executable arguments FIELD LEFT BLANK
            The user name to be substituted for the user name variable at invocation time FIELD LEFT BLANK
            Name of a variable for referencing a password in executable arguments FIELD LEFT BLANK
            The password to be substituted for the password variable at invocation time FIELD LEFT BLANK
            Supported on Operating Systems of type: UNIX
            Working directory Path pointing till the parent folder containing the script to be executed
            • ambati
              ambati
              13 Posts
              ACCEPTED ANSWER

              Re: Executing a simple java program when health policy is violated

              ‏2012-05-29T13:12:54Z  in response to SystemAdmin
              Paresh, what version of VE are you using? There was an issue with custom tasks that was fixed in VE 7.0. Also, pls make sure that the script is executable and is accessible to the ID used to start the nodeagent/middleware agent. Is this script located on a nodeagent or middleware agent?
              • SystemAdmin
                SystemAdmin
                102 Posts
                ACCEPTED ANSWER

                Re: Executing a simple java program when health policy is violated

                ‏2012-05-29T13:28:18Z  in response to ambati
                Hi Ambati,

                Thank you for your reply.Please find my response below,

                what version of VE are you using
                I am using WVE 7.0.0.1 on WAS 8.0.0.2 .

                make sure that the script is executable and is accessible to the ID used to start the nodeagent/middleware agent
                Yes, the script is executable and is also accessible to the user who is starting the node agent.
                In fact, script was created using the same ID which is used to run node agent .Also ,have deliberately provided full permission to the script file.

                Is this script located on a nodeagent or middleware agent?
                The script is located in the same server machine in which i have the installed WVE environment.
                Its path i have provided, while creating the Custom Action while specifying '*Executable*' and '*Working directory*' .
                Do i have to place it at a specific location on node agent.

                Regards,
                Paresh
                • ambati
                  ambati
                  13 Posts
                  ACCEPTED ANSWER

                  Re: Executing a simple java program when health policy is violated

                  ‏2012-05-29T14:12:16Z  in response to SystemAdmin
                  So, if you have a node agent (as opposed to middleware agent...if you installed VE over ND on this machine, it must be a node agent) on the machine where custom task is being executed, then there is a known problem. I am not entirely sure if the problem you are seeing is same as this known problem until I look at the traces from the node agent (com.ibm.ws.xd.agent.*=all:com.ibm.wsspi.xd.agent.*=all).
                  • SystemAdmin
                    SystemAdmin
                    102 Posts
                    ACCEPTED ANSWER

                    Re: Executing a simple java program when health policy is violated

                    ‏2012-05-29T14:54:06Z  in response to ambati
                    Oh..ok .So something beyond my control could possibly be happening here.Fine Ambati, i will collect the node agent specific trace and share it tomorrow.Please do take a look.
                    If traces indicate ,a known issue, then probably i will have to apply fix packs to make it work.

                    Thanks & Regards,
                    Paresh
                    • SystemAdmin
                      SystemAdmin
                      102 Posts
                      ACCEPTED ANSWER

                      Re: Executing a simple java program when health policy is violated

                      ‏2012-08-03T15:48:52Z  in response to SystemAdmin
                      Hi,

                      I get the same problem with a dummy program on WAS 8.5 ND this time. Please tell me the bug from VE 7.0 has not been replicated into v8.5....
                      Did you find a workaround?
                      Anyone has an idea?

                      btw I doing tests on RHEL ....
                      • SystemAdmin
                        SystemAdmin
                        102 Posts
                        ACCEPTED ANSWER

                        Re: Executing a simple java program when health policy is violated

                        ‏2012-08-06T11:57:39Z  in response to SystemAdmin
                        I had a look on the nodeagent log file, and I found that:
                        So it seems WAS is looking for a Environment variable... Anyone has any idea?
                        8/6/12 7:18:54:359 EDT 00000127 CustomActionT I WXDH1022I: Starting the custom task Write 3 on target thinkNode01.
                        8/6/12 7:18:54:573 EDT 00000127 CustomTaskRun E CWXDA0200E: Method CustomTaskRuntimeProcessLauncher.invokeTask: caught exception: java.lang.NullPointerException
                        at com.ibm.ws.xd.agent.process.ProcessUtils.getProcessDef(ProcessUtils.java:1394)
                        at com.ibm.ws.xd.agent.process.ProcessUtils.getStartStopProcessDef(ProcessUtils.java:2476)
                        at com.ibm.ws.xd.agent.process.ProcessUtils.getServerPidVarName(ProcessUtils.java:1948)
                        at com.ibm.ws.xd.agent.process.BaseForeignServerConfigService.getForeignServerConfigProperties(BaseForeignServerConfigService.java:40)
                        at com.ibm.ws.xd.agent.process.CustomTaskRuntimeProcessLauncher.getTaskEnvironmentVariables(CustomTaskRuntimeProcessLauncher.java:228)
                        at com.ibm.ws.xd.agent.process.CustomTaskRuntimeProcessLauncher.invokeTask(CustomTaskRuntimeProcessLauncher.java:132)
                        at com.ibm.ws.xd.agent.process.CustomTaskRuntimeProcessLauncher.invokeTask(CustomTaskRuntimeProcessLauncher.java:53)
                        at com.ibm.ws.xd.agent.remoteprocess.RemoteProcessRPCServiceImpl.invokeTask(RemoteProcessRPCServiceImpl.java:589)
                        at com.ibm.ws.xd.hmm.actuator.CustomActionTask.execCustomTask(CustomActionTask.java:175)
                        at com.ibm.ws.xd.hmm.actuator.CustomActionTask.run(CustomActionTask.java:143)
                        at com.ibm.ws.xd.hmm.actuator.ReactionManager.run(ReactionManager.java:530)
                        at java.lang.Thread.run(Thread.java:770)

                        8/6/12 7:18:54:575 EDT 00000127 ReactionManag E WXDH1024E: The attempt to start and complete custom task Write 3 failed.
                        • ambati
                          ambati
                          13 Posts
                          ACCEPTED ANSWER

                          Re: Executing a simple java program when health policy is violated

                          ‏2012-08-06T12:10:17Z  in response to SystemAdmin
                          This problem was fixed post ND 8.5. The fix will be shipped in next VE 7.x and ND 8.5 fixpack.
                          • SystemAdmin
                            SystemAdmin
                            102 Posts
                            ACCEPTED ANSWER

                            Re: Executing a simple java program when health policy is violated

                            ‏2012-08-06T13:46:56Z  in response to ambati
                            That a great news, thanks. Where did you got this information?

                            I downloaded all fix for the central fix web page and installed all recommended fixes but the problem is still here... Do you think the fix will be released before the end of October (expected date for the first Fix pack) ?
                        • SystemAdmin
                          SystemAdmin
                          102 Posts
                          ACCEPTED ANSWER

                          Re: Executing a simple java program when health policy is violated

                          ‏2012-10-04T20:37:59Z  in response to SystemAdmin
                          Have you checked out this link?

                          http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/topic/com.ibm.websphere.wve.doc/ae/twve_odhealthaction.html

                          Looks like for Java actions you have to create a PID environment variable. Not sure this is going to solve all the problems....