I'm using Ubuntu 20.04. I'm trying to get IO and BlockIO for the postgres process (and all its children).
`systemctl status [email protected]`
shows memory and CPU time used, but not IO:
[email protected] - PostgreSQL Cluster 14-main
Loaded: loaded (/lib/systemd/system/[email protected]; enabled-runtime; >
Active: active (running) since Tue 2021-12-14 17:13:19 WET; 2min 21s ago
Process: 1285 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 14>
Main PID: 1395 (postgres)
Tasks: 11 (limit: 37513)
Memory: 263.2M
CPU: 32.372s
CGroup: /system.slice/system-postgresql.slice/[email protected]
├─1395 /usr/lib/postgresql/14/bin/postgres -D /var/lib/postgresql/>
├─1442 postgres: 14/main: checkpointer
├─1444 postgres: 14/main: background writer
├─1445 postgres: 14/main: walwriter
├─1446 postgres: 14/main: autovacuum launcher
├─1447 postgres: 14/main: stats collector
├─1448 postgres: 14/main: TimescaleDB Background Worker Launcher
├─1449 postgres: 14/main: logical replication launcher
├─1450 postgres: 14/main: TimescaleDB Background Worker Scheduler
├─1453 postgres: 14/main: TimescaleDB Background Worker Scheduler
└─5990 postgres: 14/main: postgres tsenergydata 127.0.0.1(55312) I>
First, I tried the following:
- Under
/etc/systemd/system.conf
, I set the IO Accounting options to
yes:
DefaultIOAccounting=yes
DefaultBlockIOAccounting=yes
- and then reboot the system.
However, it does not seem to make a difference. The IO is not shown.
Then, I've tried systemctl --all --full show [email protected]
:
- The output actually does show values for I/O:
IOReadBytes=18446744073709551615
IOReadOperations=18446744073709551615
IOWriteBytes=18446744073709551615
IOWriteOperations=18446744073709551615
- However, these values do not seem to make any sense (seems to be in the petabyte region). I've done nothing but start up postgres. This can't generate anywhere close so much IO, surely. Moreover, the values for reads, writes and operations are all identical, which seems suspicious.
- The values shown by
systemctl show
for CPU and memory are identical to the values shown using the systemctl status
command. So not all values are off the charts.
Is there a way to get the IO of a particular service (even if that service uses multiple processes)?
I'm looking for something more straightforward than looping through proc/$pid/io
and adding up the read/writes for each related process.