13.9 Customizing the Usage Record Object

The usage record object as natively defined can be customized with the attributes you want to track in your use cases. The chapter on Customizing Objects goes into some detail on the customization syntax. However, since this may be a common requirement, this section will provide a few examples on modifying, adding and deleting usage record attributes and getting them to be tracked and show up in queries.

Usage record discriminators are those properties which are considered primary differentiators between usage, reservation and quote records. Usage record discriminators are used in the dynamic web portal as filters for the listing, modification and deletion of usage records, reservations and quotes. The default usage record discriminators are Type, User, Group, Project, Organization, Class, QualityOfService and Machine. Any new attributes added to the usage record object will become usage record discriminators. Removing a discriminator attribute from the usage record object will necessarily remove it as a usage record discriminator as well. It will be necessary to log out and back in after adding or removing a discriminator in order for it to be reflected in the web GUI.

Example 10. Setting VM as the default Usage Record Type

As installed, the usage record type defaults to "Job". The default value can be set to NULL if there should be no default value, or to any other default value. This example will demonstrate how to set the default usage record type to "VM".

$ goldsh Attribute Modify Object=UsageRecord Name=Type DefaultValue=VM
Successfully modified 1 attribute
Example 11. Adding a UsageRecord Application Field (and descriminator)

Let's say you would like to track the application run by your usage scenarios. First, you would add Application as an Attribute of the UsageRecord Object.

$ goldsh Attribute Create Object=UsageRecord Name=Application DataType=String
Successfully created 1 attribute

If you want the new attribute to show up in glsusage, you must add it to the usagerecord.show string in gold.conf.

$ vi /opt/mam/etc/gold.conf
usagerecord.show = Id,Instance,User,Group,Organization,Project,QualityOfService,Machine,Stage,Charge,Processors,Nodes,Application,Duration,StartTime,EndTime,Description

If you want to filter the usage records by Application, (such as listing all usage records associated with the specified application), use the -X (or --extension) option in glsusage.

$ glsusage -X Application=foo --show=Type,Instance,Charge,User,Application
Type Instance   Charge User Application
---- ---------- ------ ---- -----------
Job  PBS.1234.0  19744 amy  foo  

You could also use Application as the basis of a ChargeRate. See Name-Based Resources or Name-Based Multipliers in the Managing Charge Rates chapter for details on how to do this.

Although the initial step above allows the application value to be tracked in the usage record, it is also possible to add it as an attribute of the Transaction table so that it will be automatically populated from actions having assignments, conditions, options and data values referring to the Application.

$ goldsh Attribute Create Object=Transaction Name=Application DataType=String
Successfully created 1 attribute

Additionally, the gstatement client command can show Application as one of its discriminators (which are Project, User and Machine by default) in its debit detail. These statement discriminators are specified by the --show argument to gstatement and can be configured with the statement.show configuration parameter in gold.conf.

Example 12. Removing the UsageRecord Class Field

Let's say you were not interested in tracking the class. First, you would delete Class as an Attribute of the UsageRecord Object.

$ goldsh Attribute Delete Object==UsageRecord Name==Class
Successfully deleted 1 attribute

Next, we need to make sure glsusage doesn't try to list the class.

$ vi /opt/mam/etc/gold.conf
usagerecord.show = Id,Instance,User,Project,Machine,QualityOfService,Stage,Charge,Processors,Nodes,Application,Duration,StartTime,EndTime,Description

If the attribute you want to delete is also an attribute in the Transaction table, you could delete it from there as well.

(Undefined variable: MyVariables.!CopyrightInfo!)