Example script entry points

The following example shows entry points written in a shell script.

Online entry point for FileOnOff

The FileOnOff example entry point is simple. When the agent's online entry point is called by the agent, the entry point expects the name of the resource as the first argument, followed by the values of the remaining ArgList attributes.

In this example of an agent earlier than V50, the value of PathName attribute is the second argument. The agent creates the file test in the specified path.

#!/bin/sh

# FileOnOff Online script

# Expects ResourceName and PathName

#

. $VCS_HOME/bin/ag_i18n_inc.sh

RESNAME=$1

VCSAG_SET_ENVS $RESNAME

#check if second attribute provided

if [ -z "$2" ]

then

VCSAG_LOG_MSG "W" "The value for PathName is not specified"

1020

else

#Create the file

touch $2

fi

exit 0;

Monitor entry point for FileOnOff

When the agent's monitor entry point is called by the agent, the entry point expects the name of the resource as the first argument, followed by the values of the remaining ArgList attributes.

If the file exists it returns exit code 110, indicating the resource is online. If the file does not exist the monitor returns 100, indicating the resource is offline. If the state of the file cannot be determined, the monitor returns 99.

Monitor entry point with intentional offline

This script includes the intentional offline functionality for the MyCustomApp agent.

See About intentional offline of applications.

Note that the method to detect intentional offline of an application depends on the type of application. The following example assumes that the application writes a status code into a file if the application is intentionally stopped.

#!/bin/sh

. ${CLUSTER_HOME}/bin/ag_i18n_inc.sh

ResName=$1; shift;

VCSAG_SET_ENVS $ResName

// Obtain the attribute values from ArgListValues

parse_arglist_values();

RETVAL=$?

if [ ${RETVAL} -eq ${VCSAG_RES_UNKNOWN} ]; then

// Could not get all the required attributes from ArgListValues

exit $VCSAG_RES_UNKNOWN;

fi

// Check if the application's process is present in the ps

// output

check_if_app_is_running();

RETVAL=$?

if [ ${REVAL} -eq ${VCSAG_RES_ONLINE} ]; then

// Application process found

exit $VCSAG_RES_ONLINE;

fi

// Application process was not found; Check if user gracefully

// shutdown the application

grep "MyCustomAppCode 123 : User initiated shutdown command" ${APPLICATION_CREATED_STATUS_FILE}

RETVAL=$?

if [ ${REVAL} -eq 0 ]; then

// Found MyCustomAppCode 123 in the application's status

// file that gets created by the application on graceful

//shutdown

exit $VCSAG_RES_INTENTIONALOFFLINE;

else

// Did not find MyCustomAppCode 123; hence application has

// crashed or gone down unintentionally

exit $VCSAG_RES_OFFLINE;

fi

// Monitor should never come here

exit $VCSAG_RES_UNKNOWN;

Offline entry point for FileOnOff

When the agent's offline entry point is called by the agent, the entry point expects the name of the resource as the first argument, followed by the values of the remaining ArgList attributes.

When the values are accepted by the entry point, the file is deleted.

#!/bin/sh

# FileOnOff Offline script

# Expects ResourceName and Pathname

#

. $VCS_HOME/bin/ag_i18n_inc.sh

RESNAME=$1

VCSAG_SET_ENVS $RESNAME

#check if second attribute provided

if [ -z "$2" ]

then

VCSAG_LOG_MSG "W" "The value for PathName is not specified"

1020

else

#remove the file

/bin/rm -f $2

fi

exit 0;