User exits in SAP Hostagent 7.10 and 7.11
[customer exit] [Userexit]
Symptom
You want to add custom specific functionality to be executed within certain ACC operations
Other terms
Userexit, customer exit
Reason and Prerequisites
You want to add some non standard, customer specific functionality to the SAP Hostagent, which will be exectued for certain ACC operations.
You have installed the SAP Hostagent 7.10 or newer
Solution
For each of the following operations, you can define one hook.
The hook is called before the first and after the last command of an ACC Operation.
For the following operations, hooks are supported:
1. Instance Operations:
StopInstanceStartInstanceRegisterInstanceServiceUnregisterInstanceServiceInstance Operations Arguments:SAPSYSTEMNAME : SID of the instanceSAPLOCALHOST : SAPLOCALHOST of the instanceSAPSYSTEM : The instance number
2. Database Operations
StartDatabaseStopDatabaseAttachDatabaseDetachDatabaseLiveDatabaseUpdateDatabase Operations Arguments:SAPDBNAMESAPDBTYPESAPDBHOST
3. For the ACOSPrepare/Unprepare Operations, there exists one Hook for the whole prepare/unprepare Operation:
ACOSPrepare Commands ArgumentsSAPHOOKNAME: PrePrepare,PostPrepare, PreUnprepare,PostUnprepareSAPACOSPREPARE_PARAMFILE Path to the generated parameter file, which contains the parameters of all Commands for one ACOSPrepare/Unprepare operation. Commands are separated by newlines and have the following format:
For ifup|ifdown commands: ifup|ifdown;<interface>;<hostname>;<networkmask>;<broadcast>
For mount|umount Operations
mount|umount;<storage_type>;<storage-type-dependent-params>
- < storage-type-dependent-params> for storage_type NETFS
< FS_NAME>;<Mountpoint>;<fs_options>
- < storage-type-dependent-params>For storage_type SR
< SRID_NAME>;<SRID_TYPE>;<VENDOR>
- For storage_type DFS
< FS_NAME>;<Mountpoint>;<fs_type>;<vendor>;<fs_options>
Not supplied parameters will be left empty, so that the position of the parameters for a command doesn’t change
All of the operations have the parameter SAPHOOKNAME, which contains the name of the hook: Pre|Post|Error<Operationname>, e.g. PreStartInstance or PostUnregisterInstanceService
Configuration:
To configure hooks for a SAP Hostagent Operation, you have to modify the host_profile. Changes to the host_profile are only effective after a restart of the SAP Hostagent.
Hooks are configured per Operation (except for the ACOSPrepare Operation, prepare and unprepare Operation share the same hook, with different SAPHOOKNAME Parameter values):
Add the following entries to the host_profile in one line:
service/hook/<Operationname> = <full-path to script> [SAPHOOKNAME] [<Parametername>]…
e.g.
service/hook/StartInstance = /usr/sap/scripts/startInstancehook.sh [SAPHOOKNAME] [SAPSYSTEMNAME] [SAPSYSTEM] [SAPLOCALHOST]
The corresponding parameter values will be passed to the hook as normal commandline parameters in the same order as specified in the host_profile.
Returncodes:
0: normal hook termination4: hook terminated with warningeverything else is an error, will abort the Operationexecution