c8db891f98cafce46d83f42ab258f2d2dcdded83
4 echo "EXAMPLE (whole tree) : $0 | neato -T png > ps.png && open ps.png"
5 echo "EXAMPLE (user clusters): $0 | sdp -T png > ps.png && open ps.png"
10 awk -v kernel
="$(uname -v)" -v whoami
="$(whoami)" \
12 function num_scale(src_cur, src_max, dst_min, dst_max) {
13 return dst_min + ((src_cur * (dst_max - dst_min)) / src_max)
16 function vert_print(v, _color, _fontcolor) {
25 _color == COLORSCHEME_MAX || _color == COLORSCHEME_MIN \
26 ? sprintf("/%s/%d", COLORSCHEME, COLORSCHEME_MID) \
27 : sprintf("/%s/%d", "greys9", 9)
32 , fontname=Helvetica \
47 function edge_print(child, _parent, _color, _colorscheme) {
48 _parent = child2parent[child]
49 _colorscheme = "greys9"
54 , fontname=Helvetica \
67 # Hot->Cold gradual colorschemes:
72 # Light->Dark gradual colorschemes:
83 COLORSCHEME = sprintf("rdbu%d", COLORSCHEME_MAX)
85 child2cmd[0] = "swapper/sched"
89 parent2child_count[$2]++
91 parent2child_count[$2] > max_children\
92 ? parent2child_count[$2]\
95 child2user_id[$1] = $3
96 child2user_name[$1] = $4
103 print "strict digraph G {";
107 print "fontname=Helvetica;";
108 print "label=\"" kernel "\";";
109 printf "colorscheme=%s;\n", COLORSCHEME
112 ##### Vertices (clustered by user)
113 for (user_name in user_names) {
114 printf "subgraph \"cluster_%s\" {\n", user_name
115 printf "label=\"%s\"\n", user_name
116 for (c in child2parent)
117 if (child2user_name[c] == user_name)
122 ##### Vertices (without a user)
124 if (!child2user_name[c])
127 ##### Edges (across clusters)
128 for (c in child2parent)
138 if [ "$(uname)" = 'Linux' ]; then
139 ps
-eo 'pid,ppid,euid,euser,nice,comm'
141 ps
-eco 'pid,ppid,euid,euser,nice,comm'
150 *) procs |
grep "$1" | compile
This page took 0.065771 seconds and 3 git commands to generate.