39e8f4f11c0a6ad42b4ce5afbf38395fcfb73551
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, _size, _height, _label, _label_base, _label_ext) {
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") {
50 _color == VERT_COLORSCHEME_MAX || _color == VERT_COLORSCHEME_MIN \
51 ? sprintf("/%s/%d", VERT_COLORSCHEME, VERT_COLORSCHEME_MID) \
52 : sprintf("/%s/%d", "greys9", 9)
55 ? sprintf("/%s/%d", "greys9", 9) \
58 sprintf("%s\n%d", child2comm[v], v)
61 ? sprintf("\ncpu: %.1f%%\nmem: %.1f%%", child2cpu[v], child2mem[v]) \
63 _label = _label_base _label_ext
70 , style=\"filled,solid\" \
71 , fontname=Helvetica \
74 , fillcolor=\"/%s/%d\" \
87 function edge_print(child, _parent) {
88 _parent = child2parent[child]
92 , fontname=Helvetica \
103 # Hot->Cold gradual colorschemes:
107 # - rdylgn10 # 3 - 11
109 # Light->Dark gradual colorschemes:
117 VERT_COLORSCHEME_MIN = 1
118 VERT_COLORSCHEME_MID = 4
119 VERT_COLORSCHEME_MAX = 8
120 VERT_COLORSCHEME = "rdylgn10"
122 EDGE_COLOR = "/ylorbr9/3"
124 child2comm[0] = "swapper/sched"
128 parent2child_count[$2]++
130 parent2child_count[$2] > max_children\
131 ? parent2child_count[$2]\
133 child2parent[$1] = $2
134 child2user_id[$1] = $3
135 child2user_name[$1] = $4
142 max_cpu = $7 > max_cpu ? $7 : max_cpu
143 max_mem = $8 > max_mem ? $8 : max_mem
147 print "strict digraph G {";
151 print "fontname=Helvetica;";
152 print "label=\"" kernel "\";";
153 print "fontcolor=\"/greys9/9\";"
155 ##### Vertices (clustered by user)
156 for (user_name in user_names) {
157 printf "subgraph \"cluster_%s\" {\n", user_name
158 printf "label=\"%s\"\n", user_name
159 for (c in child2parent)
160 if (child2user_name[c] == user_name)
165 ##### Vertices (without a user)
166 for (c in child2comm)
167 if (!child2user_name[c])
170 ##### Edges (across clusters)
171 for (c in child2parent)
181 if [ "$(uname)" = 'Linux' ]; then
182 ps
-eo 'pid,ppid,euid,euser,nice,s,%cpu,%mem,comm'
184 ps
-eco 'pid,ppid,euid,euser,nice,s,%cpu,%mem,comm'
193 *) procs |
grep "$1" | compile
This page took 0.09788 seconds and 3 git commands to generate.