Graphical representation of parent/child processes (pstree)¶
The pstree program provides a graphical representation of parent and child processes, number of threads, their states, etc.
Options provided by ‘pstree’:
crash> pstree -h
Usage: pstree [options]
Options:
-h, --help show this help message and exit
-p Print process ID
-g Print number of threads
-s Print task state
-t TASK_ID Print specific task and its children
** Execution took 1.13s (real) 1.13s (CPU)
crash>
Print process ID (-p)¶
The'-p' option displays a graphical representation of all the processes and their child processes:
crash> pstree -p
swapper/0(0) -+- systemd(1) -+- systemd-journal(4578)
| |- lvmetad(4614)
| |- systemd-udevd(4618)
| |- multipathd(4624)
| |- auditd(5670) -+- audispd(5672) -+- sedispatch(5674)
| |- alsactl(5695)
| |- smartd(5696)
| |- lsmd(5698)
| |- avahi-daemon(5699) -+- avahi-daemon(5703)
| |- rtkit-daemon(5700)
| |- rngd(5702)
| |- accounts-daemon(5706)
| |- rsyslogd(5707)
| |- ModemManager(5709)
| |- polkitd(5710)
| |- systemd-logind(5711)
| |- abrtd(5714)
| |- abrt-watch-log(5718)
| |- abrt-watch-log(5720)
| |- irqbalance(5725)
| |- dbus-daemon(5728)
| |- gssproxy(5738)
| |- firewalld(5770)
| |- ksmtuned(5773) -+- sleep(11584)
| |- mcelog(5779)
| |- chronyd(5781)
| |- NetworkManager(5788) -+- dhclient(5912)
| |- sshd(6106) -+- sshd(6777) -+- bash(6792)
| | |- sshd(6824) -+- bash(6830) -+- journalctl(11478)
| | |- sshd(6862) -+- bash(6868)
| | |- sshd(6900) -+- bash(6906)
| | `- sshd(6938) -+- bash(6952)
| |- cupsd(6107)
| |- tuned(6108)
| |- rhsmcertd(6117)
| |- libvirtd(6119)
| |- gdm(6129) -+- X(6581)
| | `- gdm-session-wor(6593) -+- gnome-session-b(6597) -+- gnome-shell(6622) -+- ibus-daemon(6666) -+- ibus-dconf(6692)
| | | `- ibus-engine-sim(6729)
| | `- gnome-settings-(6685)
| |- crond(6130)
| |- atd(6131)
| |- rhnsd(6204)
| |- dnsmasq(6443) -+- dnsmasq(6444)
| |- master(6506) -+- pickup(6507)
| | `- qmgr(6508)
| |- dbus-daemon(6604)
| |- dbus-launch(6603)
| |- at-spi-bus-laun(6607) -+- dbus-daemon(6612)
| |- at-spi2-registr(6614)
[...]
Print number of threads (-g)¶
As marked in the example below, the '-g' option can be used to check the number of threads associated with each process:
crash> pstree -g
swapper/0 -+- systemd -+- systemd-journal
| |- lvmetad
| |- systemd-udevd
| |- multipathd---31*[{multipathd}] <-------- 31 threads
| |- auditd -+- audispd -+- sedispatch
| |- alsactl
| |- smartd
| |- lsmd
| |- avahi-daemon -+- avahi-daemon
| |- rtkit-daemon---2*[{rtkit-daemon}] <-------- 2 threads
| |- rngd
| |- accounts-daemon---2*[{accounts-daemon}]
| |- rsyslogd---2*[{rsyslogd}]
| |- ModemManager---2*[{ModemManager}]
| |- polkitd---5*[{polkitd}]
| |- systemd-logind
| |- abrtd
| |- abrt-watch-log
| |- abrt-watch-log
| |- irqbalance
| |- dbus-daemon
| |- gssproxy---5*[{gssproxy}]
| |- firewalld
| |- ksmtuned -+- sleep
| |- mcelog
| |- chronyd
| |- NetworkManager---2*[{NetworkManager}] -+- dhclient
| |- sshd -+- sshd -+- bash
| | |- sshd -+- bash -+- journalctl
| | |- sshd -+- bash
| | |- sshd -+- bash
| | `- sshd -+- bash
| |- cupsd
| |- tuned---4*[{tuned}]
| |- rhsmcertd
| |- libvirtd---15*[{libvirtd}]
| |- gdm---3*[{gdm}] -+- X
| | `- gdm-session-wor---2*[{gdm-session-wor}] -+- gnome-session-b---3*[{gnome-session-b}] -+- gnome-shell---6*[{gnome-shell}] -+- ibus-daemon---2*[{ibus-daemon}] -+- ibus-dconf---3*[{ibus-dconf}]
| | | `- ibus-engine-sim---2*[{ibus-engine-sim}]
| | `- gnome-settings----4*[{gnome-settings-}]
| |- crond
| |- atd
| |- rhnsd
| |- dnsmasq -+- dnsmasq
| |- master -+- pickup
| | `- qmgr
| |- dbus-daemon
| |- dbus-launch
| |- at-spi-bus-laun---3*[{at-spi-bus-laun}] -+- dbus-daemon
| |- at-spi2-registr---2*[{at-spi2-registr}]
[...]
Print task state (-s)¶
The '-s' option shows a graphical representation of parent and child processes along with their states:
crash> pstree -s
swapper/0[RU] -+- systemd[IN] -+- systemd-journal[IN]
| |- lvmetad[IN]
| |- systemd-udevd[IN]
| |- multipathd[IN]
| |- auditd[IN] -+- audispd[IN] -+- sedispatch[IN]
| |- alsactl[IN]
| |- smartd[IN]
| |- lsmd[IN]
| |- avahi-daemon[IN] -+- avahi-daemon[IN]
| |- rtkit-daemon[IN]
| |- rngd[IN]
| |- accounts-daemon[IN]
| |- rsyslogd[IN]
| |- ModemManager[IN]
| |- polkitd[IN]
| |- systemd-logind[IN]
| |- abrtd[IN]
| |- abrt-watch-log[IN]
| |- abrt-watch-log[IN]
| |- irqbalance[IN]
| |- dbus-daemon[IN]
| |- gssproxy[IN]
| |- firewalld[IN]
| |- ksmtuned[IN] -+- sleep[IN]
| |- mcelog[IN]
| |- chronyd[IN]
| |- NetworkManager[IN] -+- dhclient[IN]
| |- sshd[IN] -+- sshd[IN] -+- bash[IN]
| | |- sshd[IN] -+- bash[IN] -+- journalctl[IN]
| | |- sshd[IN] -+- bash[RU]
| | |- sshd[IN] -+- bash[IN]
| | `- sshd[IN] -+- bash[IN]
| |- cupsd[IN]
| |- tuned[IN]
| |- rhsmcertd[IN]
| |- libvirtd[IN]
| |- gdm[IN] -+- X[IN]
| | `- gdm-session-wor[IN] -+- gnome-session-b[IN] -+- gnome-shell[IN] -+- ibus-daemon[IN] -+- ibus-dconf[IN]
| | | `- ibus-engine-sim[IN]
| | `- gnome-settings-[IN]
| |- crond[IN]
| |- atd[IN]
| |- rhnsd[IN]
| |- dnsmasq[IN] -+- dnsmasq[IN]
| |- master[IN] -+- pickup[IN]
| | `- qmgr[IN]
| |- dbus-daemon[IN]
| |- dbus-launch[IN]
| |- at-spi-bus-laun[IN] -+- dbus-daemon[IN]
| |- at-spi2-registr[IN]
[...]
Print specific task and its children (-t)¶
The '-t' option can be used with the above options to print the details about a specific process and its child processes only:
e.g using '-t' with '-s' option to print process states:
crash> pstree -t 6106 -s
sshd[IN] -+- sshd[IN] -+- bash[IN]
|- sshd[IN] -+- bash[IN] -+- journalctl[IN]
|- sshd[IN] -+- bash[RU]
|- sshd[IN] -+- bash[IN]
`- sshd[IN] -+- bash[IN]
Total 12 tasks printed
** Execution took 0.01s (real) 0.02s (CPU)
crash>
with '-p' option to print only process IDs:
crash> pstree -t 6106 -p
sshd(6106) -+- sshd(6777) -+- bash(6792)
|- sshd(6824) -+- bash(6830) -+- journalctl(11478)
|- sshd(6862) -+- bash(6868)
|- sshd(6900) -+- bash(6906)
`- sshd(6938) -+- bash(6952)
Total 12 tasks printed
** Execution took 0.01s (real) 0.01s (CPU)
crash>