Skip Navigation Links | |
Exit Print View | |
Resource Management, Oracle Solaris Zones, and Oracle Solaris 10 Zones Developer's Guide Oracle Solaris 11.1 Information Library |
1. Resource Management in the Oracle Solaris Operating System
3. Using the C Interface to Extended Accounting
4. Using the Perl Interface to Extended Accounting
Sun::Solaris::Project Constants
Sun::Solaris::Project Functions, Class Methods, and Object Methods
Sun::Solaris::Task Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct Constants
Sun::Solaris::Exacct Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct::Catalog Module
Sun::Solaris::Exacct::Catalog Constants
Sun::Solaris::Exacct::Catalog Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct::Catalog Exports
Sun::Solaris::Exacct::File Module
Sun::Solaris::Exacct::File Constants
Sun::Solaris::Exacct::File Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct::File Exports
Sun::Solaris::Exacct::Object Module
Sun::Solaris::Exacct::Object Constants
Sun::Solaris::Exacct::Object Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct::Object Exports
Sun::Solaris::Exacct::Object::Item Module
Sun::Solaris::Exacct::Object::Item Constants
Sun::Solaris::Exacct::Object::Item Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct::Object::Item Exports
Sun::Solaris::Exacct::Object::Group Module
Sun::Solaris::Exacct::Object::Group Constants
Sun::Solaris::Exacct::Object::Group Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct::Object::Group Exports
Sun::Solaris::Exacct::Object::_Array Module
Sun::Solaris::Exacct::Object::_Array Constants
Sun::Solaris::Exacct::Object::_Array Functions, Class Methods, and Object Methods
Sun::Solaris::Exacct::Object::_Array Exports
7. Design Considerations for Resource Management Applications in Oracle Solaris Zones
The Sun::Solaris::Exacct module is the parent of all the classes provided by libexacct(3LIB) library. libexacct(3LIB) provides operations on types of entities: exacct format files, catalog tags and exacct objects. exacct objects are subdivided into two types.
Items
Single data values
Groups
Lists of items
The Perl extensions to extended accounting provide a Perl interface to the underlying libexacct(3LIB) API and offer the following enhancements.
Full equivalence to C API provide a Perl interface that is functionally equivalent to the underlying C API.
The interface provides a mechanism for accessing exacct files that does not require C coding. All the functionality that is available from C is also available by using the Perl interface.
Ease of use.
Data obtained from the underlying C API is presented as Perl data types. Perl data types ease access to the data and remove the need for buffer pack and unpack operations.
Automated memory management.
The C API requires that the programmer take responsibility for managing memory when accessing exacct files. Memory management takes the form of passing the appropriate flags to functions, such as ea_unpack_object(3EXACCT), and explicitly allocating buffers to pass to the API. The Perl API removes these requirements, as all memory management is performed by the Perl library.
Prevent incorrect use of API.
The ea_object_t structure provides the in-memory representation of exacct records. The ea_object_t structure is a union type that is used for manipulating both Group and Item records. As a result, an incorrectly typed structure can be passed to some of the API functions. The addition of a class hierarchy prevents this type of programming error.
The modules described in this document make extensive use of the Perl double-typed scalar facility. The double-typed scalar facility allows a scalar value to behave either as an integer or as a string, depending upon the context. This behavior is the same as exhibited by the $! Perl variable (errno). The double-typed scalar facility avoids the need to map from an integer value into the corresponding string in order to display a value. The following example illustrates the use of double-typed scalars.
# Assume $obj is a Sun::Solaris::Item my $type = $obj->type(); # prints out "2 EO_ITEM" printf("%d %s\n", $type, $type); # Behaves as an integer, $i == 2 my $i = 0 + $type; # Behaves as a string, $s = "abc EO_ITEM xyx" my $s = "abc $type xyz";