2010年(9)
分类: LINUX
2010-06-01 17:42:20
from "How to keep a detailed audit trail of what’s being done on your Linux systems"
The psacct package contains several utilities for monitoring process activities, including ac, lastcomm, accton and sa.
Use sa command to print summarizes information about previously executed commands. In addition, it condenses this data into a summary file named savacct which contains the number of times the command was called and the system resources used. The information can also be summarized on a per-user basis; sa will save this iinformation into a file named usracct.# sa
Output:
579 222.81re 0.16cp 7220k 4 0.36re 0.12cp 31156k up2date 8 0.02re 0.02cp 16976k rpmq 8 0.01re 0.01cp 2148k netstat 11 0.04re 0.00cp 8463k grep 18 100.71re 0.00cp 11111k ***other* 8 0.00re 0.00cp 14500k troff 5 12.32re 0.00cp 10696k smtpd 2 8.46re 0.00cp 13510k bash 8 9.52re 0.00cp 1018k less
Take example of first line:4 0.36re 0.12cp 31156k up2date
Where,
Display output per-user:# sa -u
Output:
root 0.00 cpu 595k mem accton root 0.00 cpu 12488k mem initlog root 0.00 cpu 12488k mem initlog root 0.00 cpu 12482k mem touch root 0.00 cpu 13226k mem psacct root 0.00 cpu 595k mem consoletype root 0.00 cpu 13192k mem psacct * root 0.00 cpu 13226k mem psacct root 0.00 cpu 12492k mem chkconfig postfix 0.02 cpu 10696k mem smtpd vivek 0.00 cpu 19328k mem userhelper vivek 0.00 cpu 13018k mem id vivek 0.00 cpu 13460k mem bash * lighttpd 0.00 cpu 48240k mem php *
Display the number of processes and number of CPU minutes on a per-user basis# sa -m
Output:
667 231.96re 0.17cp 7471k root 544 51.61re 0.16cp 7174k vivek 103 17.43re 0.01cp 8228k postfix 18 162.92re 0.00cp 7529k lighttpd 2 0.00re 0.00cp 48536k