acctctl(3c) acctctl(3c) NAME acctctl - controls and provides status for comprehensive system accounting (CSA) SYNOPSIS #include <sys/acct.h> int acctctl (int function, void *act); DESCRIPTION The acctctl library call checks the status of, enables, and disables process, daemon, and record accounting. The record accounting types supported are memory and I/O. The kernel and daemon accounting types supported are csa, nqs, tape, and workload management. The acctctl library call accepts the following arguments: fnc Identifies a function to be performed as follows: Function Description AC_START Starts kernel, daemon, or record accounting; sets cpu time or memory threshold. AC_STOP Stops kernel, daemon, or record accounting. AC_HALT Stops all kernel, daemon, and record accounting. AC_CHECK Checks a kernel, daemon, or record accounting state. AC_KDSTAT Checks all kernel and daemon accounting states. AC_RCDSTAT Checks all record accounting states. AC_JASTART Starts user job accounting. AC_JASTOP Stops user job accounting. AC_WRACCT Writes accounting record for a daemon program. AC_AUTH Checks if caller has the necessary capabilities for privileged acctctl calls act Points to either an actctl, actstat, or actwra structure, depending on the function (that is, fnc) to be performed. The actctl structure is used with AC_START, AC_STOP, AC_KDSTAT, AC_RCDSTAT, AC_JASTART, and AC_JASTOP functions. The actstat structure is used with AC_CHECK function. The actwra structure is used with the AC_WRACCT function. This parameter is ignored for the AC_AUTH function. The AC_START, AC_STOP, AC_HALT, and AC_WRACCT functions require the CAP_ACCT_MGT capability. See the capability(4) and capabilities(4) man pages for more information on the capability mechanism that provides fine grained control over the privileges of a process. If the type of accounting you specified already is enabled and the path information in the actctl structure differs from the accounting file currently in use, the accounting file will be switched to the new path without losing any accounting information. Only a process with appropriate privilege can use this system call to enable or disable accounting. However, privilege is not required to check the status of accounting. EXAMPLES The following example shows how to write an NQS daemon accounting record. Similar code would be written for other daemon accounting record types. You need to use the following include statements: #include <sys/types.h> #include <sys/time.h> #include <sys/acct.h> #include <csaacct.h> #include <optional_sym.h> ... To write a daemon accounting record within a procedure, see the following example: struct nqsbs nqsbs; struct actwra actwra; memset((char *)&nqsbs, 0, sizeof(nqsbs)); nqsbs.hdr.ah_magic = ACCT_MAGIC; nqsbs.hdr.ah_revision = REV_NQS; nqsbs.hdr.ah_type = ACCT_DAEMON_NQS; nqsbs.hdr.ah_flag = 0; nqsbs.hdr.ah_size = sizeof(nqsbs); nqsbs.type = type; nqsbs.subtype = subtype; nqsbs.jid = jid; nqsbs.time = time(0); /* convert time values from clock ticks to microseconds */ nqsbs.utime = clock_to_microsec(utime); nqsbs.stime = clock_to_microsec(stime); /* fill in remaining nqsbs fields */ actwra.ac_did = ACCT_DMD_NQS; actwra.ac_len = sizeof(nqsbs); actwra.ac_jid = jid; actwra.ac_buf = (char *)&nqsbs; if ( _MIPS_SYMBOL_PRESENT(acctctl) == 1) { if (acctctl(AC_WRACCT, &actwra)) { /* handle error condition */ } } else { /* this system doesn't have the acctctl() call available */ } } ERRORS Under the following conditions, the acctctl function fails and sets errno to: [EACCESS] Search permission is denied on a component of the path prefix. [EFAULT] The act argument points to an illegal address. [EINVAL] An invalid argument was specified. [EPERM] The process does not have appropriate capability to use this library call. [ENOPKG] The CSA software is not installed or not enabled via the systune(1M) command. [ENOJOB] No job table entry is found when attempting to start or stop user job accounting. DIAGNOSTICS Upon successful completion, acctctl returns a value of 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. SEE ALSO ja(1). Page 3