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 |