7 from lttnganalyses
.cli
import mi
10 _TABLE_CLASS_PER_PROC
= 'per-proc'
11 _TABLE_CLASS_PER_SYSCALL
= 'per-syscall'
12 _TABLE_CLASS_PER_IRQ
= 'per-irq'
14 _TABLE_CLASS_PER_PROC
: mi
.TableClass(
15 _TABLE_CLASS_PER_PROC
,
16 'Per-process stuff', [
17 ('proc', 'Process', mi
.Process
),
18 ('count', 'Count', mi
.Integer
, 'things'),
19 ('flag', 'Flag', mi
.Boolean
),
20 ('value', 'Value', mi
.Float
, 'thou'),
21 ('name', 'Name', mi
.String
),
22 ('ratio', 'Ratio', mi
.Ratio
),
23 ('ts', 'Timestamp', mi
.Timestamp
),
26 _TABLE_CLASS_PER_SYSCALL
: mi
.TableClass(
27 _TABLE_CLASS_PER_SYSCALL
,
28 'Per-syscall stuff', [
29 ('syscall', 'System call', mi
.Syscall
),
30 ('duration', 'Duration', mi
.Duration
),
31 ('size', 'Size', mi
.Size
),
32 ('bitrate', 'Bitrate', mi
.Bitrate
),
33 ('time_range', 'Time range', mi
.TimeRange
),
36 _TABLE_CLASS_PER_IRQ
: mi
.TableClass(
38 'Per-interrupt stuff', [
39 ('interrupt', 'Interrupt', mi
.Irq
),
40 ('fd', 'File descriptor', mi
.Fd
),
41 ('path', 'File path', mi
.Path
),
42 ('cpu', 'CPU', mi
.Cpu
),
43 ('disk', 'Disk', mi
.Disk
),
44 ('part', 'Partition', mi
.Partition
),
45 ('netif', 'Network interface', mi
.NetIf
),
51 def _print_metadata():
52 infos
= mi
.get_metadata(version
=[1, 2, 3, 'dev'], title
='LAMI test',
53 description
='LTTng analyses machine interface test',
54 authors
=['Phil Proulx'], url
='http://perdu.com',
55 tags
=['lami', 'test'],
56 table_classes
=_TABLE_CLASSES
.values())
57 print(json
.dumps(infos
))
61 ap
= argparse
.ArgumentParser()
62 ap
.add_argument('--metadata', action
='store_true')
63 ap
.add_argument('--begin', type=int, default
=1000)
64 ap
.add_argument('--end', type=int, default
=2000)
65 ap
.add_argument('-d', '--dynamic', action
='store_true')
66 ap
.add_argument('-r', '--dynamic-rows', type=int, default
=25)
67 ap
.add_argument('-c', '--dynamic-columns', type=int, default
=10)
69 return ap
.parse_args()
72 def _print_tables(tables
):
74 'results': [t
.to_native_object() for t
in tables
],
77 print(json
.dumps(obj
))
80 def _print_dynamic_table(begin
, end
, rows
, columns
):
81 def gen_irq_name(size
=6, chars
=string
.ascii_uppercase
+ string
.digits
):
82 return ''.join(random
.choice(chars
) for _
in range(size
))
85 ('irq', 'Interrupt', mi
.Irq
),
88 for i
in range(columns
):
89 column_tuples
.append((
91 'Count ({} to {})'.format(i
* 5, (i
+ 1) * 5),
96 table_class
= mi
.TableClass(None, 'What a dynamic table!', column_tuples
)
97 result_table
= mi
.ResultTable(table_class
, begin
, end
)
101 mi
.Irq(bool(random
.getrandbits(1)), i
, gen_irq_name())
104 for j
in range(columns
):
105 row_tuple
.append(mi
.Integer(random
.randint(0, 5000)))
107 result_table
.append_row_tuple(tuple(row_tuple
))
109 _print_tables([result_table
])
112 def _print_static_tables(begin
, end
):
113 per_proc_table
= mi
.ResultTable(_TABLE_CLASSES
[_TABLE_CLASS_PER_PROC
], begin
, end
)
114 per_syscall_table
= mi
.ResultTable(_TABLE_CLASSES
[_TABLE_CLASS_PER_SYSCALL
], begin
, end
)
115 per_irq_table
= mi
.ResultTable(_TABLE_CLASSES
[_TABLE_CLASS_PER_IRQ
], begin
, end
)
116 per_irq_table_sub
= mi
.ResultTable(_TABLE_CLASSES
[_TABLE_CLASS_PER_IRQ
], begin
, end
,
117 'with overridden title')
120 per_proc_table
.append_row_tuple((
121 mi
.Process('zsh', pid
=23),
125 mi
.String('typical'),
127 mi
.Timestamp(817232),
129 per_proc_table
.append_row_tuple((
130 mi
.Process('chromium', tid
=4987),
136 mi
.Timestamp(1194875),
138 per_proc_table
.append_row_tuple((
139 mi
.Process('terminator'),
145 mi
.Timestamp(984987658),
147 per_proc_table
.append_row_tuple((
148 mi
.Process(pid
=1945, tid
=4497),
154 mi
.Timestamp(154484512),
158 per_syscall_table
.append_row_tuple((
160 mi
.Duration(2398123),
163 mi
.TimeRange(98233, 1293828),
165 per_syscall_table
.append_row_tuple((
169 mi
.Bitrate(25235343),
170 mi
.TimeRange(5454, 2354523),
172 per_syscall_table
.append_row_tuple((
174 mi
.Duration(2312454),
177 mi
.TimeRange(12, 645634545454),
179 per_syscall_table
.append_row_tuple((
184 mi
.TimeRange(2134, 645634545),
186 per_syscall_table
.append_row_tuple((
190 mi
.Bitrate(4494494494),
195 per_irq_table
.append_row_tuple((
196 mi
.Irq(True, 15, 'keyboard'),
198 mi
.Path('/etc/passwd'),
201 mi
.Partition('sdb3'),
204 per_irq_table
.append_row_tuple((
205 mi
.Irq(False, 7, 'soft-timer'),
207 mi
.Path('/dev/null'),
210 mi
.Partition('mmcblk0p2'),
213 per_irq_table
.append_row_tuple((
219 mi
.Partition('sdc3'),
223 # per-interrupt with subtitle
224 per_irq_table_sub
.append_row_tuple((
225 mi
.Irq(False, 12, 'soft-like-silk'),
227 mi
.Path('/home/bob/meowmix.txt'),
230 mi
.Partition('sdb2'),
233 per_irq_table_sub
.append_row_tuple((
234 mi
.Irq(True, 1, 'mouse2'),
239 mi
.Partition('vda3'),
260 _print_dynamic_table(args
.begin
, args
.end
,
261 args
.dynamic_rows
, args
.dynamic_columns
)
263 _print_static_tables(args
.begin
, args
.end
)
266 if __name__
== '__main__':
This page took 0.047916 seconds and 5 git commands to generate.