Example 4-3 Creating a New Group Record and Writing to a File
# Prototype list of catalog tags and values. my @items = ( [ &EXT_STRING | &EXC_DEFAULT | &EXD_CREATOR => "me" ], [ &EXT_UINT32 | &EXC_DEFAULT | &EXD_PROC_PID => $$ ], [ &EXT_UINT32 | &EXC_DEFAULT | &EXD_PROC_UID => $< ], [ &EXT_UINT32 | &EXC_DEFAULT | &EXD_PROC_GID => $( ], [ &EXT_STRING | &EXC_DEFAULT | &EXD_PROC_COMMAND => "/bin/stuff" ], ); # Create a new group catalog object. my $cat = new_catalog(&EXT_GROUP | &EXC_DEFAULT | &EXD_NONE); # Create a new Group object and retrieve its data array. my $group = new_group($cat); my $ary = $group->value(); # Push the new Items onto the Group array. foreach my $v (@items) { push(@$ary, new_item(new_catalog($v->[0]), $v->[1])); } # Nest the group within itself (performs a deep copy). push(@$ary, $group); # Dump out the group. dump_object($group); |
Example 4-4 Dumping an exacct File
#!/usr/bin/perl use strict; use warnings; use blib; use Sun::Solaris::Exacct qw(:EXACCT_ALL); die("Usage is dumpexacct # Open the exact file and display the header information. my $ef = ea_new_file($ARGV[0], &O_RDONLY) || die(error_str()); printf("Creator: %s\n", $ef->creator()); printf("Hostname: %s\n\n", $ef->hostname()); # Dump the file contents while (my $obj = $ef->get()) { ea_dump_object($obj); } # Report any errors if (ea_error() != EXR_OK && ea_error() != EXR_EOF) { printf("\nERROR: %s\n", ea_error_str()); exit(1); } exit(0); |
Output From dump Method
This example shows the formatted output of the Sun::Solaris::Exacct::Object->dump() method.
GROUP Catalog = EXT_GROUP|EXC_DEFAULT|EXD_GROUP_PROC_PARTIAL ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_PID Value = 3 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_UID Value = 0 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_GID Value = 0 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_PROJID Value = 0 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_TASKID Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_CPU_USER_SEC Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_CPU_USER_NSEC Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_CPU_SYS_SEC Value = 890 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_CPU_SYS_NSEC Value = 760000000 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_START_SEC Value = 1011869897 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_START_NSEC Value = 380771911 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_FINISH_SEC Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_FINISH_NSEC Value = 0 ITEM Catalog = EXT_STRING|EXC_DEFAULT|EXD_PROC_COMMAND Value = fsflush ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_TTY_MAJOR Value = 4294967295 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_TTY_MINOR Value = 4294967295 ITEM Catalog = EXT_STRING|EXC_DEFAULT|EXD_PROC_HOSTNAME Value = mower ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_FAULTS_MAJOR Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_FAULTS_MINOR Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_MESSAGES_SND Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_MESSAGES_RCV Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_BLOCKS_IN Value = 19 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_BLOCKS_OUT Value = 40833 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_CHARS_RDWR Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_CONTEXT_VOL Value = 129747 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_CONTEXT_INV Value = 79 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_SIGNALS Value = 0 ITEM Catalog = EXT_UINT64|EXC_DEFAULT|EXD_PROC_SYSCALLS Value = 0 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_ACCT_FLAGS Value = 1 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_ANCPID Value = 0 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_WAIT_STATUS Value = 0 ENDGROUP |