Previous section.

Systems Management: Application Response Measurement (ARM) API
Copyright © 1998 The Open Group

Adding ARM Function Calls to an Application

The following steps show how to add ARM API function calls to an application. Also shown is a very simple application that has been instrumented with the ARM Software Developer's Kit (SDK) libarm library of calls.

Each numbered step below (1-4) is highlighted in the source code for the sample application that follows:

  1. Once the SDK is installed, include the header file <arm.h> (for C and C++) in your source code and modify the compile link to reference the library.

  2. Identify the start and the end of the application, and place the calls to arm_init() and arm_end(). These calls are used for initialization and cleanup of the ARM environment for your application, and therefore should be called from the initialization and exit sections of your application.

  3. Determine what transaction classes you want to instrument, and the names to use to uniquely identify each transaction class. Modify the code to call arm_getid() for each transaction class. The arm_getid() calls can also be made from the application initialization section.

  4. Call arm_start() just prior to the start of execution of the transaction, and arm_stop() just after the transaction completes.

When distributing an application, a NULL shared library must be included in the installation package. This will ensure that the application will load and execute correctly, even if no measurement agent is installed.

Note:
If the libarm.* file already exists on the system where the application is being installed, do not overwrite the library. The library that exists may be the NULL library or it could be one of the measurement agent's libraries.

/********************************************************************/
/* sample.c                                                         */
/********************************************************************/

    #include <stdio.h>
(1) #include "arm.h"
    int32 appl_id = -1;            /* Unique id for the application */
    int32 tran_id = -1;            /* Unique id for the transaction */
    void init()
    {
(2)     appl_id = arm_init("ARM sample program" /* application name */
                           "*",                 /* use default user */
                           0,0,0); 
        if (appl_id < 0)
            printf("ARM sample program not registered.");
(3) tran_id = arm_getid(appl_id,    /* application id from arm_init */ 
                        "Sample_transaction",   /* transaction name */
                        "First Transaction in Sample program",
                        0,0,0); 

        if (tran_id < 0) 
            printf("Sample_transaction is not registered.");
    }                                           /* init             */
    void transaction()
    {
        int32 tran_handle;
(4)     tran_handle = arm_start(tran_id, /* trans id from arm_getid */
                                0,0,0); 
        /*********************************************/
        /* Perform actual transaction processing here*/
        /*********************************************/
        sleep(1);
(4) arm_stop(tran_handle,      /* transaction handle from arm_start */
             ARM_GOOD,         /* successful completion define = 0  */
             0,0,0); 
        return;
    }                          /* transaction */
    main()
    {
        int continue_processing = 1;
        init();
        while (continue_processing)
        {
            transaction();
        }
(2) arm_end(appl_id,           /* application id from arm_init      */
            0,0,0);
    return(0);
    }



Why not acquire a nicely bound hard copy?
Click here to return to the publication details or order a copy of this publication.

Contents Next section Index