Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xcheckrestart: reports docker/podman processes #302

Open
usagi-flow opened this issue May 21, 2023 · 1 comment
Open

xcheckrestart: reports docker/podman processes #302

usagi-flow opened this issue May 21, 2023 · 1 comment

Comments

@usagi-flow
Copy link

It would seem like xcheckrestart reports processes which run in a container, but are not/never were installed on the host system:

$ xbps-query -s postgre (reports nothing)

$ xcheckrestart:

22684 /usr/local/bin/postgres ()
22691 /usr/local/bin/postgres ()
22998 /usr/local/bin/postgres ()
22999 /usr/local/bin/postgres ()
23007 /usr/local/bin/postgres ()
23008 /usr/local/bin/postgres ()
23016 /usr/local/bin/postgres ()
23017 /usr/local/bin/postgres ()
23018 /usr/local/bin/postgres ()
23027 /usr/local/bin/postgres ()
23028 /usr/local/bin/postgres ()
23048 /usr/local/bin/postgres ()
23049 /usr/local/bin/postgres ()
23050 /usr/local/bin/postgres ()
23441 /usr/local/bin/postgres ()
23442 /usr/local/bin/postgres ()
2667 /usr/local/bin/postgres ()
28263 /usr/local/bin/postgres ()
32512 /usr/local/bin/postgres ()
4953 /usr/local/bin/postgres ()
4955 /usr/local/bin/postgres ()
5031 /usr/local/bin/postgres ()
5032 /usr/local/bin/postgres ()
5033 /usr/local/bin/postgres ()
5949 /usr/local/bin/postgres ()
751 /usr/local/bin/postgres ()
752 /usr/local/bin/postgres ()

Idea

Maybe we could inspect /proc/<pid>/cgroup for each process before printing them out, and avoid printing them if the cgroup paths are not "/", as in this example:
$ cat /proc/752/cgroup:

12:name=systemd:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
11:pids:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
10:net_prio:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
9:perf_event:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
8:net_cls:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
7:freezer:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
6:devices:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
5:memory:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
4:blkio:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
3:cpuacct:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
2:cpu:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
1:cpuset:/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67db
0::/docker/2c4f7ce9f2c04ed0892c8bfe8d68e23804243a23f9834dd742ad3addf8ed67d

On the host, I would expect non-containerized processes to output something like this:
$ cat /proc/1/cgroup:

12:name=systemd:/
11:pids:/
10:net_prio:/
9:perf_event:/
8:net_cls:/
7:freezer:/
6:devices:/
5:memory:/
4:blkio:/
3:cpuacct:/
2:cpu:/
1:cpuset:/
0::/

The downside might be a performance hit...

PS: Thank you for this wonderful collection of tools!

@leahneukirchen
Copy link
Owner

I think a better check is test /proc/$pid/root -ef /

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants