rename network functions (#16908)
Costa Tsaousis committed
Feb 1, 2024 at 18:20 UTC
278f8878a4ee681bd4bda70d8743c2a13da80e9a
3 files changed
+62
-15
collectors/ebpf.plugin/ebpf_functions.h
+1
-1
@@ -16,7 +16,7 @@ static inline void EBPF_PLUGIN_FUNCTIONS(const char *NAME, const char *DESC, int
16
#define NETDATA_EBPF_FUNCTIONS_MODULE_DESC "Show information about current function status."
17
18
// function list
19
-#define EBPF_FUNCTION_SOCKET "network-connections"
19
+#define EBPF_FUNCTION_SOCKET "network-sockets-tracing"
20
21
// socket constants
22
#define EBPF_PLUGIN_SOCKET_FUNCTION_DESCRIPTION "Detailed information about open sockets."
collectors/network-viewer.plugin/network-connections-chart.html
renamed
+55
-8
@@ -101,7 +101,11 @@
101
const ch = h / 2 - borderPadding;
102
103
const minSize = 13;
104
- const maxSize = Math.max(5, Math.min(w, h) / data.length) + minSize;
104
+ const maxSize = Math.min(
105
+ (cw * 2) / 3 - borderPadding,
106
+ (ch * 2) / 3 - borderPadding,
107
+ Math.max(5, Math.min(w, h) / data.length) + minSize
108
+ )
109
110
const max = {
111
total: d3.max(data, d => d.counts.total),
@@ -118,12 +122,18 @@
122
.range([minSize, maxSize])
123
.clamp(true); // Clamps the output so that it stays within the range
124
121
- const logScaleRight = d3.scaleLog().domain([1, max.public + 1]).range([0, cw]);
122
- const logScaleLeft = d3.scaleLog().domain([1, max.private + 1]).range([0, cw]);
123
- const logScaleTop = d3.scaleLog().domain([1, max.outbound + 1]).range([0, ch]);
124
- const logScaleBottom = d3.scaleLog().domain([1, (max.listen + max.inbound) / 2 + 1]).range([0, ch]);
125
+ let listenerDelta = 50;
126
+ let listenersAdded = 0;
127
+ let listenersAddedRight = 0;
128
+ let listenersAddedLeft = 0;
129
+ let listenersH = h - borderPadding;
130
131
data.forEach((d, i) => {
132
+ const logScaleRight = d3.scaleLog().domain([1, d.counts.public + 1]).range([0, cw]);
133
+ const logScaleLeft = d3.scaleLog().domain([1, d.counts.private + 1]).range([0, cw]);
134
+ const logScaleTop = d3.scaleLog().domain([1, d.counts.outbound + 1]).range([0, ch]);
135
+ const logScaleBottom = d3.scaleLog().domain([1, (d.counts.listen + d.counts.inbound) / 2 + 1]).range([0, ch]);
136
+
137
d.forces = {
138
total: d.counts.total / max.total,
139
local: d.counts.local / max.local,
@@ -142,11 +152,48 @@
152
bottom: logScaleBottom(((config.listen ? d.counts.listen : 0) + d.counts.inbound) / (config.listen ? 2 : 1) + 1),
153
};
154
155
+ let x = borderPadding + cw + d.pos.right - d.pos.left;
156
+ let y = borderPadding + ch + d.pos.bottom - d.pos.top;
157
+ let size = circleSize(d.counts.total);
158
+
159
+ if(d.counts.listen === d.counts.total) {
160
+ // a listener
161
+ size = circleSize(1);
162
+
163
+ if(listenersAdded * listenerDelta > cw * 2 / 3) {
164
+ // too many listeners on this row
165
+ // let's start adding on another row above
166
+ listenersAdded = 0;
167
+ listenersAddedLeft = 0;
168
+ listenersAddedRight = 0;
169
+ listenersH -= 30;
170
+ }
171
+
172
+ if(!listenersAdded) {
173
+ x = cw;
174
+ y = listenersH - size;
175
+ }
176
+ else {
177
+ if(listenersAddedLeft >= listenersAddedRight) {
178
+ listenersAddedRight++;
179
+ x = cw + listenersAddedRight * listenerDelta;
180
+ y = listenersH - size - (listenersAddedRight % 2 === 0 ? 0 : 30);
181
+ }
182
+ else {
183
+ listenersAddedLeft++;
184
+ x = cw - listenersAddedLeft * listenerDelta;
185
+ y = listenersH - size - (listenersAddedLeft % 2 === 0 ? 0 : 30);
186
+ }
187
+ }
188
+
189
+ listenersAdded++;
190
+ }
191
+
192
const others = d.counts.total - (d.counts.public + d.counts.private + (config.listen ? d.counts.listen : 0) + d.counts.inbound + d.counts.outbound);
193
d.d3 = {
147
- x: borderPadding + cw + d.pos.right - d.pos.left,
148
- y: borderPadding + ch + d.pos.bottom - d.pos.top,
149
- size: circleSize(d.counts.total),
194
+ x: x,
195
+ y: y,
196
+ size: size,
197
pie: [
198
{ value: d.counts.public },
199
{ value: d.counts.private },
collectors/network-viewer.plugin/network-viewer.c
+6
-6
@@ -5,8 +5,8 @@
5
#include "libnetdata/required_dummies.h"
6
#include "collectors/plugins.d/local-sockets.h"
7
8
-#define NETWORK_VIEWER_FUNCTION "network-viewer"
9
-#define NETWORK_VIEWER_HELP "Network dependencies (outbound connections)"
8
+#define NETWORK_CONNECTIONS_VIEWER_FUNCTION "network-connections"
9
+#define NETWORK_CONNECTIONS_VIEWER_HELP "Network connections explorer"
10
11
netdata_mutex_t stdout_mutex = NETDATA_MUTEX_INITIALIZER;
12
static bool plugin_should_exit = false;
@@ -113,7 +113,7 @@ void network_viewer_function(const char *transaction, char *function __maybe_unu
113
buffer_json_member_add_uint64(wb, "status", HTTP_RESP_OK);
114
buffer_json_member_add_string(wb, "type", "table");
115
buffer_json_member_add_time_t(wb, "update_every", 5);
116
- buffer_json_member_add_string(wb, "help", NETWORK_VIEWER_HELP);
116
+ buffer_json_member_add_string(wb, "help", NETWORK_CONNECTIONS_VIEWER_HELP);
117
buffer_json_member_add_array(wb, "data");
118
119
LS_STATE ls = {
@@ -460,7 +460,8 @@ int main(int argc __maybe_unused, char **argv __maybe_unused) {
460
// ----------------------------------------------------------------------------------------------------------------
461
462
fprintf(stdout, PLUGINSD_KEYWORD_FUNCTION " GLOBAL \"%s\" %d \"%s\" \"top\" "HTTP_ACCESS_FORMAT" %d\n",
463
- NETWORK_VIEWER_FUNCTION, 60, NETWORK_VIEWER_HELP,
463
+ NETWORK_CONNECTIONS_VIEWER_FUNCTION, 60,
464
+ NETWORK_CONNECTIONS_VIEWER_HELP,
465
(HTTP_ACCESS_FORMAT_CAST)(HTTP_ACCESS_SIGNED_ID | HTTP_ACCESS_SAME_SPACE | HTTP_ACCESS_SENSITIVE_DATA),
466
RRDFUNCTIONS_PRIORITY_DEFAULT);
467
@@ -469,8 +470,7 @@ int main(int argc __maybe_unused, char **argv __maybe_unused) {
470
struct functions_evloop_globals *wg =
471
functions_evloop_init(5, "Network-Viewer", &stdout_mutex, &plugin_should_exit);
472
472
- functions_evloop_add_function(wg,
473
- NETWORK_VIEWER_FUNCTION,
473
+ functions_evloop_add_function(wg, NETWORK_CONNECTIONS_VIEWER_FUNCTION,
474
network_viewer_function,
475
PLUGINS_FUNCTIONS_TIMEOUT_DEFAULT,
476
NULL);