Can't jcmd, jps or jstat cassandra process within the docker container - linux

$ jcmd -l
418 sun.tools.jcmd.JCmd -l
$ jstat -gcutil -t 10 250ms 1
10 not found
I am aware of the bug in jdk related to attaching jstat as root to a process running as a different user.
Here, this docker container has one user root and as can be seen below from the ps command, cassandra is running under root.
$ whoami
root
I have tried to do the following:
$ sudo -u root jcmd -l
Any help is appreciated.
Docker container is debian:jessie
running java version:
openjdk version "1.8.0_66-internal"
Here's the output of ps -ef:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 17:40 ? 00:00:00 /bin/bash /run.sh
root 10 1 11 17:40 ? 00:02:25 java -ea -javaagent:/usr/share/c
root 375 0 0 17:49 ? 00:00:00 bash
root 451 375 0 18:00 ? 00:00:00 ps -ef
Aside: jstack successfully dumps out the stack traces of the threads.

I know at least two possible reasons why this can happen.
Java is run with -XX:+PerfDisableSharedMem option. This option helps sometimes to reduce JVM safepoint pauses, but it also makes JVM invisible to jps and jstat. This is a very likely case, because you are running Cassandra, and recent Cassandra has this option ON by default.
Java process has a different mount namespace, so that /tmp of Java process is not physically the same directory as /tmp of your shell. The directory /tmp/hsperfdata_root must be accessible in order to use jps or jstat. This is also a plausible reason since you are using docker containers.

Related

Linux graphics architecture process gfx_0.0.0

When I check graphics process on Ubuntu system. I see gfx_0.0.0 as a process.
ps -ef | grep -i gfx
root 760 2 0 Jan13 ? 00:03:01 [gfx_0.0.0]
I am not running any application but still since system bootup I observe this process.
Can anyone please help me to understand what exactly gfx_0.0.0 process ? How it is getting created?
ps -ef | grep -i gfx
root 760 2 0 Jan13 ? 00:03:01 [gfx_0.0.0]
Trying to understand what is this process and who is creating it and why?

Why some processes(even they are user processes) could not be migrated to a certain cpu by `cpuset(7)`?

Why some processes could not be migrated to a certain cpu by cpuset(7) while some processes could?
I found that these processes could not be really migrated to a certain cpu(Though when you check the cpuset filesystem,it seems ok.But if check the affinity of these processes by top or htop, you could find the cpuset does not work for these processes indeed.):
/sbin/init splash
/usr/sbin/rpc.idmapd
/lib/systemd/systemd-timesyncd
/lib/systemd/systemd-timesyncd
/usr/sbin/cups-browsed
/usr/sbin/sshd -D
/sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf
/var/run/dhclient-
/usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-
sshd: john [priv]
sshd: john [priv]
sshd: john#notty
/usr/lib/openssh/sftp-server
lightdm --session-child 12 15
upstart-file-bridge --daemon --user
/usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
/usr/lib/at-spi2-core/at-spi-bus-launcher
/usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-addre
/usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
/usr/lib/update-notifier/system-crash-notification
/usr/lib/x86_64-linux-gnu/hud/hud-service
/usr/lib/dconf/dconf-service
/usr/lib/x86_64-linux-gnu/indicator-power/indicator-power-service
/usr/lib/x86_64-linux-gnu/indicator-power/indicator-power-service
/usr/lib/x86_64-linux-gnu/indicator-datetime/indicator-datetime-service
/usr/lib/x86_64-linux-gnu/indicator-sound/indicator-sound-service
/usr/lib/x86_64-linux-gnu/indicator-printers/indicator-printers-service
/usr/lib/evolution/evolution-source-registry
/usr/lib/evolution/evolution-source-registry
/usr/lib/colord/colord
/usr/lib/colord/colord
/usr/lib/evolution/evolution-calendar-factory
/usr/bin/gnome-software --gapplication-service
/usr/lib/unity-settings-daemon/unity-fallback-mount-helper
/usr/lib/gvfs/gvfs-udisks2-volume-monitor
/usr/lib/gvfs/gvfs-udisks2-volume-monitor
/usr/lib/udisks2/udisksd --no-debug
/usr/lib/gvfs/gvfs-gphoto2-volume-monitor
/usr/lib/evolution/evolution-calendar-factory-subprocess --factory contacts --bus-name or
zeitgeist-datahub
I think that may because your computer use NUMA model rather than SMP model. This can solve the problem, but I'm not sure if that is the reason.

docker tty command execute display

Run container:
[root#localhost ~]# tty
/dev/pts/3
[root#localhost ~]# docker run -it nginx /bin/bash
root#bee12031f933:/# sleep 20
root#bee12031f933:/#
See:
[root#localhost ~]# tty
/dev/pts/2
[root#localhost ~]# w
17:43:24 up 19 days, 45 min, 5 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN# IDLE JCPU PCPU WHAT
root pts/0 192.168.1.22 16:24 1:01m 0.73s 0.00s sleep 20
root pts/1 192.168.1.22 11:31 1:02m 4.92s 4.65s docker run -it centos:7.7.1908
root pts/2 192.168.1.22 16:31 4.00s 0.70s 0.01s w
root pts/3 192.168.1.22 15:09 4.00s 0.25s 0.07s docker run -it nginx /bin/bash
root pts/4 192.168.1.22 16:41 44.00s 0.06s 0.06s -bash
Example picture:
enter image description here
enter image description here
docker container running in pts/3, execute command in container "sleep 20". then, i execute command "w" on the external host, display command "sleep 20" is executed in pts/0, what's the reason ?
why do external hosts display commands executed in containers ?
docker is similar to how LXC works. It allows sandboxing processes from one another, and controlling their resource allocations.
Since the resources are "separated", the system will show the information based on what it knows.
myuser#localhost: ~ $ tty
/dev/pts/1
myuser#localhost: ~ $ docker run --rm -it ubuntu:18.04 bash
root#36ed505961f4:/# tty
/dev/pts/0
Check the Kernel Namespaces for more info.

how to use procps-3.2.8 in listing all the running processes?

Does anyone know how to use procps-3.2.8 in listing all the running processes of ubuntu/linux?
And how to kill them using procps-3.2.8?
please provide the step-by-step procedure and provide useful links about procps.
procps is the package which contains the many command line utility provided. You can find the complete information about each utility option under the procpcs from the below location:
On the homepage we can get the following information about procps:
procps is the package that has a bunch of small useful utilities that give information about processes using the /proc filesystem. The
package includes the programs ps, top, vmstat, w, kill, free, slabtop,
and skill.*
http://www.linuxfromscratch.org/lfs/view/7.2/chapter06/procps.html
http://procps.sourceforge.net/
How to use procps-3.2.8 in listing all the running processes?
ps is the part of procps package and there are numerous ways to list the all running process(For detailed information do man ps).
mantosh#mantosh4u:~/practice$ ps -V
procps version 3.2.8
mantosh#mantosh4u:~/practice$ ps -AF
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
root 1 0 0 6143 2544 3 14:38 ? 00:00:00 /sbin/init
root 2 0 0 0 0 1 14:38 ? 00:00:00 [kthreadd]
.............................................................................
root 3320 2 0 0 0 0 15:13 ? 00:00:00 [kworker/u:2]
root 3334 2 0 0 0 1 15:18 ? 00:00:00 [kworker/1:0]
How to kill them using procps-3.2.8?
pkill is part of procps package which contains numerous command line option to kill a process. For detailed information man pkill on your terminal.
mantosh#mantosh4u:~/practice$ pkill -V
pkill (procps version 3.2.8)
mantosh#mantosh4u:~/practice$ pkill -f gedit
In the above example, the gedit was the process name which has been killed.

Apache 2.4 hits rlimit_nproc: hidden processes?

My webapp allows users to execute some arbitrary code in a sandbox. To prevent forkbombs, the application calls setrlimit and limits RLIMIT_NPROC to 50 before executing user code. This worked great in Ubuntu 12.04 up till Ubuntu 13.04. However, after upgrading to Ubuntu 13.10 (which ships with Apache 2.4 and Linux 3.11), we hit the limit of 50 www-data processes, even when Apache2 is idle!
The problem is most easily reproduced by running bash as user www-data with ulimit. First switch into user www-data and start bash:
jeroen#Ubuntu:/$ sudo su www-data
$ bash
www-data#Ubuntu:/$
Now gradually lower RLIMIT_NPROC until we hit problems:
#RLIMIT_NPROC=100: works fine
www-data#Ubuntu:/$ ulimit -u 100
www-data#Ubuntu:/$ ls
bin dev initrd.img lib64 mnt root srv usr vmlinuz.old
boot etc initrd.img.old lost+found opt run sys var
cdrom home lib media proc sbin tmp vmlinuz
#RLIMIT_NPROC=50: limit reached
www-data#Ubuntu:/$ ulimit -u 50
www-data#Ubuntu:/$ ls
bash: fork: retry: No child processes
bash: fork: retry: No child processes
bash: fork: Resource temporarily unavailable
Hence after setting RLIMIT_NPROC to 50, the process can no longer fork. This implies that there are already 50 or more processes running as user www-data. However, this does not seem to be the case, the server is just a blank idle Apache 2.4. According to ps, there are currently only 2 procs owned by www-data:
jeroen#Ubuntu:~$ ps aux | grep www-data
www-data 11473 0.0 0.5 631296 46164 ? Sl 14:28 0:01 /usr/sbin/apache2 -k start
www-data 11474 0.0 0.5 565656 45632 ? Sl 14:28 0:01 /usr/sbin/apache2 -k start
jeroen 12136 0.0 0.0 13644 956 pts/4 S+ 14:51 0:00 grep --color=auto www-data
So why is www-data is hitting the RLIMIT_NPROC limit of 50 in Apache 2.4, even when idle?
Found the problem thanks to the suggestion from #sarnold. My Application depends on mpm_prefork and up till Ubuntu 13.04, this module was automatically enabled when the apache2-mpm-prefork package is installed. I assumed this was still the case, but it turned out that it was running mpm_event.
It seems that in Apache 2.4 the packaging of MPM's has changed and mpm_prefork needs to be enabled manually after installation:
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo service apache2 restart
Now the problems seem to have disappeared.

Resources