Previous  |  Next  >  
Product: Cluster Server Guides   
Manual: Cluster Server 4.1 Agent Developer's Guide   

info


 unsigned int (*info) (const char *res_name,
        VCSAgResInfoOp resinfo_op, void **attr_val, char
        **info_output, char ***opt_update_args, char
        ***opt_add_args);

You may select any name for the function.

resinfo_op

The resinfo_op parameter indicates whether to initialize or update the data in the ResourceInfo attribute. The values of this field and their significance are described in the following table:

Value of
resinfo_op

Significance

1

Add and initialize static and dynamic name-value data pairs in the ResourceInfo attribute.

2

Update just the dynamic data in the ResourceInfo attribute.

info_output

The parameter info_output is a character string that stores the output of the info entry point. The output value could be any summarized data for the resource. The Msg key in the ResourceInfo attribute is updated with info_output. If the info entry point exits with success (0), the output stored in info_output is dumped into the Msg key of the ResourceInfo attribute.

The info entry point is responsible for allocating memory for info_output. The agent framework handles the deletion of any memory allocated to this argument. Since memory is allocated in the entry point and deleted in the agent framework, the entry point needs to pass the address of the allocated memory to the agent framework.

opt_update_args

The opt_update_args parameter is an array of character strings that represents the various name-value pairs in the ResourceInfo attribute. This argument is allocated memory in the info entry point, but the memory allocated for it will be freed in the agent framework. The ResourceInfo attribute is updated with these name-value pairs. The names in this array must already be present in the ResourceInfo attribute.

For example:


ResourceInfo = { State = Valid, Msg = "Info entry point output",
        TS = "Wed May 28 10:34:11 2003", FileOwner = root,
        FileGroup = root, FileSize = 100 }

A valid opt_update_args array for this ResourceInfo attribute would be:


 opt_update_args = { "FileSize", "102" }

This array of name-value pairs updates the dynamic data stored in the ResourceInfo attribute.

An invalid opt_update_args array would be one that specifies a key not already present in the ResourceInfo attribute or one that specifies any of the keys: State, Msg, or TS. These three keys can only be updated by the agent framework and not by the entry point.

opt_add_args

opt_add_args is an array of character strings that represent the various name-value pairs to be added to the ResourceInfo attribute. The names in this array represent keys that are not already present in the ResourceInfo association list and have to be added to the attribute. This argument is allocated memory in the info entry point, but this memory is freed in the agent framework. The ResourceInfo attribute is populated with these name-value pairs.

For example:


ResourceInfo = { State = Valid, Msg = "Info entry point output",
        TS = "Wed May 28 10:34:11 2003" }

A valid opt_add_args array for this would be:


        opt_add_args = { "FileOwner", "root", "FileGroup", "root",
                        "FileSize", "100" }

This array of name-value pairs adds to and initializes the static and dynamic data stored in the ResourceInfo attribute.

An invalid opt_add_args array would be one that specifies a key that is already present in the ResourceInfo attribute, or one that specifies any of the keys State, Msg, or TS; these are keys that can be updated only by the agent framework, not by the entry point.

Example, Info Entry Point Implementation in C++

The info field of VCSAgV40EntryPointStruct passed to VCSAgRegisterEPStruct() must be assigned a pointer to this function.

For example:


extern "C" unsigned int
file_info(const char *res_name, VCSAgResInfoOp resinfo_op,
        void **attr_val, char **output, char ***opt_update_args,
        char ***opt_add_args) {

        struct stat stat_buf;
        int i;
        char **args = NULL;
        char *out = new char [80];

        *output = out;

        VCSAgSnprintf(out, 80, 
"Output of info entry point...updates the "Msg" key in ResourceInfo attribute");

// Use the stat system call on the file to get its information

        if ((attr_val) && (*attr_val)) {
           if ((stat((CHAR *)(*attr_val), &stat_buf) == 0) &&
                        (strlen((CHAR *)(*attr_val)) != 0)) {

           if (resinfo_op == VCSAgResInfoAdd) {
// Add and initialize all the static and
// dynamic keys in the ResourceInfo attribute

           args = new char * [7];
           for (i = 0; i < 6; i++) {
                       args[i] = new char [15];
           }
// All the static information - file owner and group
           VCSAgSnprintf(args[0], 15, "%s", "Owner");
           VCSAgSnprintf(args[1], 15, "%d", stat_buf.st_uid);
           VCSAgSnprintf(args[2], 15, "%s", "Group");
           VCSAgSnprintf(args[3], 15, "%d", stat_buf.st_gid);
// Initialize the dynamic information for the file
           VCSAgSnprintf(args[4], 15, "%s", "FileSize");
           VCSAgSnprintf(args[5], 15, "%d", stat_buf.st_size);
           args[6] = NULL;
               *opt_add_args = args;
          }
          else {
// Simply update the dynamic keys in the ResourceInfo
// attribute. In this case, the dynamic info on the file

          args = new char * [3];
          for (i = 0; i < 2; i++) {
                 args[i] = new char [15];
          }
          VCSAgSnprintf(args[0], 15, "%s", "FileSize");
          VCSAgSnprintf(args[1], 15, "%d", stat_buf.st_size);
          args[2] = NULL;
          *opt_update_args = args;
          }
    }
    else {
// Set the output to indicate the error
           VCSAgSnprintf(out, 80, "Stat on the file %s failed",
           *attr_val);
           return 1;
    }
    else {
// Set the output to indicate the error
           VCSAgSnprintf(out, 80, 
           "Error in arglist values passed to the info entry
           point");
           return 1;
    }

// Successful completion of the info entry point
    return 0;
}
 ^ Return to Top Previous  |  Next  >  
Product: Cluster Server Guides  
Manual: Cluster Server 4.1 Agent Developer's Guide  
VERITAS Software Corporation
www.veritas.com