Description of problem: When I pass the token for alert sender operations, the execution of script fails. However, the notification remarks as SUCCESS. Version-Release number of selected component (if applicable): 2.4.0.Beta01 How reproducible: Always. Steps to Reproduce: 1. Browse to JBoss AS Server 2. Click on Inventory and scroll down and click on Manuall add "Script" OK. 3. Enter the path of the script. Uncheck the Unset box and enter the environment variable as the alert notification sender token listed at http://rhq-project.org/display/RHQ/Design-Resource+operations+for+alerts#Design-Resourceoperationsforalerts-Tokensforalertoperationssender 4. Click Save. 5. Create alert definition and add alert notification for relative resource mode for operation type script execution. 6. Provide the script name of the script added in step 3. Actual results: When the alert condition is met and the notification execute the script, though notification action says SUCCESS, the script execution itself fails. Expected results: Script should be executed and the token should be passed correctly Additional info: Looks like the complete tokens for alert-sender operation is broken. I tried with different tokens but none passed. java.lang.IllegalStateException: Malformed environment entry: %url% at org.rhq.plugins.jbossas.script.ScriptComponent.createEnvironmentVariableMap(ScriptComponent.java:182) at org.rhq.plugins.jbossas.script.ScriptComponent.setEnvironmentVariables(ScriptComponent.java:148) at org.rhq.plugins.jbossas.script.ScriptComponent.invokeOperation(ScriptComponent.java:97) at sun.reflect.GeneratedMethodAccessor1745.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.rhq.core.pc.inventory.ResourceContainer$ComponentInvocationThread.call(ResourceContainer.java:525) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)
Sudhir Can you check if this is still a problem using the correct Alert tokens as discussed with Joseph and Heiko
I tried with jon-server-2.4.0.GA_QA Build# 42 with tokens in <% alert.name %> format and get the same error, java.lang.IllegalStateException: Malformed environment entry: <% alert.name %> at org.rhq.plugins.jbossas.script.ScriptComponent.createEnvironmentVariableMap(ScriptComponent.java:182) at org.rhq.plugins.jbossas.script.ScriptComponent.setEnvironmentVariables(ScriptComponent.java:148) at org.rhq.plugins.jbossas.script.ScriptComponent.invokeOperation(ScriptComponent.java:97) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.rhq.core.pc.inventory.ResourceContainer$ComponentInvocationThread.call(ResourceContainer.java:525) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Moving this to ON_DEV
This worked for me. I created an alert definition called 'test parameter replacement' which would trigger the "twiddle.sh" script on my RHQ Server resource when it fired. In the operation arguments I put "<% alert.name %>" (without the quotes). This was the result of that operation: 00:10:42,742 ERROR [Twiddle] Command failure org.jboss.console.twiddle.command.NoSuchCommandException: No such command named 'test parameter replacement' at org.jboss.console.twiddle.Twiddle.createCommand(Twiddle.java:162) at org.jboss.console.twiddle.Twiddle.main(Twiddle.java:294) twiddle.sh commands: jsr77 Print out JSR77 related information xmbean Print out mbean metadata as an xmbean descriptor info Get the metadata for an MBean get Get the values of one or more MBean attributes invoke Invoke an operation on an MBean create Create an MBean setattrs Set the values of one or more MBean attributes unregister Unregister one or more MBeans query Query the server for a list of matching MBeans set Set the value of one MBean attribute serverinfo Get information about the MBean server Even though the twiddle command failed, the operation results show that the parameter replacement succeeded. The output said: No such command named 'test parameter replacement' As opposed to: No such command named '<% alert.name %>' ----- I'm going to need exact reproduction steps for how you're making this fail.
I tried again with the latest build# 43. Below are the steps I'm performing. 1. Browse though the JBoss AS Server and select RHQ server under it. 2. Click on Alert tab and click New Definition. 3. I'm creating alert for JVM free memory and so I name is as, "JVM free memory alert" 4. Select the condition for JVM Free Memory value changed, so that the alert get triggered often for testing. 5. Click Edit under Alert Notification. 6. Click Add New and select Resource Operations. 7. Select Resource Selection Mode to Relative Resource and click Save. 8. Select Search from as JBoss AS Server 9. Select Then filter by as Script and type in the Name field as twiddle.sh 10. Select Operation Name as Execute Script 11. Click Save. 12. Browse through the twiddle.sh (JBoss AS Server -> RHQ Server -> Resources -> Scripts -> twiddle.sh) 13. Click on Inventory tab and then click on Connection sub tab. 14. Against Environment variables value, enter <% alert.name %> and click OK. Now, in the operation history under status, when I click on Failure, I see the mentioned exception. However, after step 10 if I passed the <% alert.name %> to the command line argument and don't do step 12,13 and 14, then it works. I guess this is the right thing to do. I wasn't able to do this in build# 42 as I was blocked by bug 607548. Marking this bug as verified.
Needs retesting with the script plugin once 613834 is implemented
Created attachment 431542 [details] test-script.sh attaching test-script.sh that you can use when needing a test script to be triggered. It can be used to test passing in env vars, arguments and changing exit codes as needed. Read the comments at the top of the attached script for more info on how to use it.
When testing with a Script plugin resource, test that the alert sender will: 1) pass in NO arguments (leave arguments unset) 1) pass in NO arguments (set argument to an empty string - uncheck the unset button) 2) pass in ONE argument 3) pass in MORE THAN ONE argument
I have verified this on jon-server-2.4.0.GA_QA.zip build# 62 for all the 4 conditions mentiond in #7. Marking this bug as verified.
Mass-closure of verified bugs against JON.