SAC(8)
β¨ NAME β¨
sac β system accounting. yes bestie, this is the SAC(8) page from the System Manager's Manual, and it's giving system admin realness. π
π SYNOPSIS π
sac [-acdfFhilmoprtU] [-w [wtmp-list|-]] [-b H[:M[:S]]] [-s start] [-e
end] [-X[3|4]] [[-u] user-list] [-x [user-list]] [-T [tty-list]] [-H
[host-list]] [-I H[:M[:S]]] [-M hour-range[,...]] [-R
[portmaster/pattern-list]] [--seconds] [--hms] [--hm] [--hours]
[--round] [--longdate] [--help] [--version]
πΈ DESCRIPTION πΈ
π what even is sac
Sac is a system administration utility. It's based on the original BSD ac program, and its whole thing is reading the wtmp log and producing system usage info that's way more human-readable than what last gives you. Several features that are not in the BSD version of this program have been added. π
π the output types
Okay so sac produces five different types of output (the manpage says five, then lists six β we're just the messenger π):
- total usage in number of login hours since
wtmpwas created β this is the default - login usage per day (
-d) - total usage per user (
-p) - usage per tty line (
-t) - simultaneous usage (
-U) - raw usage (
-r), which prints everythingsacknows about your accounting file(s)
The output of these six gets modified by supplying either the average (-a) option, the hourly profile (-h) option, the login listing (-l) option, and/or the clipping (-c) option.
π
date selection: -s and -e
The -s and -e options are used to select the starting date and ending date, respectively, to report on. The format for the date is one of:
+daysβ days since the beginning of thewtmpfile-daysβ days before the end of thewtmpfile- standard date format:
MM/DD/YY
β° hour range: -M
The -M option is used to select only specific hours in a day to perform accounting on instead of all the hours in the day. The hour-range format is: (0-23)[-(0-23)[,hour-range[,...]]]. The hour given applies to the whole hour, so a range of "5-6" is a time range from 5am to 6:59:59am. This option is probably only useful to those ISP providers that want to charge a different rate for specific time periods.
β¨ average option (-a)
Selecting the average option for total usage gives an average number of login hours per day since the creation of the wtmp file. For the daily option it prints the total # of logins for the day and the average login time per login. For the per person display it displays the total number of logins the user has made and the average amount of time spent on each login. For the TTY option, it prints the total number of logins on that TTY and the average amount of time for each login.
π¦ hourly profile option (-h)
Selecting the hourly profile option for total usage gives a visual display of the percentage of login time spent per hour for all the logins on the system. For the daily option it prints the same visual display for each day. For the per person display it displays the hourly breakdown of login time the user spends on the system (this can be pretty interesting). For the TTY option it breaks down hourly usage for each TTY.
π login listing option (-l)
Selecting the login listing option shows the logins and total time for each individual login for the time period requested on each day, tty line or person depending on the profile requested. Such output is ready-made for use as an ISP billing back-end.
βοΈ clipping option (-c)
Selecting the -c option performs clipping on the amount of login time being used. Multiple logins during the same time period will only count once. As a side effect (possibly a bug) clipping will affect the output of the average option, reporting only the number of logins that uniquely apply to the total login time. Logins that fall totally within the time span of other logins will be totally clipped out, as if they did not occur.
β οΈ bestie, that "possibly a bug" is straight from the manpage β don't @ me.
π₯ user lists, -u, and -x
If the optional user-list is given, sac will only consider accounting information from those users, discarding the rest. The -u option can be used to precede the optional user-list. This option is useful to terminate the -x, -T and -H options.
The -x option has the reverse effect of the -u option, in that it excludes the users specified from accounting. This is useful for removing users that are on a lot, which skew average usage results.
π₯οΈ tty lines: -T
The -T option performs accounting for only the optionally specified tty lines listed. This is useful for determining modem usage, and who's been using them the most. The tty line may be given as a wildcard pattern, using *, ?, [...] and [^...] to easily select a given set of tty lines (such as ttyC* to produce accounting on cyclades tty lines). Wildcard patterns should be escaped or quoted to avoid having the shell process them.
π hosts: -H
The -H option performs accounting for only the optionally specified hosts listed. Since a host-name can only be up to 16 characters long in the wtmp file, only the first 16 characters of a given host-name will be considered for purposes of matches. If a host-name given on the command line does not contain any dots (.) or ends with a dot, it is taken to be a substring and will match if the first part of the wtmp host-name matches the substring. Like with tty lines, the hostname may be given as a wildcard, using *, ?, [...] and [^...] to easily select a large number of hosts at once (such as *.indstate.*).
π include files with @
If an option word used in a -u, -x, -T or -H list begins with an @ (at) sign, it denotes that the option word specifies a file which contains a list of usernames, ttys or hostnames to be applied to the specific option. The "include file" may contain comments which are denoted by a # (pound) character at the beginning of a line, ala shell scripts. If a word in an include file begins with an @ as well, it denotes another file is to be included.
π‘ ftp logins: -f and -F
The -f option makes sac perform accounting on both normal logins and ftp logins. The -F option makes sac perform accounting on ftp logins, normal logins are not considered. Sac is only guaranteed to work with wu-ftpd (wu-archive FTP daemon) style of utmp entry for ftp logins, denoted by a line of "ftp#####" where "#####" is the process ID of the ftp process.
β³ time formats: --seconds, --hms, --hm, --hours, --round
The time format for sac defaults to fractions of hours. Thus 1.5 hours is 1 hour and 30 minutes. The output time format may be changed using the command line options --seconds (seconds only), --hms (hour:minute:second format), --hm (hour:minute format), --hours (hours only format), and --round which rounds the time to the nearest minute or hour instead of always rounding down.
β¨ OPTIONS β¨
okay bestie, here's the whole menu of switches sac understands π pick your faves:
--helpβ dumps out a verbose usage listing. like, it tells you everything. go off.--verboseβ prints alerts whenever sac bumps into errors or other weird strange phenomena π. and here's the tea: if there's a nullwtmpentry (which, btw, is sometimes what crackers do to cover their tracks π), sac prints an approximate time stamp along with the alert. forensic queen behavior.--versionβ outputs the version of sac. that's it, that's the whole thing.-w [wtmp-list|-]β picks a different input file (or files) instead of the default (/var/log/wtmp). heads up tho: the accounting file type is decided by whatever options you used before-wgets reached. order matters, bestie.-dβ lists login time per day instead of the default total time.-pβ lists login time per user instead of the default total time.-tβ lists login time per tty line instead of the default total time.-Uβ lists simultaneous usage levels π₯. it shows the amount of time at each usage level (usage level = number of ttys used simultaneously) plus the number of accountable hours (that's time * usage level) at each usage level.-rβ prints almost everything sac knows about yourwtmpfile. time gets displayed in seconds. the Hourmask is a 24 bit field representing which hours accounting was performed on (zero means no mask used). the format is fairly obvious. useful as a back-end to some accounting package or for graphing usage. quite verbose, ngl.-aβ prints average information.-hβ prints hourly profile information.-lβ prints login listing information.-cβ performs login "clipping". multiple logins during the same time period only count once. lowkey a glow-up for your numbers β¨-I H[:M[:S]]β ignores a specific amount of login time for each user before doing accounting. β οΈ only works with the-poption, no cap.--secondsβ displays time in seconds.--hmsβ displays time in Hours:Minutes:Seconds format.--hmβ displays time in Hours:Minutes format. seconds get rounded off.--hoursβ displays time in hours only format. minutes and seconds get rounded off.--roundβ rounds the displayed time to the nearest minute when you're using--hm, or to the nearest hour when you're using--hours.--longdateβ displays dates in long notation (weekday, month, day and four digit year). very main character of the dates π-oβ reads thewtmpfile as if it were an old style BSDwtmpfile (that's the oldutmpformat, which doesn't use theut_typefield). programs like tacacs keep awtmpfile that doesn't use all the fields, so yeah.-Sβ attempts to seek intowtmpto the day specified by the-soption (-s MM/DD/YY). not guaranteed to work π« . if the seek fails, it'll try to rewind input to the beginning and continue normally. useful for seeing last day's usage from a largewtmpfile.-X[3]β reads awtmpfile maintained by xtacacs, that's terminal server access control software, versions 3.4 and 3.5.-X4β reads awtmpfile maintained by xtacacs version 4.0.-iβ includes hostname information when trying to determine logins and logouts. super useful for accurately parsing tacacs accounting logs that merge accounting for multiple terminal servers into the same log. detective mode π-R portmaster/pattern-listβ reads and processes the detail files maintained by the Radius access control software for terminal servers. sac will process each detail file in/usr/adm/radacct/<portmaster-name>/detail, each in turn, until all the detail files have been processed. if no portmaster name is given, a detail file must be specified with the-woption. if a wildcard pattern is given, sac will try to find all portmaster directories in the radacct directory that match the pattern. and yes, a detail file may be specified with-win addition to-R.-Dβ when processing radius logs, this says sac should use the@hostnamepart ofuser@hostnamefor the hostname field instead of portmaster's hostname. handy for-Hfiltering when you're working with radius logs.-Pβ performs packet and octet accounting when reading from a detail file that logs packet and octet information (i.e. Ascend terminal servers).-b hours[:minutes[:seconds]]β considers only thoseutmpentries that fall within the last few hours/minutes/seconds from the current time, and disregards the rest. useful for figuring out if someone's been on in the last few hours π-s startβ selects the starting date of the report.-e endβ selects the ending date of the report.-M hour-range[,...]]β selects only specific hours in a day to perform accounting on, instead of all the hours in the day. the hour-range format is:(0-23)[-(0-23)[,hour-range[,...]]]. and the hour given applies to the whole hour, so a range of"5-6"is a time range from 5am to 6:59:59am. no sneaky half-hours, bestie.-fβ performs ftp login accounting in addition to normal shell accounting.-Fβ performs ftp login accounting only.-mβ shows minimum and maximum number of concurrent logins over the total time span, or per day/per user when used with the-d/-poption.-u user-listβ selects only those users to perform accounting on.-x user-listβ selects those users to not perform accounting on. begone π«-T tty-listβ selects those ttys to perform accounting on. each tty specifier may be a wildcard.-H host-listβ selects those hosts to perform accounting on. each host specifier may be a wildcard.
πΈ FILES πΈ
/var/log/wtmpβ login database/usr/adm/radacct/.../detailβ Radius accounting logs
π AUTHOR π
Steve Baker (ice@mama.indstate.edu) β the icon, the legend π
π BUGS π
ngl bestie, this section is long and it's all real, so buckle up:
- The documentation for
wtmpis lacking. it's not clear at all what all gets put inwtmpor the significance of any of it. the docs really said "figure it out" π - The
-oand-Xoptions handle what is a login and what is a logout differently than normally (because there's nout_typefield), which makes sac incorrectly identify xterm log-outs as a login. (xterm doesn't write a "login" entry, only a "logout" entry that looks just like a login in all respects save the contents of theut_typefield.) it should also be noted thatlastincorrectly handles xterm log-outs as well. so it's not just us π«Ά - The
-for-Foptions should not be used with-o,-X[3|4]or-Roptions, because sac will default back to a normalutmpformat, or ignore the-for-Fdirectives depending on where they occur on the command line. order-dependent chaos, fr fr. - Using the
-Soption will cause sac to skip over accounting information which may well apply to the days you are inspecting π¬. the only sure way to get all the accounting information is to start at the beginning, or at least a day before the start you're interested in. - The
-moption does not accurately report true min/max usage when inspecting more than one logfile if those logfiles overlap the same time range. - The
-Uoption may report incorrect amounts of time when compared to the-toption. as yet, the author has no idea why. it's giving mystery β¨ - Sac (probably) only handles changes in time logged in the
wtmpfile made by netdate. Rdate does not log time changes. - Clipping can affect the output of the average option, as described above. Radius accounting uses
Acct-Session-Timeto determine usage when a stop record has no start record. clipping will not function correctly when there are missing start records. - The
ut_addrfield doesn't seem to be consistently used by all programs, so it can't be used for exact host-name filtering. even if it were, it would be too much work for this lazy programmer anyway π honestly? relatable. - Radius detail logs suck. there is not one standard radius detail file format. sac is not guaranteed to work with your detail file. if you suspect sac's output is not correct, please contact the author at the e-mail address above.
- Null usernames in radius detail logs are represented as
"UNKNOWN"by sac, which may be a valid username. yes, that's as confusing as it sounds. - Too much accounting results in big brother... citizen. π
π¦ SEE ALSO π¦
ac(1), last(1), rawtmp(1), wtmp(5), netdate(8L)
and that's the whole page, bestie π this lil masterpiece lives in the UNIX Manual as SAC(8) β go forth and account responsibly, and remember: the vibe is immaculate but the bugs are real. mwah πβ¨
π¦ where this page comes from
- ubuntu jammy: sac 1.9b5-3build1
- Copyright (c) 1995 - 2000 by Steve Baker (ice@mama.indstate.edu)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms