User Tools

Site Tools


ubuntu:systemd:accounting

Ubuntu - SystemD - Accounting

Systemd allows you to check how much CPU and Memory is used by a service and how many tasks are running by the service.

  • Many recent Linux distros enable accounting by default.
  • On old Linux distros like Ubuntu 18.04, you need to manually enable accounting.

Example

To enable accounting for Nginx on Ubuntu 18.04.

Create a directory to store the custom systemd configuration for this service

sudo mkdir -p /etc/systemd/system/nginx.service.d/

Create the custom config file under this directory

sudo vi /etc/systemd/system/nginx.service.d/custom.conf

NOTE: The filename extension must be .conf.

…add the following lines in this file.

[Service]
CPUAccounting=true
MemoryAccounting=true
TasksAccounting=true

Reload systemd

sudo systemctl daemon-reload

NOTE: There is no need to restart Nginx.


Check Nginx status

systemctl status nginx

NOTE: This should show Tasks, Memory and CPU information.

ubuntu/systemd/accounting.txt · Last modified: 2023/06/03 10:30 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki