How to Display Extended Accounting Status
Type acctadm without arguments
to display the current status of the extended accounting facility.
# acctadm
Task accounting: active
Task accounting file: /var/adm/exacct/task
Tracked task resources: extended
Untracked task resources: none
Process accounting: active
Process accounting file: /var/adm/exacct/proc
Tracked process resources: extended
Untracked process resources: host,mstate
Flow accounting: active
Flow accounting file: /var/adm/exacct/flow
Tracked flow resources: extended
Untracked flow resources: none
|
In the previous example,
system task accounting is active in extended mode and mstate
mode. Process and flow accounting are active in extended mode.
Note - In the context of extended accounting, microstate (mstate) refers to the extended data, associated with microstate process
transitions, that is available in the process usage file (see proc(4)). This data provides much
more detail about the activities of the process than basic or extended records.
How to View Available Accounting Resources
Available resources can vary from system to system, and from platform
to platform. Use the -r option to view the available accounting
resources on the system.
# acctadm -r
process:
extended pid,uid,gid,cpu,time,command,tty,projid,taskid,ancpid,wait-status,flag
basic pid,uid,gid,cpu,time,command,tty,flag
task:
extended taskid,projid,cpu,time,host,mstate,anctaskid
basic taskid,projid,cpu,timeprocess:
extended pid,uid,gid,cpu,time,command,tty,projid,taskid,ancpid,wait-status,flag
basic pid,uid,gid,cpu,time,command,tty,flag
task:
extended taskid,projid,cpu,time,host,mstate,anctaskid
basic taskid,projid,cpu,time
flow:
extended
saddr,daddr,sport,dport,proto,dsfield,nbytes,npkts,action,ctime,lseen,projid,uid
basic saddr,daddr,sport,dport,proto,nbytes,npkts,action
|
How
to Deactivate Process, Task, and Flow Accounting
To deactivate process,
task, and flow accounting, turn off each of them individually.
Become superuser.
Turn off process accounting.
Turn off task accounting.
Turn off flow accounting.
Verify that task accounting, process accounting, and flow accounting
have been turned off. # acctadm
Task accounting: inactive
Task accounting file: none
Tracked task resources: extended
Untracked task resources: none
Process accounting: inactive
Process accounting file: none
Tracked process resources: extended
Untracked process resources: host,mstate
Flow accounting: inactive
Flow accounting file: none
Tracked flow resources: extended
Untracked flow resources: none
|
Using the Perl Interface to libexacct
How to Recursively Print the Contents of an exacct
Object
Use the following code to recursively print the contents of an exacct object. Note that this capability is provided by the library
as the Sun::Solaris::Exacct::Object::dump() function. This
capability is also available through the ea_dump_object()
convenience function.
sub dump_object
{
my ($obj, $indent) = @_;
my $istr = ' ' x $indent;
#
# Retrieve the catalog tag. Because we are
# doing this in an array context, the
# catalog tag will be returned as a (type, catalog, id)
# triplet, where each member of the triplet will behave as
# an integer or a string, depending on context.
# If instead this next line provided a scalar context, e.g.
# my $cat = $obj->catalog()->value();
# then $cat would be set to the integer value of the
# catalog tag.
#
my @cat = $obj->catalog()->value();
#
# If the object is a plain item
#
if ($obj->type() == &EO_ITEM) {
#
# Note: The '%s' formats provide s string context, so
# the components of the catalog tag will be displayed
# as the symbolic values. If we changed the '%s'
# formats to '%d', the numeric value of the components
# would be displayed.
#
printf("%sITEM\n%s Catalog = %s|%s|%s\n",
$istr, $istr, @cat);
$indent++;
#
# Retrieve the value of the item. If the item contains
# in turn a nested exacct object (i.e., an item or
# group),then the value method will return a reference
# to the appropriate sort of perl object
# (Exacct::Object::Item or Exacct::Object::Group).
# We could of course figure out that the item contained
# a nested item orgroup by examining the catalog tag in
# @cat and looking for a type of EXT_EXACCT_OBJECT or
# EXT_GROUP.
#
my $val = $obj->value();
if (ref($val)) {
# If it is a nested object, recurse to dump it.
dump_object($val, $indent);
} else {
# Otherwise it is just a 'plain' value, so
# display it.
printf("%s Value = %s\n", $istr, $val);
}
#
# Otherwise we know we are dealing with a group. Groups
# represent contents as a perl list or array (depending on
# context), so we can process the contents of the group
# with a 'foreach' loop, which provides a list context.
# In a list context the value method returns the content
# of the group as a perl list, which is the quickest
# mechanism, but doesn't allow the group to be modified.
# If we wanted to modify the contents of the group we could
# do so like this:
# my $grp = $obj->value(); # Returns an array reference
# $grp->[0] = $newitem;
# but accessing the group elements this way is much slower.
#
} else {
printf("%sGROUP\n%s Catalog = %s|%s|%s\n",
$istr, $istr, @cat);
$indent++;
# 'foreach' provides a list context.
foreach my $val ($obj->value()) {
dump_object($val, $indent);
}
printf("%sENDGROUP\n", $istr);
}
}
|
|