Red Hat Bugzilla – Bug 613834
Include script plugin in JON 2.4release
Last modified: 2015-02-01 18:26:27 EST
This is needed in order for 577256 to be complete, i.e. function on platforms where there is no JBAS instance.
Mazz, we also need the basic test cases for inventoring and executing scripts added to this bug so we can test this feature. Testing will also require retesting 602682.
Created attachment 431541 [details]
Attaching a test-script.sh that you can use to test the script plugin. It will allow you to test passing in env var as well as arguments and changing its exit code. Read the comments in the script file for more info on how to use it.
we can use the same attached script to test bug 602682 as well
Remember that the original purpose of this script plugin was to use a CLI script as a management endpoint for resources that might not have a true management interface (for example, apachectl script could be used to obtain status of apache).
But we can use this for any script - anything that has an exit code or output can be used. You can even just use the fact that the scrip ran successfully as a marker that the resource is UP.
How to test this:
0) take the attached test-script.sh and put it somewhere on your file system (the agent needs to be running on this machine)
1) make sure the Script plugin is deployed
2) Go to your platform resource, and go to Inventory tab and manually add a "Script Server"
3) Point to the full absolute path of your script that you stored in step 0
Now you can do one of several things here:
a) add an environment variable "SCRIPT_MSG" and set it to some string. That string will be output as the first line from the script
b) the first argument passed into the script is the # of seconds the script will sleep - default is 0 if no arguments are passed
c) the second argument passed is the exit code the script will exit with. Default is 0 if there is no second argument passed to it.
The availability of the script can be determined in several ways:
1) just by its existence
2) just by the fact that it can be executed successfully
3) by the exit code matching a regular expression (e.g. "0" or ""
4) by its output matching a regular expression (e.g. "(?s).*OK.*")
5) by both 3 and 4 (matching exit code AND output).
Read the descriptions for all the "Availability Definition" plugin configuration properties for explanations on all the properties and how you can do 1-5 above.
For example, you can set the env var plugin configuration so it passes "SCRIPT_MSG" with value "This is OK". You can then set the "Availability Output Regex" plugin configuration property to "(?s).*OK.*". This will check that the script's output has the word "OK" in it somewhere - if it does, the script resource is assumed "UP". You can then pass in arguments "0 2" and set the "Availability Exit Code Regex" to "2" to ensure that the script exits with exit code 2 to be considered up. anytime you change the plugin config for the script resource, just run the agent prompt command "avail" to get the new availability status of the resource sent up to the server.
Similar settings allow you to use the results of script to determine its version and its description text. Again, the plugin configuration property descriptions give more info on how to do this.
one note: you should not use this script plugin for scripts that are long-lived. it is assumed the script is a short lived command line interface tool that runs, gathers information, outputs that information and exits.
another neat thing we can test using this script plugin is operation timeouts.
Script resources have one operation - "Execute". You give it some arguments to pass to the script and the script is executed.
Since we can now force the script execution to take as long as we want (via the first argument which is the # of seconds the script sleeps before exiting) we can give a large number of seconds to sleep, longer than the operation timeout, and make sure the timeout triggers and fails the operation execution.
I have verified this on jon-server-2.4.0.GA_QA.zip build# 62.
Marking this bug as verified.
Mass-closure of verified bugs against JON.