Skip to content

Commit d1788c5

Browse files
author
Benn Bollay
committed
F5 Network's contribution of a fast in-memory stats system, including
reporting, publishing, and merging. Originally implemented by Jonathan Mini.
0 parents  commit d1788c5

17 files changed

+13340
-0
lines changed

LICENSE

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright (c) 2013, F5 Networks, Inc.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
17+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
24+
The views and conclusions contained in the software and documentation are
25+
those of the authors and should not be interpreted as representing official
26+
policies, either expressed or implied, of F5 Networks, Inc.

README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A binary file in-memory stat segment library, with associated tools.

SConstruct

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Running unittests is left as an exercise for the reader, through the
2+
# run_tests.sh shellscript.
3+
4+
env = Environment(CFLAGS= ['-falign-functions=16',
5+
'-D_REENTRANT',
6+
'-mtune=opteron',
7+
'-g',
8+
'-O2',
9+
'-fPIC',
10+
'-Wall',
11+
'-Werror',
12+
'-Wpointer-arith',
13+
'-Wreturn-type',
14+
'-Wswitch',
15+
'-Wunused',
16+
'-Wundef',
17+
'-Wno-uninitialized',
18+
'-Wno-format',
19+
'-Wmissing-prototypes',
20+
'--std=gnu99',
21+
'-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE']
22+
, LIBPATH='.')
23+
24+
env.Library('tmstat', ['libtmstat.c', 'libtmstat_eval.c'])
25+
env.Program('tmstat', ['tmstat_dash.c', 'd_compress.c', 'd_cpu.c', 'd_summary.c'],
26+
LIBS=['tmstat', 'curses'])
27+
env.Program('tmctl', ['tmctl.c'], LIBS=['tmstat'])
28+
env.Program('tmstat_test', ['tmstat_test.c'], LIBS=['tmstat'])
29+
env.Library('tmstat_tls', ['tmstat_sandbox.c', 'libtmstat.c', 'libtmstat_eval.c'])
30+

d_compress.c

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/*
2+
* Copyright (c) 2013, F5 Networks, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
* POSSIBILITY OF SUCH DAMAGE.
25+
*
26+
* The views and conclusions contained in the software and documentation are
27+
* those of the authors and should not be interpreted as representing official
28+
* policies, either expressed or implied, of F5 Networks, Inc.
29+
*
30+
* Vcompress display.
31+
*
32+
*/
33+
#include <stdint.h>
34+
35+
#include "tmstat.h"
36+
#include "tmstat_dash.h"
37+
38+
struct display display_compress[] = {
39+
{ .x = 1, .y = 1, .what = DT_LABEL,
40+
.s = "CPU: %% busy %% idle %% sleep" },
41+
{ .x = 9, .y = 1, .what = DT_INT, .w = 3, .align = RIGHT,
42+
.s = "(((((<proc_stat.tm_total_cycles-(<proc_stat.tm_idle_cycles+<proc_stat.tm_sleep_cycles))*1000)/<proc_stat.tm_total_cycles)+5)/10)" },
43+
{ .x = 21, .y = 1, .what = DT_INT, .w = 3, .align = RIGHT,
44+
.s = "((((<proc_stat.tm_idle_cycles*1000)/<proc_stat.tm_total_cycles)+5)/10)" },
45+
{ .x = 32, .y = 1, .what = DT_INT, .w = 3, .align = RIGHT,
46+
.s = "((((<proc_stat.tm_sleep_cycles*1000)/<proc_stat.tm_total_cycles)+5)/10)" },
47+
48+
/* Memory under exclusive process control. */
49+
{ .x = 15, .y = 3, .what = DT_LABEL, .s = "Memory Allocated",
50+
.align = CENTER },
51+
{ .x = 14, .y = 4, .what = DT_LABEL, .s = "/",
52+
.align = CENTER },
53+
{ .x = 13, .y = 4, .what = DT_INT, .s = "proc_stat.memory_used",
54+
.align = RIGHT },
55+
{ .x = 16, .y = 4, .what = DT_INT, .s = "proc_stat.memory_total",
56+
.align = LEFT },
57+
58+
/* Misc. */
59+
{ .x = -8, .y = 3, .what = DT_LABEL, .s = "Polls"},
60+
{ .x = -9, .y = 3, .what = DT_INT, .s = "<proc_stat.polls", .align = RIGHT },
61+
62+
/* Compress */
63+
{ .x = 40, .y = 7, .what = DT_LABEL, .s = "Compression", .align = CENTER },
64+
{ .x = 12, .y = 8, .what = DT_LABEL, .s = "Device", .align = CENTER },
65+
{ .x = 54, .y = 8, .what = DT_LABEL, .s = "Streams", .align = RIGHT },
66+
{ .x = -6, .y = 8, .what = DT_LABEL, .s = "Bit Rate", .align = RIGHT },
67+
68+
{ .x = 12, .y = 9, .what = DT_STRING,.s = "compress[0].provider", .align = CENTER },
69+
{ .x = 29, .y = 9, .what = DT_INT, .s = "compress[0].cur_enqueued", .align = RIGHT },
70+
{ .x = 30, .y = 9, .what = DT_LABEL, .s = "queued" },
71+
{ .x = 29, .y = 10, .what = DT_INT, .w = 3, .align = RIGHT,
72+
.s = "(100-((((<compress[0].tot_bytes_out*1000)/<compress[0].tot_bytes_in)+5)/10))" },
73+
{ .x = 30, .y = 10, .what = DT_LABEL,.s = "%% saved", .align = LEFT },
74+
{ .x = 50, .y = 9, .what = DT_INT, .s = "compress[0].cur_ctx", .align = RIGHT },
75+
{ .x = 51, .y = 9, .what = DT_LABEL, .s = "cur" },
76+
{ .x = 50, .y = 10, .what = DT_INT, .s = "compress[0].tot_ctx", .align = RIGHT },
77+
{ .x = 51, .y = 10, .what = DT_LABEL,.s = "tot" },
78+
{ .x = -6, .y = 9, .what = DT_INT, .s = "(<compress[0].tot_bytes_out*8)", .align = RIGHT },
79+
{ .x = -6, .y = 10, .what = DT_INT, .s = "(<compress[0].tot_bytes_in*8)", .align = RIGHT },
80+
{ .x = -5, .y = 9, .what = DT_LABEL, .s = "post" },
81+
{ .x = -5, .y = 10, .what = DT_LABEL,.s = "pre" },
82+
83+
84+
{ .x = 12, .y = 12, .what = DT_STRING,.s = "compress[1].provider", .align = CENTER },
85+
{ .x = 29, .y = 12, .what = DT_INT, .s = "compress[1].cur_enqueued", .align = RIGHT },
86+
{ .x = 30, .y = 12, .what = DT_LABEL, .s = "queued" },
87+
{ .x = 29, .y = 13, .what = DT_INT, .w = 3, .align = RIGHT,
88+
.s = "(100-((((<compress[1].tot_bytes_out*1000)/<compress[1].tot_bytes_in)+5)/10))" },
89+
{ .x = 30, .y = 13, .what = DT_LABEL, .s = "%% saved", .align = LEFT },
90+
{ .x = 50, .y = 12, .what = DT_INT, .s = "compress[1].cur_ctx", .align = RIGHT },
91+
{ .x = 50, .y = 13, .what = DT_INT, .s = "compress[1].tot_ctx", .align = RIGHT },
92+
{ .x = 51, .y = 12, .what = DT_LABEL, .s = "cur" },
93+
{ .x = 51, .y = 13, .what = DT_LABEL, .s = "tot" },
94+
{ .x = -6, .y = 12, .what = DT_INT, .s = "(<compress[1].tot_bytes_out*8)", .align = RIGHT },
95+
{ .x = -6, .y = 13, .what = DT_INT, .s = "(<compress[1].tot_bytes_in*8)", .align = RIGHT },
96+
{ .x = -5, .y = 12, .what = DT_LABEL, .s = "post" },
97+
{ .x = -5, .y = 13, .what = DT_LABEL, .s = "pre" },
98+
99+
100+
{ .x = 12, .y = 15, .what = DT_STRING,.s = "compress[2].provider", .align = CENTER },
101+
{ .x = 29, .y = 15, .what = DT_INT, .s = "compress[2].cur_enqueued", .align = RIGHT },
102+
{ .x = 30, .y = 15, .what = DT_LABEL, .s = "queued" },
103+
{ .x = 29, .y = 16, .what = DT_INT, .w = 3, .align = RIGHT,
104+
.s = "(100-((((<compress[2].tot_bytes_out*1000)/<compress[2].tot_bytes_in)+5)/10))" },
105+
{ .x = 30, .y = 16, .what = DT_LABEL, .s = "%% saved", .align = LEFT },
106+
{ .x = 50, .y = 15, .what = DT_INT, .s = "compress[2].cur_ctx", .align = RIGHT },
107+
{ .x = 50, .y = 16, .what = DT_INT, .s = "compress[2].tot_ctx", .align = RIGHT },
108+
{ .x = 51, .y = 15, .what = DT_LABEL, .s = "cur" },
109+
{ .x = 51, .y = 16, .what = DT_LABEL, .s = "tot" },
110+
{ .x = -6, .y = 15, .what = DT_INT, .s = "(<compress[2].tot_bytes_out*8)", .align = RIGHT },
111+
{ .x = -6, .y = 16, .what = DT_INT, .s = "(<compress[2].tot_bytes_in*8)", .align = RIGHT },
112+
{ .x = -5, .y = 15, .what = DT_LABEL, .s = "post" },
113+
{ .x = -5, .y = 16, .what = DT_LABEL, .s = "pre" },
114+
115+
116+
{ .x = 12, .y = 18, .what = DT_STRING,.s = "compress[3].provider", .align = CENTER },
117+
{ .x = 29, .y = 18, .what = DT_INT, .s = "compress[3].cur_enqueued", .align = RIGHT },
118+
{ .x = 30, .y = 18, .what = DT_LABEL, .s = "queued" },
119+
{ .x = 29, .y = 19, .what = DT_INT, .w = 3, .align = RIGHT,
120+
.s = "(100-((((<compress[3].tot_bytes_out*1000)/<compress[3].tot_bytes_in)+5)/10))" },
121+
{ .x = 30, .y = 19, .what = DT_LABEL, .s = "%% saved", .align = LEFT },
122+
{ .x = 50, .y = 19, .what = DT_INT, .s = "compress[3].cur_ctx", .align = RIGHT },
123+
{ .x = 50, .y = 19, .what = DT_INT, .s = "compress[3].tot_ctx", .align = RIGHT },
124+
{ .x = 51, .y = 18, .what = DT_LABEL, .s = "cur" },
125+
{ .x = 51, .y = 19, .what = DT_LABEL, .s = "tot" },
126+
{ .x = -6, .y = 18, .what = DT_INT, .s = "(<compress[3].tot_bytes_out*8)", .align = RIGHT },
127+
{ .x = -6, .y = 19, .what = DT_INT, .s = "(<compress[3].tot_bytes_in*8)", .align = RIGHT },
128+
{ .x = -5, .y = 18, .what = DT_LABEL, .s = "post" },
129+
{ .x = -5, .y = 19, .what = DT_LABEL, .s = "pre" },
130+
131+
132+
{ .x = 12, .y = 21, .what = DT_LABEL, .s = "GRAND TOTAL", .align = CENTER },
133+
{ .x = 29, .y = 21, .what = DT_INT,
134+
.s = "((compress[0].cur_enqueued+compress[1].cur_enqueued)+(compress[2].cur_enqueued+compress[3].cur_enqueued))", .align = RIGHT },
135+
{ .x = 30, .y = 21, .what = DT_LABEL, .s = "queued" },
136+
{ .x = 29, .y = 22, .what = DT_INT, .w = 3, .align = RIGHT,
137+
.s = "(100-((((((<compress[0].tot_bytes_out+<compress[1].tot_bytes_out)+(<compress[2].tot_bytes_out+<compress[3].tot_bytes_out))*1000)/((<compress[0].tot_bytes_in+<compress[1].tot_bytes_in)+(<compress[2].tot_bytes_in+<compress[3].tot_bytes_in)))+5)/10))" },
138+
{ .x = 30, .y = 22, .what = DT_LABEL, .s = "%% saved", .align = LEFT },
139+
{ .x = 50, .y = 21, .what = DT_INT,
140+
.s = "((compress[0].cur_ctx+compress[1].cur_ctx)+(compress[2].cur_ctx+compress[3].cur_ctx))", .align = RIGHT },
141+
{ .x = 50, .y = 22, .what = DT_INT,
142+
.s = "((compress[0].tot_ctx+compress[1].tot_ctx)+(compress[2].tot_ctx+compress[3].tot_ctx))", .align = RIGHT },
143+
{ .x = 51, .y = 21, .what = DT_LABEL, .s = "cur" },
144+
{ .x = 51, .y = 22, .what = DT_LABEL, .s = "tot" },
145+
{ .x = -6, .y = 21, .what = DT_INT,
146+
.s = "(((<compress[0].tot_bytes_out+<compress[1].tot_bytes_out)+(<compress[2].tot_bytes_out+<compress[3].tot_bytes_out))*8)", .align = RIGHT },
147+
{ .x = -6, .y = 22, .what = DT_INT,
148+
.s = "(((<compress[0].tot_bytes_in+<compress[1].tot_bytes_in)+(<compress[2].tot_bytes_in+<compress[3].tot_bytes_in))*8)", .align = RIGHT },
149+
{ .x = -5, .y = 21, .what = DT_LABEL, .s = "post" },
150+
{ .x = -5, .y = 22, .what = DT_LABEL, .s = "pre" },
151+
152+
/* Streams per sec by gzip level */
153+
{ .x = 40, .y = 24, .what = DT_LABEL, .s = "New Streams Per Second", .align = CENTER },
154+
{ .x = 1, .y = 25, .what = DT_LABEL, .s =
155+
"Device 0 1 2 3 4 5 6 7 8 9" },
156+
{ .x = 1, .y = 26, .what = DT_STRING, .s = "compress[0].provider" },
157+
{ .x = 1, .y = 27, .what = DT_STRING, .s = "compress[1].provider" },
158+
{ .x = 1, .y = 28, .what = DT_STRING, .s = "compress[2].provider" },
159+
160+
{ .x = 16, .y = 26, .what = DT_INT, .s = "<compress[0].0_tot_ctx", .align = RIGHT },
161+
{ .x = 23, .y = 26, .what = DT_INT, .s = "<compress[0].1_tot_ctx", .align = RIGHT },
162+
{ .x = 30, .y = 26, .what = DT_INT, .s = "<compress[0].2_tot_ctx", .align = RIGHT },
163+
{ .x = 37, .y = 26, .what = DT_INT, .s = "<compress[0].3_tot_ctx", .align = RIGHT },
164+
{ .x = 44, .y = 26, .what = DT_INT, .s = "<compress[0].4_tot_ctx", .align = RIGHT },
165+
{ .x = 51, .y = 26, .what = DT_INT, .s = "<compress[0].5_tot_ctx", .align = RIGHT },
166+
{ .x = 58, .y = 26, .what = DT_INT, .s = "<compress[0].6_tot_ctx", .align = RIGHT },
167+
{ .x = 65, .y = 26, .what = DT_INT, .s = "<compress[0].7_tot_ctx", .align = RIGHT },
168+
{ .x = 72, .y = 26, .what = DT_INT, .s = "<compress[0].8_tot_ctx", .align = RIGHT },
169+
{ .x = 79, .y = 26, .what = DT_INT, .s = "<compress[0].9_tot_ctx", .align = RIGHT },
170+
171+
{ .x = 16, .y = 27, .what = DT_INT, .s = "<compress[1].0_tot_ctx", .align = RIGHT },
172+
{ .x = 23, .y = 27, .what = DT_INT, .s = "<compress[1].1_tot_ctx", .align = RIGHT },
173+
{ .x = 30, .y = 27, .what = DT_INT, .s = "<compress[1].2_tot_ctx", .align = RIGHT },
174+
{ .x = 37, .y = 27, .what = DT_INT, .s = "<compress[1].3_tot_ctx", .align = RIGHT },
175+
{ .x = 44, .y = 27, .what = DT_INT, .s = "<compress[1].4_tot_ctx", .align = RIGHT },
176+
{ .x = 51, .y = 27, .what = DT_INT, .s = "<compress[1].5_tot_ctx", .align = RIGHT },
177+
{ .x = 58, .y = 27, .what = DT_INT, .s = "<compress[1].6_tot_ctx", .align = RIGHT },
178+
{ .x = 65, .y = 27, .what = DT_INT, .s = "<compress[1].7_tot_ctx", .align = RIGHT },
179+
{ .x = 72, .y = 27, .what = DT_INT, .s = "<compress[1].8_tot_ctx", .align = RIGHT },
180+
{ .x = 79, .y = 27, .what = DT_INT, .s = "<compress[1].9_tot_ctx", .align = RIGHT },
181+
182+
{ .x = 16, .y = 28, .what = DT_INT, .s = "<compress[2].0_tot_ctx", .align = RIGHT },
183+
{ .x = 23, .y = 28, .what = DT_INT, .s = "<compress[2].1_tot_ctx", .align = RIGHT },
184+
{ .x = 30, .y = 28, .what = DT_INT, .s = "<compress[2].2_tot_ctx", .align = RIGHT },
185+
{ .x = 37, .y = 28, .what = DT_INT, .s = "<compress[2].3_tot_ctx", .align = RIGHT },
186+
{ .x = 44, .y = 28, .what = DT_INT, .s = "<compress[2].4_tot_ctx", .align = RIGHT },
187+
{ .x = 51, .y = 28, .what = DT_INT, .s = "<compress[2].5_tot_ctx", .align = RIGHT },
188+
{ .x = 58, .y = 28, .what = DT_INT, .s = "<compress[2].6_tot_ctx", .align = RIGHT },
189+
{ .x = 65, .y = 28, .what = DT_INT, .s = "<compress[2].7_tot_ctx", .align = RIGHT },
190+
{ .x = 72, .y = 28, .what = DT_INT, .s = "<compress[2].8_tot_ctx", .align = RIGHT },
191+
{ .x = 79, .y = 28, .what = DT_INT, .s = "<compress[2].9_tot_ctx", .align = RIGHT },
192+
193+
{ .what = DT_EOL }
194+
};

0 commit comments

Comments
 (0)