Solstice AdminSuite 2.3 Administration Guide

How to Embed Software Usage Monitoring into Applications

  1. Open the application source code file that will contain the software usage monitoring commands.

  2. Add the following header file to the application source code.


    #include <swusage.h>
    
  3. Add a swu_rpt() function specifying the begin of the application.


    swu_rpt ("Server_name", "Identifier", SWU_BEGIN, "Product name", avl)
    
  4. Add a swu_rpt() function specifying the end of the application.


    swu_rpt ("Server_name", "Identifier", SWU_END, "Product name", avl)
    
  5. Compile the application source code with one of the following arguments.

    For static linking of the libraries:


    $ ... -I/opt/SUNWswusg/include -L/opt/SUNWswusg/lib -Bstatic -lswusage -lnsl ...

    For dynamic linking of the libraries:


    $ ... -I/opt/SUNWswusg/include -R/opt/SUNWswusg/lib -L/opt/SUNWswusg/lib
     
    -lswusage -lnsl ...

Example of Embedding Software Usage Monitoring into Applications

The following example shows an application that includes the software usage monitoring function.


#include <stdio.h>	/* definition of NULL */
#include <swusage.h>	/* swu_rpt() prototype, swusage_alist definition */
#define 	ATTRIBUTE_COUNT 3
 
main()
{
	struct swusage_alist avl[ATTRIBUTE_COUNT];
 
	/*
	 * Define some product specific attribute-value pairs that will
	 * be included in the software usage report records.
	 */
	avl[0].u_attr = "ATTR_1";
	avl[0].u_value = "val_1";
	avl[1].u_attr = "ATTR_2";
	avl[1].u_value = "val_2";
 
	/*
	 * Terminate the attribute list
	 */
	avl[2].u_attr = NULL;
	avl[2].u_value = NULL;
 
	/*
	 * Create a begin record for the application
	 */
	swu_rpt("Server_name", "Identifier", SWU_BEGIN, "My product name", avl);
 
	/*
	 * The application code would go here.
	 */
 
	/*
	 * Create an end record for the application
	 */
	swu_rpt("Server_name", "Identifier",SWU_END, "My product name", avl);
}

In this example, the software usage report entry looks like this:

Report Entry 1 

 

Report Entry 2 

 

Type

Admin/Usage

Type

Admin/Usage

Product

My product name

Product

My product name

SubType

Begin

SubType

End

Time

8148244876

Time

8148244920

UserID

30581

UserID

30581

User

jod

User

jod

Host

buck

Host

buck

Domain

forest.field.com

Domain

forest.field.com

HostID

1234567890

HostID

1234567890

Locale

C

Locale

C

Version

1

Version

1

Usage Server

Server_name

Usage Server

Server_name

RecordID

Identifier

RecordID

Identifier

C_ATTR_1

val_1

C_ATTR_1

val_1

C_ATTR_2

val_2

C_ATTR_2

val_2