Use > Server Automation > Run SA extensions > Add scripts to extensible discovery > Add your own scripts to extensible discovery

Add your own scripts to extensible discovery

To customize extensible discovery, you need to write one or more scripts that gather the custom data you want, then import your scripts into SA. For requirements and guidelines on writing scripts, see Write your own scripts for extensible discovery.

  • This section presumes you are familiar with software policies. For details on software policies, see "Software management" in Use section.
  • To add scripts to Extensible Discovery, you must have write access to the Extensible Discovery folder and the ability to create software policies. For more information on permissions, see the SA Administer section.

To create and add your script to Extensible Discovery:

  1. Decide where you want the output of your script to go. It can go either in a custom attribute or in a custom field.
  2. Decide on the name of the custom attribute or custom field. Extensible Discovery will place the output of your script in the named custom attribute or custom field.
    • For a custom attribute, the name will be in the following format: HPSW_ED_<name> where <name> is any string you choose.
    • For a custom field, use any value for the <name> of the custom field.

    You must use the <name> string in the name of your script as described in the steps below.

  3. Write your script such that the output of the script is the data you want to capture. You can write any of the following types of scripts:
    • UNIX shell scripts in a file ending with .sh.
    • Visual Basic scripts in a file ending with .vbs.
    • Windows batch scripts in a file ending with .bat.

    For more information how to write these scripts for Extensible Discovery, see Write your own scripts for extensible discovery.

  4. Test your script to make sure it is functioning properly.
  5. Name your script get_<name>.sh or get_<name>.vbs or get_<name>.bat, where <name> is from step 2. Extensible Discovery uses <name> to locate the custom attribute or custom field for the output of the script.
  6. Make sure your script file has execute permissions. For example, for UNIX scripts use the chmod command.
  7. If you want the output to go into a custom attribute, skip this step and go to step 8 below. Extensible Discovery creates and places the output in the custom attribute named HPSW_ED_<name> by default.

    If you want the output to go to a custom field, you must create a custom field named “<name>” where <name> is the string you used in step 2 and step 5 above. Extensible Discovery first checks for an existing custom field of the specified name. If that custom field exists, Extensible Discovery places the script output there. If that custom field does not exist, Extensible Discovery creates and stores the output in a custom attribute named “HPSW_ED_<name>”.

    For example, if you create a script named get_mysysdata.sh, the output from the script will be placed into the custom field named mysysdata, if it exists. Otherwise the output will be placed in the custom attribute named HPSW_ED_mysysdata.

    For instruction on creating custom fields, see Custom fields.
  8. Wrap your script into a .zip file. Include any other files your script needs in the .zip file.

    As a best practice, include a version string in the name of your .zip file and increment the version string with each subsequent version of your script. For more information, see Upgrade your scripts in extensible discovery.
  9. Import your .zip file into a package in SA.

    For convenience, you can place your packages in /Opsware/Tools/Extensible Discovery/Customer Provided Components. Make sure your imported package specifies the proper target operating system.

    For instructions on importing packages, see "Software management" in the SA Use section.
  10. Open your package in the SA Client and set the Default Install Path property to one of the following and save your changes.
    • UNIX: /var/opt/opsware/extensible_discovery/scripts
    • Windows: %ProgramFiles%\Common Files\Opsware\extensible_discovery\scripts\. SA replaces %ProgramFiles% with the appropriate system Program Files directory.
  11. Add your package to a software policy. Add it either to the software policy named “Customer Provided Scripts” or add it to your own software policy.

    Extensible Discovery remediates the “Customer Provided Scripts” policy by default whenever it runs.

    Note
    Make sure the software policy to which you add your package has the proper target operating system(s). Note that any user who has write access to the “Customer Provided Components” folder can run arbitrary code on any servers that Extensible Discovery is run on. For greater security, use your own software policy and set security on your software policy to meet your security requirements.

  12. If you added your script to your own software policy, you must remediate your policy on all servers where you want Extensible Discovery to run.

    If you added your script to the policy named “Customer Provided Scripts”, you can skip this step.
  13. Run your script as described in Running extensible discovery on managed servers below.

If you intend to use a custom field but inadvertently run your script without having created the custom field and it creates custom attributes on many servers, you can use the following OGSH command to remove the custom attributes from all servers.

rm /opsw/Server/@/*/CustAttr/<custom attribute name>