forked from dlakelan/routerperf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonify.m4
39 lines (37 loc) · 1.01 KB
/
jsonify.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
divert(-1)dnl
define(`statformat',`[')
define(`nstimestart',`define(startsec,eval('$1`-1)) dnl')
define(`nstimestamp',`,
{"time" : eval($1-'startsec`).$2,
')
pushdef(`nstimestamp',`popdef(`nstimestamp') {"time" : eval($1-'startsec`).$2,
')
define(`nocomma',```dnl''')
define(`procstat',`procstatformat(nocomma $1)')
define(`procstatformat',`"cpu":[patsubst($1,`\(cpu[0-9]*\) *\([0-9 ]+\)
',`,
["\1",patsubst(\2,` +',`,')]')],
')
define(`Inter',`dnl')
define(`face',`dnl')
define(`procnetdev',`procnetformat(nocomma $1])')
define(`procnetformat',`"interfaces":[patsubst($1,` *\([a-zA-Z0-9.]+\):\([ 0-9]*\)
',`,
["\1",patsubst(\2,` +',`,')]')
}
')
define(`ctxt',`dnl')
define(`intr',`dnl')
define(btime,`dnl')
define(processes,`dnl')
define(procs_running,`dnl')
define(procs_blocked,`dnl')
define(softirq,`dnl')
define(`id',$1)
define(`pingformat',`[')dnl
define(`PING',`dnl')dnl
define(`pingdata',`patsubst($1,`\[\([0-9]+\)\.\([0-9]+\)\][^
]*time=\([0-9.]+\) ms',`nstimestamp(\1,\2`'000) "ping":\3}')')dnl
divert dnl
m4wrap(]
)dnl