https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi37V2axu15achqcnYKZD35L_a_p6NPuQ2nMO7nOnqDpi-XsSk9jgPfFAH_wQ7zvRH9p0OipdVoVZqG9Dsh5ki6joHBgiVU7OrOCCWktTt4xcxeHFNxYL_RjtFXynZF6YAaQuYvfr2EFjE/s800-Ic42/all-but-current.png

Just thought I could make one like this. You can use pstree to get a text-version in tree style:

init-+-acpid
     |-agetty
     |-at-spi-bus-laun-+-dbus-daemon
     |                 |-{dconf worker}
     |                 |-{gdbus}
     |                 `-{gmain}
     |-at-spi2-registr---{gdbus}
     |-cdm---xinit-+-X---{X}
     |             `-dwm
     |-cron
     |-2*[dbus-daemon]
     |-dbus-launch
     |-dzen-status-+-dzen2
     |             `-{threaded-ml}
     |-ntpd---ntpd
     |-pppd
     |-pulseaudio-+-{alsa-sink-STAC9}
     |            `-{alsa-source-STA}
     |-syslog-ng---syslog-ng
     |-systemd-udevd
     |-tmux-+-bash---vim
     |      |-bash
     |      `-bash---pstree
     `-urxvtd-+-bash
              `-tmux

Here are the codes:

cat /proc/*/status | awk '
BEGIN {printf("graph G {\n")}
/Name/ {name = $2}
/^Pid/ {pid = $2}
/PPid/ {
  if (PROCINFO["ppid"] != $2) {
    printf("p%d [label = \"%s\"]\n", pid, name);
    if ($2 != 0)
      printf("p%d -- p%d\n", pid, $2);
    }
  }
END {printf("}")}' | circo -T png -o test.png

It outputs all process except the current processes (cat/awk/circo). You can use if ('$$' != $2) { to replace the checking code, $$ is the current Bash shell’s process ID, which is Awk’s parent process ID. Note that part is actually being processed in Bash not Awk. The Awk code pauses before $$, then continues after.

Next one hide the kernel threads:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNCA3An8_h4TLQWNLbtguHuD1BQ8s0c3GFGcEQOiTllXbDKR6D1amx3lXBR_hrxuIL0RPXfzxXkVrbWK1rrp5OF74Iy2TlN6meA9OsySZHISR7YlHw8FVbMHKbAkNXdM32mViDrfOs70Q/s800-Ic42/only-kernel.png
cat /proc/*/status | awk '
BEGIN {printf("graph G {\n")}
/Name/ {name = $2}
/^Pid/ {pid = $2}
/PPid/ {
  if ($2 == 2 || pid == 2) {
    printf("p%d [label = \"%s\"]\n", pid, name);
    if ($2 != 0)
      printf("p%d -- p%d\n", pid, $2);
    }
  }
END {printf("}")}' | circo -T png -o test.png

I am not sure if all kernel threads are with PID #2, but it works for me. And if those children had children, then this code will work probably.

The last one only show kernel threads:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVykZ5Ar8xCTCeRFEUBgp5DttIEWK0oB__cBeOa_NlIvjnPm9VwEGZkdxWXxs8liGzX4cPannk000fjRcmSYN7p2CkRB-2LnlNuP0oVS2G6SealyjXJkwSHzft73FV4ac4R-yDEohYyuU/s800-Ic42/no-kernel.png
cat /proc/*/status | awk '
BEGIN {printf("graph G {\n")}
/Name/ {name = $2}
/^Pid/ {pid = $2}
/PPid/ {
  if ($2 != 2 && pid != 2 && PROCINFO["ppid"] != $2) {
    printf("p%d [label = \"%s\"]\n", pid, name);
    if ($2 != 0)
      printf("p%d -- p%d\n", pid, $2);
    }
  }
END {printf("}")}' | circo -T png -o test.png