psacct or acct both are open source application for monitoring users activities on the system. These applications runs in the background and keeps track of each users activity on your system as well as what resources are being consumed.
I personally used this program in our company, we have development team where our developers continuously work on servers. So, this is one of best program to keep a eye on them. This program provides an excellent way to monitor what users are doing, what commands are they firing, how much resources are being consumed by them, how long users are active on the system. Another great feature of this program is it gives total resources consumed by services like Apache, MySQL, FTP,SSH etc.
I think this is one of the great and must needed application for every Linux/Unix System Administrators, who wanted to keep a track of user activities on their servers/systems.
The psacct or acct package provides several features for monitoring process activities.
- ac command prints the statistics of user logins/logouts (connect time) in hours.
- lastcomm command prints the information of previously executed commands of user.
- accton commands is used to turn on/off process for accounting.
- sa command summarizes information of previously executed commands.
- last and lastb commands show listing of last logged in users.
Installing psacct or acct Packages
psacct or acct both are similar packages and there is not much difference between them, but the psacctpackage only available for rpm based distributions such as RHEL, CentOS and Fedora, whereas acct package available for distributions like Ubuntu, Debian and Linux Mint.
To install psacct package under rpm based distributions issue the following yum command.
To install acct package using apt-get command under Ubuntu / Debian / Linux Mint.
Starting psacct or acct service
By default psacct service is in disabled mode and you need to start it manually under RHEL/CentOS/Fedorasystems. Use the following command to check the status of service.
You see the status showing as disabled, so let’s start it manually using the following both commands. These two commands will create a /var/account/pacct file and start services.
After starting service, check the status again, you will get status as enabled as shown below.
Under Ubuntu, Debian and Mint service is started automatically, you don’t need to start it again.
Display Statistics of Users Connect Time
ac command without specifying any argument will displays total statistics of connect time in hours based on the user logins/logouts from the current wtmp file.
Display Statistics of Users Day-wise
Using command “ac -d” will prints out the total login time in hours by day-wise.
Display Time Totals for each User
Using command “ac -p” will print the total login time of each user in hours.
Display Individual User Time
To get the total login statistics time of user “tecmint” in hours, use the command as.
Display Day-Wise Logn Time of User
The following command will prints the day-wise total login time of user “tecmint” in hours.
Print All Account Activity Information
The “sa” command is used to print the summary of commands that were executed by users.
Where
- 9.86re is a “real time” as per wall clock minutes
- 0.01cp is a sum of system/user time in cpu minutes
- 2466k is a cpu-time averaged core usage, i.e. 1k units
- sshd command name
Print Individual User Information
To get the information of individual user, use the options -u.
Print Number of Processes
This command prints the total number of processes and CPU minutes. If you see continue increase in these numbers, then its time to look into the system about what is happening.
Print Sort by Percentage
The command “sa -c” displays the highest percentage of users.
List Last Executed Commands of User
The ‘latcomm‘ command is used to search and display previously executed user commands information. You can also search commands of individual usernames. For example, we see commands of user (tecmint).
Search Logs for Commands
With the help of the lastcomm command you will be able to view individual use of an each commands.
0 comments:
Post a Comment