An excellent program for monitoring users and applications is psacct. This program will work in the background of your system recording what all users are doing on your system as well as the resources that are being consumed. I use it daily for resource abuse tracking, statistics generation, CPU usage trending, process identification and more.
Since I administer both Ubuntu/Debian and CentOS/RHEL servers, I’ll provide both methods of installation here:
CentOS:
yum install psacct
Ubuntu:
sudo apt-get install acct
The most useful command that now exists on your box is in /usr/bin and called “sa”.
SA has the following output fields:
cpu – sum of system and user time in cpu minutes
re – actual time in minutes
k – cpu-time averaged core usage, in 1k units
k*sec – cpu storage integral (kilo-core seconds)
u – user cpu time in cpu minutes
s – system time in cpu minutes
Start off by allowing process accounting to collect some data from your system. This should really be left for 24-48 hours, though if you’re too excited to start parsing the results, lets continue.
This will show you averages for the all the activity for this server overtime. This log file grows larger over time as more commands run, and the longer you allow it to collect data.
# sa -m
This will show you the sum of the system and user time in cpu minutes for specific commands.
# sa -u | grep username
This will give you a combined total for a specific user:
# sa -u |grep username|awk ‘BEGIN{TOTAL=0}{TOTAL=TOTAL+$2}END{print TOTAL}’
This option will show each of the programs on your server so you may evaluate, real time, memory usage and which programs are running:
# sa -a
Hint: append the “-c” flag to any of the options to view the highest percentile users first.
I know that this can be confusing, and it took myself and my organization some time to master the technology due to the lack of documentation available. I hope this article will also help someone else’s resource management lightbulb illuminate.
Tweet
Leave a Reply