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

Write your own scripts for extensible discovery

This section describes requirements and guidelines for writing scripts for use with Extensible Discovery. For instructions on how to add your scripts to Extensible Discovery, see Add your own scripts to extensible discovery.

  • HPE provides several sample scripts you can use in the software policy “HPE provided Scripts”. You can view these scripts in /Library/Opsware/Tools/Extensible Discovery/HPE provided Components. For more information, see Scripts provided with extensible discovery.
  • A best practice is to store your script in a version control system.
  • Your script needs to handle error situations within your script and return an accurate exit status. The following explains various error situations and how Extensible Discovery handles them.
    • The exit status of a shell script is the exit status of the last command in the script. A script that returns zero status is considered successful.
    • A script could return zero status but also send some output to stderr. This case is treated as a success. The output from stderr will be treated the same as stdout.
    • A script that returns zero status and outputs nothing to stdout or stderr will be considered a success and the blank value will be written to the appropriate custom attribute or custom field. You could use this method to set the custom attribute or custom field to ““.
    • A script that returns a non-zero value is treated as an error. A message including the script's stdout and stderr will be stored in the HPSW_ED_error custom attribute.
    • A script that is not executable or has syntax errors is treated as an error. A message including the script's stdout and stderr will be stored in the HPSW_ED_error custom attribute.
    • If a script determines that it has nothing to collect on a server (for example, if the get_eeprom_version.sh is run on a Solaris x86 server, where there is no EEPROM), it should return an exit status of 3, which will be interpreted by Extensible Discovery as not applicable, and will return nothing for that particular data item.
    • For UNIX shell scripts, if you want the script to fail when any individual command in the script fails, start the script with the line #!/bin/sh -e. For more information, see the documentation for the UNIX shell.