On any server it’s important to have the most information as possible on what’s going on in real time with tools as pidstat and glances, but it’s also important to collect all the activity done by all the users and processes that are running, to analyze them at a later time or in case of problems of any kind (performance, security, capacity).
psaact as well as
acct are both open source application that are used for monitoring user activity on a system. They run in the background keeping track of user activity on a system and the resources consumed by services such as MySQL, Apache, FTP, SSH, et al.
Now with these applications one will be able to track not only user activity, but that of all administrators as well that is performed on a particular server. Consequently, you can make use of this program to know what your users are doing at any given point in time and know what commands they are using as well as be aware of how long it is they are spending on a server.
The psacct or acct package has many features that make it suitable for observing process activities.
- The ac command is used for printing user login/logout (connect time) statistics in hours.
- The sa command is used for summarizing information about previously executed command.
- The lastcomm command is used for printing information about commands previously executed by user.
- The last and lastb commands show the listing of users that last logged in.
- The accton command is used in the turning on/off process for accounting.
How to Install psacct or acct Packages
Both psacct and acct packages are similar. The difference between these two isn’t much. However, the psacct package is available only for rpm based distributions like RHEL, Fedora, CentOs, while the acct package is available for deb distribution such as Linux Mint, Ubuntu as well as Debian.
In order for one to be able to install the psacct package under the rpm based distribution the following yum command is required:
# yum install psacct
On the other hand, to be able to carry out
acct installation making use of the apt-get command under Linux Mint/Ubuntu/Debian the following command is required:
# apt-get install acct
$ sudo apt-get install acct
Starting psacct or acct
psacct service by default is disabled. So there is a need for you to manually start it under the RHEL, Fedora, CentOs systems. You can make use of the following command in order to confirm service status:
# /etc/init.d/psacct status Process accounting is disabled.
Now from the foregoing you can see that the status displayed shows that it is disabled.
To start it at boot time use the
chkconfig command, while to start it manually you will make use of the init script.
Both commands will produce a /var/account/pact file plus start services, but
chkconfig will require a reboot.
The commands are:
# chkconfig psacct on # /etc/init.d/psacct start Starting process accounting: [OK]
Once service has begun, you can verify the status again, if the service is running the following message will be displayed to confirm enabled status:
# /etc/init.d/psacct status Process accounting is enabled.
Regarding Mint, Ubuntu and Debian service starts automatically and you do not need to restart.
Display Statistics about User Connect Time
In order to display total connect time statistics in hours (this is based on user login/logout of current wtmp file) there will be no need to specify any argument with
ac command. This goes as follows:
# ac total 1112.04
Or if you prefer to have a breakdown of every day you can use the option -d:
$ ac -d Feb 1 total 80.12 Feb 2 total 50.60 Feb 3 total 130.21 Feb 4 total 60.44 Feb 5 total 90.30 Feb 6 total 60.10 Feb 7 total 100.20 ...
Or you can use the option -p to have the total for each uase with an output similar to this:
... linuxaria 57.11 root 20.63 total 77.64
Lastly, as noted earlier there are other statistics that can be monitored using psacct as well as acct tools. This includes daily use statistics, list of the last commands executed by user among others.
The article is being authored by Jason Phillips. He is a very experienced writer and an enthusiast. He is really talented writer who wrote about user activity monitoringsoftware.
- Natron an open source compositing software for linux.
- Yum and repository tools by examples
- Linux Games: Natural Selection 2
Find me on Google+