528d1000390a1e887f1a634819ac3902244643cf
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, _shape, _state) {
18 _state = child2state[v]
21 } else if (_state == "I") {
23 } else if (_state == "R") {
25 } else if (_state == "S") {
27 } else if (_state == "T") {
29 } else if (_state == "t") {
31 } else if (_state == "Z") {
42 _color == COLORSCHEME_MAX || _color == COLORSCHEME_MIN \
43 ? sprintf("/%s/%d", COLORSCHEME, COLORSCHEME_MID) \
44 : sprintf("/%s/%d", "greys9", 9)
49 , style=\"filled,solid\" \
50 , fontname=Helvetica \
53 , fillcolor=\"/%s/%d\" \
66 function edge_print(child, _parent, _color, _colorscheme) {
67 _parent = child2parent[child]
68 _colorscheme = COLORSCHEME
69 _color = COLORSCHEME_MID
73 , fontname=Helvetica \
86 # Hot->Cold gradual colorschemes:
91 # Light->Dark gradual colorschemes:
102 COLORSCHEME = sprintf("rdylgn%d", COLORSCHEME_MAX)
104 child2comm[0] = "swapper/sched"
108 parent2child_count[$2]++
110 parent2child_count[$2] > max_children\
111 ? parent2child_count[$2]\
113 child2parent[$1] = $2
114 child2user_id[$1] = $3
115 child2user_name[$1] = $4
123 print "strict digraph G {";
127 print "fontname=Helvetica;";
128 print "label=\"" kernel "\";";
129 print "fontcolor=\"/greys9/9\";"
131 ##### Vertices (clustered by user)
132 for (user_name in user_names) {
133 printf "subgraph \"cluster_%s\" {\n", user_name
134 printf "label=\"%s\"\n", user_name
135 for (c in child2parent)
136 if (child2user_name[c] == user_name)
141 ##### Vertices (without a user)
142 for (c in child2comm)
143 if (!child2user_name[c])
146 ##### Edges (across clusters)
147 for (c in child2parent)
157 if [ "$(uname)" = 'Linux' ]; then
158 ps
-eo 'pid,ppid,euid,euser,nice,s,comm'
160 ps
-eco 'pid,ppid,euid,euser,nice,s,comm'
169 *) procs |
grep "$1" | compile
This page took 0.072899 seconds and 3 git commands to generate.