Running scripts for additional checks

If you want KSYS to perform some additional checks that are specific to your environment, you can add those checks as scripts. You can specify whether those scripts must be run before or after the discovery, verification, or disaster recovery operations.

For example, if you use the Enterprise Pool resource management, you can add a customized script to update the backup host capacity and revert to older capacity values after the verification is complete. To monitor the workload that is running on the virtual machines on a specific criteria, you can add scripts to check the workload before and after the verification.You can run the scripts at site, host group, and VM levels.

The sample scripts are available in the /opt/IBM/ksys/samples/custom_validation/ directory.

Running scripts before or after discovery and verification operations

You can use the following attributes to add a script for additional checks during verification operations:

pre_verify
When you specify a script with this attribute, the script is run before any discovery and verification operations. You can add a pre_verify script by entering the following command syntax:
ksysmgr add script entity=site|host_group|vm pre_verify=script_path
post_verify
When you specify a script with this attribute, the script is run after any discovery and verification operations. You can add a post_verify script by entering the following command syntax:
ksysmgr add script entity=site|host_group|vm post_verify=script_path

Running scripts before or after the disaster recovery operations

You can use the following attributes to add a script for additional checks during disaster recovery operations:

pre_offline
When you specify a script with this attribute, the script is run before the virtual machines are shut down in the primary site. You can add a pre_offline script by entering the following command syntax:
ksysmgr add script entity=site|host_group|vm pre_offline=script_path
post_offline
When you specify a script with this attribute, the script is run after all the virtual machines are shut down in the primary site. You can add a post_offline script by entering the following command syntax:
ksysmgr add script entity=site|host_group|vm post_offline=script_path
pre_online
When you specify a script with this attribute, the script is run before the storage replication direction is reversed and before the virtual machines are restarted on the target site. You can add a pre_online script by entering the following command syntax:
ksysmgr add script entity=site|host_group|vm pre_online=script_path
post_online
When you specify a script with this attribute, the script is run after the virtual machines are restarted on the target site. You can add a post_online script by entering the following command syntax:
ksysmgr add script entity=site|host_group|vm post_online=script_path
When you register scripts, the KSYS subsystem passes the following arguments to the custom scripts that you registered. You can use these values to identify the operation that the KSYS subsystem is performing and to determine at what stage of a specific operation is your script triggered by the KSYS subsystem.
Resource class Argument values Additional arguments that are passed by the KSYS subsystem
Site

KSYS_MOVE_PLANNED_PRE_OFFLINE_SITE

KSYS_MOVE_UNPLANNED_PRE_OFFLINE_SITE

KSYS_MOVE_PLANNED_POST_ONINE_SITE

KSYS_MOVE_UNPLANNED_POST_ONLINE_SITE

KSYS_PRE_DISCOVERVERIFY_QUICK_DISCOVERY_SITE

KSYS_PRE_DISCOVERVERIFY_DETAIL_DISCOVERY_SITE

KSYS_PRE_VERIFYONLY_QUICK_DISCOVERY_SITE

KSYS_PRE_VERIFYONLY_DETAIL_DISCOVERY_SITE

KSYS_PRE_DISCOVERONLY_QUICK_DISCOVERY_SITE

KSYS_PRE_DISCOVERONLY_DETAIL_DISCOVERY_SITE

KSYS_POST_DISCOVERVERIFY_QUICK_DISCOVERY_SITE

KSYS_POST_DISCOVERVERIFY_DETAIL_DISCOVERY_SITE

KSYS_POST_VERIFYONLY_QUICK_DISCOVERY_SITE

KSYS_POST_VERIFYONLY_DETAIL_DISCOVERY_SITE

KSYS_POST_DISCOVERONLY_QUICK_DISCOVERY_SITE

KSYS_POST_DISCOVERONLY_DETAIL_DISCOVERY_SITE

KSYS_DRTEST_PRE_ONLINE_SITE

KSYS_DRTEST_POST_ONLINE_SITE

KSYS_CLEANUP_PRE_OFFLINE_SITE

KSYS_CLEANUP_POST_OFFLINE_SITE

Source site name and target site name
Host group

KSYS_MOVE_PLANNED_PRE_OFFLINE_HOST_GROUP

KSYS_MOVE_PLANNED_POST_OFFLINE_HOST_GROUP

KSYS_MOVE_PLANNED_PRE_ONLINE_HOST_GROUP

KSYS_MOVE_PLANNED_POST_ONLINE_HOST_GROUP

KSYS_MOVE_UNPLANNED_PRE_OFFLINE_HOST_GROUP

KSYS_MOVE_UNPLANNED_POST_OFFLINE_HOST_GROUP

KSYS_MOVE_UNPLANNED_PRE_ONLINE_HOST_GROUP

KSYS_MOVE_UNPLANNED_POST_ONLINE_HOST_GROUP

KSYS_PRE_DISCOVERVERIFY_QUICK_DISCOVERY_HOST_GROUP

KSYS_PRE_DISCOVERVERIFY_DETAIL_DISCOVERY_HOST_GROUP

KSYS_PRE_VERIFYONLY_QUICK_DISCOVERY_HOST_GROUP

KSYS_PRE_VERIFYONLY_DETAIL_DISCOVERY_HOST_GROUP

KSYS_PRE_DISCOVERONLY_QUICK_DISCOVERY_HOST_GROUP

KSYS_PRE_DISCOVERONLY_DETAIL_DISCOVERY_HOST_GROUP

KSYS_POST_DISCOVERVERIFY_QUICK_DISCOVERY_HOST_GROUP

KSYS_POST_DISCOVERVERIFY_DETAIL_DISCOVERY_HOST_GROUP

KSYS_POST_VERIFYONLY_QUICK_DISCOVERY_HOST_GROUP

KSYS_POST_VERIFYONLY_DETAIL_DISCOVERY_HOST_GRUP

KSYS_POST_DISCOVERONLY_QUICK_DISCOVERY_HOST_GROUP

KSYS_POST_DISCOVERONLY_DETAIL_DISCOVERY_HOST_GROUP

KSYS_DRTEST_PRE_ONLINE_HOST_GROUP

KSYS_DRTEST_POST_ONLINE_HOST_GROUP

KSYS_CLEANUP_PRE_OFFLINE_HOST_GROUP

KSYS_CLEANUP_POST_OFFLINE_HOST_GROUP

Host group name
VM

KSYS_PRE_VERIFY_LPAR

KSYS_POST_VERIFY_LPAR

KSYS_MOVE_UNPLANNED_PRE_OFFLINE_LPAR

KSYS_MOVE_PLANNED_PRE_OFFLINE_LPAR

KSYS_MOVE_UNPLANNED_POST_OFFLINE_LPAR

KSYS_MOVE_PLANNED_POST_OFFLINE_LPAR

KSYS_MOVE_UNPLANNED_PRE_ONLINE_LPAR

KSYS_MOVE_PLANNED_PRE_ONLINE_LPAR

KSYS_MOVE_UNPLANNED_POST_ONLINE_LPAR

KSYS_MOVE_PLANNED_POST_ONLINE_LPAR

Virtual machine name

Configuring the timeout duration for custom scripts

You can configure the timeout duration for a custom script. If the custom script is unable to complete the execution within the configured timeout duration, the KSYS subsystem terminates the execution of the custom script and proceeds with the next execution. If the value 0 is set for the timeout duration, the system waits indefinitely for the custom script to complete the execution before proceeding to the next execution. Run the following command to configure the timeout duration for a custom script:
ksysmgr modify system [custom_script_timeout=<sec>]
The custom script timeout value set in the this command is used at the site level, the host group level and the VM level. The sec variable is the timeout duration set in seconds for the custom script.
Note: In the HADR and HADRHA types of deployment, scripts are triggered for both HA and DR processes. To check whether the script is running for the HA process or the DR process, you can use persistent variables, VerifyContext and FailoverContext at the host group level. Run the following commands to check whether the script is running for the HA process or for the DR process:
lsrsrc -s ‘Name=<NameOfHG>’ IBM.VMR_HG VerfiyContext
lsrsrc -s ‘Name=<NameOfHG>’ IBM.VMR_HG FailoverContext