0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-13 17:19:11 +00:00
netdata_netdata/collectors/proc.plugin/proc_net_sockstat.c
Costa Tsaousis cb7af25c09
RRD structures managed by dictionaries ()
* rrdset - in progress

* rrdset optimal constructor; rrdset conflict

* rrdset final touches

* re-organization of rrdset object members

* prevent use-after-free

* dictionary dfe supports also counting of iterations

* rrddim managed by dictionary

* rrd.h cleanup

* DICTIONARY_ITEM now is referencing actual dictionary items in the code

* removed rrdset linked list

* Revert "removed rrdset linked list"

This reverts commit 690d6a588b4b99619c2c5e10f84e8f868ae6def5.

* removed rrdset linked list

* added comments

* Switch chart uuid to static allocation in rrdset
Remove unused functions

* rrdset_archive() and friends...

* always create rrdfamily

* enable ml_free_dimension

* rrddim_foreach done with dfe

* most custom rrddim loops replaced with rrddim_foreach

* removed accesses to rrddim->dimensions

* removed locks that are no longer needed

* rrdsetvar is now managed by the dictionary

* set rrdset is rrdsetvar, fixes https://github.com/netdata/netdata/pull/13646#issuecomment-1242574853

* conflict callback of rrdsetvar now properly checks if it has to reset the variable

* dictionary registered callbacks accept as first parameter the DICTIONARY_ITEM

* dictionary dfe now uses internal counter to report; avoided excess variables defined with dfe

* dictionary walkthrough callbacks get dictionary acquired items

* dictionary reference counters that can be dupped from zero

* added advanced functions for get and del

* rrdvar managed by dictionaries

* thread safety for rrdsetvar

* faster rrdvar initialization

* rrdvar string lengths should match in all add, del, get functions

* rrdvar internals hidden from the rest of the world

* rrdvar is now acquired throughout netdata

* hide the internal structures of rrdsetvar

* rrdsetvar is now acquired through out netdata

* rrddimvar managed by dictionary; rrddimvar linked list removed; rrddimvar structures hidden from the rest of netdata

* better error handling

* dont create variables if not initialized for health

* dont create variables if not initialized for health again

* rrdfamily is now managed by dictionaries; references of it are acquired dictionary items

* type checking on acquired objects

* rrdcalc renaming of functions

* type checking for rrdfamily_acquired

* rrdcalc managed by dictionaries

* rrdcalc double free fix

* host rrdvars is always needed

* attempt to fix deadlock 1

* attempt to fix deadlock 2

* Remove unused variable

* attempt to fix deadlock 3

* snprintfz

* rrdcalc index in rrdset fix

* Stop storing active charts and computing chart hashes

* Remove store active chart function

* Remove compute chart hash function

* Remove sql_store_chart_hash function

* Remove store_active_dimension function

* dictionary delayed destruction

* formatting and cleanup

* zero dictionary base on rrdsetvar

* added internal error to log delayed destructions of dictionaries

* typo in rrddimvar

* added debugging info to dictionary

* debug info

* fix for rrdcalc keys being empty

* remove forgotten unlock

* remove deadlock

* Switch to metadata version 5 and drop
  chart_hash
  chart_hash_map
  chart_active
  dimension_active
  v_chart_hash

* SQL cosmetic changes

* do not busy wait while destroying a referenced dictionary

* remove deadlock

* code cleanup; re-organization;

* fast cleanup and flushing of dictionaries

* number formatting fixes

* do not delete configured alerts when archiving a chart

* rrddim obsolete linked list management outside dictionaries

* removed duplicate contexts call

* fix crash when rrdfamily is not initialized

* dont keep rrddimvar referenced

* properly cleanup rrdvar

* removed some locks

* Do not attempt to cleanup chart_hash / chart_hash_map

* rrdcalctemplate managed by dictionary

* register callbacks on the right dictionary

* removed some more locks

* rrdcalc secondary index replaced with linked-list; rrdcalc labels updates are now executed by health thread

* when looking up for an alarm look using both chart id and chart name

* host initialization a bit more modular

* init rrdlabels on host update

* preparation for dictionary views

* improved comment

* unused variables without internal checks

* service threads isolation and worker info

* more worker info in service thread

* thread cancelability debugging with internal checks

* strings data races addressed; fixes https://github.com/netdata/netdata/issues/13647

* dictionary modularization

* Remove unused SQL statement definition

* unit-tested thread safety of dictionaries; removed data race conditions on dictionaries and strings; dictionaries now can detect if the caller is holds a write lock and automatically all the calls become their unsafe versions; all direct calls to unsafe version is eliminated

* remove worker_is_idle() from the exit of service functions, because we lose the lock time between loops

* rewritten dictionary to have 2 separate locks, one for indexing and another for traversal

* Update collectors/cgroups.plugin/sys_fs_cgroup.c

Co-authored-by: Vladimir Kobal <vlad@prokk.net>

* Update collectors/cgroups.plugin/sys_fs_cgroup.c

Co-authored-by: Vladimir Kobal <vlad@prokk.net>

* Update collectors/proc.plugin/proc_net_dev.c

Co-authored-by: Vladimir Kobal <vlad@prokk.net>

* fix memory leak in rrdset cache_dir

* minor dictionary changes

* dont use index locks in single threaded

* obsolete dict option

* rrddim options and flags separation; rrdset_done() optimization to keep array of reference pointers to rrddim;

* fix jump on uninitialized value in dictionary; remove double free of cache_dir

* addressed codacy findings

* removed debugging code

* use the private refcount on dictionaries

* make dictionary item desctructors work on dictionary destruction; strictier control on dictionary API; proper cleanup sequence on rrddim;

* more dictionary statistics

* global statistics about dictionary operations, memory, items, callbacks

* dictionary support for views - missing the public API

* removed warning about unused parameter

* chart and context name for cloud

* chart and context name for cloud, again

* dictionary statistics fixed; first implementation of dictionary views - not currently used

* only the master can globally delete an item

* context needs netdata prefix

* fix context and chart it of spins

* fix for host variables when health is not enabled

* run garbage collector on item insert too

* Fix info message; remove extra "using"

* update dict unittest for new placement of garbage collector

* we need RRDHOST->rrdvars for maintaining custom host variables

* Health initialization needs the host->host_uuid

* split STRING to its own files; no code changes other than that

* initialize health unconditionally

* unit tests do not pollute the global scope with their variables

* Skip initialization when creating archived hosts on startup. When a child connects it will initialize properly

Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Co-authored-by: Vladimir Kobal <vlad@prokk.net>
2022-09-19 23:46:13 +03:00

538 lines
21 KiB
C

// SPDX-License-Identifier: GPL-3.0-or-later
#include "plugin_proc.h"
#define PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME "/proc/net/sockstat"
static struct proc_net_sockstat {
kernel_uint_t sockets_used;
kernel_uint_t tcp_inuse;
kernel_uint_t tcp_orphan;
kernel_uint_t tcp_tw;
kernel_uint_t tcp_alloc;
kernel_uint_t tcp_mem;
kernel_uint_t udp_inuse;
kernel_uint_t udp_mem;
kernel_uint_t udplite_inuse;
kernel_uint_t raw_inuse;
kernel_uint_t frag_inuse;
kernel_uint_t frag_memory;
} sockstat_root = { 0 };
static int read_tcp_mem(void) {
static char *filename = NULL;
static const RRDVAR_ACQUIRED *tcp_mem_low_threshold = NULL,
*tcp_mem_pressure_threshold = NULL,
*tcp_mem_high_threshold = NULL;
if(unlikely(!tcp_mem_low_threshold)) {
tcp_mem_low_threshold = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_mem_low");
tcp_mem_pressure_threshold = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_mem_pressure");
tcp_mem_high_threshold = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_mem_high");
}
if(unlikely(!filename)) {
char buffer[FILENAME_MAX + 1];
snprintfz(buffer, FILENAME_MAX, "%s/proc/sys/net/ipv4/tcp_mem", netdata_configured_host_prefix);
filename = strdupz(buffer);
}
char buffer[200 + 1], *start, *end;
if(read_file(filename, buffer, 200) != 0) return 1;
buffer[200] = '\0';
unsigned long long low = 0, pressure = 0, high = 0;
start = buffer;
low = strtoull(start, &end, 10);
start = end;
pressure = strtoull(start, &end, 10);
start = end;
high = strtoull(start, &end, 10);
// fprintf(stderr, "TCP MEM low = %llu, pressure = %llu, high = %llu\n", low, pressure, high);
rrdvar_custom_host_variable_set(localhost, tcp_mem_low_threshold, low * sysconf(_SC_PAGESIZE) / 1024.0);
rrdvar_custom_host_variable_set(localhost, tcp_mem_pressure_threshold, pressure * sysconf(_SC_PAGESIZE) / 1024.0);
rrdvar_custom_host_variable_set(localhost, tcp_mem_high_threshold, high * sysconf(_SC_PAGESIZE) / 1024.0);
return 0;
}
static kernel_uint_t read_tcp_max_orphans(void) {
static char *filename = NULL;
static const RRDVAR_ACQUIRED *tcp_max_orphans_var = NULL;
if(unlikely(!filename)) {
char buffer[FILENAME_MAX + 1];
snprintfz(buffer, FILENAME_MAX, "%s/proc/sys/net/ipv4/tcp_max_orphans", netdata_configured_host_prefix);
filename = strdupz(buffer);
}
unsigned long long tcp_max_orphans = 0;
if(read_single_number_file(filename, &tcp_max_orphans) == 0) {
if(unlikely(!tcp_max_orphans_var))
tcp_max_orphans_var = rrdvar_custom_host_variable_add_and_acquire(localhost, "tcp_max_orphans");
rrdvar_custom_host_variable_set(localhost, tcp_max_orphans_var, tcp_max_orphans);
return tcp_max_orphans;
}
return 0;
}
int do_proc_net_sockstat(int update_every, usec_t dt) {
(void)dt;
static procfile *ff = NULL;
static uint32_t hash_sockets = 0,
hash_raw = 0,
hash_frag = 0,
hash_tcp = 0,
hash_udp = 0,
hash_udplite = 0;
static long long update_constants_every = 60, update_constants_count = 0;
static ARL_BASE *arl_sockets = NULL;
static ARL_BASE *arl_tcp = NULL;
static ARL_BASE *arl_udp = NULL;
static ARL_BASE *arl_udplite = NULL;
static ARL_BASE *arl_raw = NULL;
static ARL_BASE *arl_frag = NULL;
static int do_sockets = -1, do_tcp_sockets = -1, do_tcp_mem = -1, do_udp_sockets = -1, do_udp_mem = -1, do_udplite_sockets = -1, do_raw_sockets = -1, do_frag_sockets = -1, do_frag_mem = -1;
static char *keys[7] = { NULL };
static uint32_t hashes[7] = { 0 };
static ARL_BASE *bases[7] = { NULL };
if(unlikely(!arl_sockets)) {
do_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 sockets", CONFIG_BOOLEAN_AUTO);
do_tcp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 TCP sockets", CONFIG_BOOLEAN_AUTO);
do_tcp_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 TCP memory", CONFIG_BOOLEAN_AUTO);
do_udp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 UDP sockets", CONFIG_BOOLEAN_AUTO);
do_udp_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 UDP memory", CONFIG_BOOLEAN_AUTO);
do_udplite_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 UDPLITE sockets", CONFIG_BOOLEAN_AUTO);
do_raw_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 RAW sockets", CONFIG_BOOLEAN_AUTO);
do_frag_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG sockets", CONFIG_BOOLEAN_AUTO);
do_frag_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG memory", CONFIG_BOOLEAN_AUTO);
update_constants_every = config_get_number("plugin:proc:/proc/net/sockstat", "update constants every", update_constants_every);
update_constants_count = update_constants_every;
arl_sockets = arl_create("sockstat/sockets", arl_callback_str2kernel_uint_t, 60);
arl_expect(arl_sockets, "used", &sockstat_root.sockets_used);
arl_tcp = arl_create("sockstat/TCP", arl_callback_str2kernel_uint_t, 60);
arl_expect(arl_tcp, "inuse", &sockstat_root.tcp_inuse);
arl_expect(arl_tcp, "orphan", &sockstat_root.tcp_orphan);
arl_expect(arl_tcp, "tw", &sockstat_root.tcp_tw);
arl_expect(arl_tcp, "alloc", &sockstat_root.tcp_alloc);
arl_expect(arl_tcp, "mem", &sockstat_root.tcp_mem);
arl_udp = arl_create("sockstat/UDP", arl_callback_str2kernel_uint_t, 60);
arl_expect(arl_udp, "inuse", &sockstat_root.udp_inuse);
arl_expect(arl_udp, "mem", &sockstat_root.udp_mem);
arl_udplite = arl_create("sockstat/UDPLITE", arl_callback_str2kernel_uint_t, 60);
arl_expect(arl_udplite, "inuse", &sockstat_root.udplite_inuse);
arl_raw = arl_create("sockstat/RAW", arl_callback_str2kernel_uint_t, 60);
arl_expect(arl_raw, "inuse", &sockstat_root.raw_inuse);
arl_frag = arl_create("sockstat/FRAG", arl_callback_str2kernel_uint_t, 60);
arl_expect(arl_frag, "inuse", &sockstat_root.frag_inuse);
arl_expect(arl_frag, "memory", &sockstat_root.frag_memory);
hash_sockets = simple_hash("sockets");
hash_tcp = simple_hash("TCP");
hash_udp = simple_hash("UDP");
hash_udplite = simple_hash("UDPLITE");
hash_raw = simple_hash("RAW");
hash_frag = simple_hash("FRAG");
keys[0] = "sockets"; hashes[0] = hash_sockets; bases[0] = arl_sockets;
keys[1] = "TCP"; hashes[1] = hash_tcp; bases[1] = arl_tcp;
keys[2] = "UDP"; hashes[2] = hash_udp; bases[2] = arl_udp;
keys[3] = "UDPLITE"; hashes[3] = hash_udplite; bases[3] = arl_udplite;
keys[4] = "RAW"; hashes[4] = hash_raw; bases[4] = arl_raw;
keys[5] = "FRAG"; hashes[5] = hash_frag; bases[5] = arl_frag;
keys[6] = NULL; // terminator
}
update_constants_count += update_every;
if(unlikely(update_constants_count > update_constants_every)) {
read_tcp_max_orphans();
read_tcp_mem();
update_constants_count = 0;
}
if(unlikely(!ff)) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/sockstat");
ff = procfile_open(config_get("plugin:proc:/proc/net/sockstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
if(unlikely(!ff)) return 1;
}
ff = procfile_readall(ff);
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
size_t lines = procfile_lines(ff), l;
for(l = 0; l < lines ;l++) {
size_t words = procfile_linewords(ff, l);
char *key = procfile_lineword(ff, l, 0);
uint32_t hash = simple_hash(key);
int k;
for(k = 0; keys[k] ; k++) {
if(unlikely(hash == hashes[k] && strcmp(key, keys[k]) == 0)) {
// fprintf(stderr, "KEY: '%s', l=%zu, w=1, words=%zu\n", key, l, words);
ARL_BASE *arl = bases[k];
arl_begin(arl);
size_t w = 1;
while(w + 1 < words) {
char *name = procfile_lineword(ff, l, w); w++;
char *value = procfile_lineword(ff, l, w); w++;
// fprintf(stderr, " > NAME '%s', VALUE '%s', l=%zu, w=%zu, words=%zu\n", name, value, l, w, words);
if(unlikely(arl_check(arl, name, value) != 0))
break;
}
break;
}
}
}
// ------------------------------------------------------------------------
if(do_sockets == CONFIG_BOOLEAN_YES || (do_sockets == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.sockets_used ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_sockets = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_used = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_sockets"
, NULL
, "sockets"
, NULL
, "IPv4 Sockets Used"
, "sockets"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_SOCKETS
, update_every
, RRDSET_TYPE_LINE
);
rd_used = rrddim_add(st, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_used, (collected_number)sockstat_root.sockets_used);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_tcp_sockets == CONFIG_BOOLEAN_YES || (do_tcp_sockets == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.tcp_inuse ||
sockstat_root.tcp_orphan ||
sockstat_root.tcp_tw ||
sockstat_root.tcp_alloc ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_tcp_sockets = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_inuse = NULL,
*rd_orphan = NULL,
*rd_timewait = NULL,
*rd_alloc = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_tcp_sockets"
, NULL
, "tcp"
, NULL
, "IPv4 TCP Sockets"
, "sockets"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_TCP_SOCKETS
, update_every
, RRDSET_TYPE_LINE
);
rd_alloc = rrddim_add(st, "alloc", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_orphan = rrddim_add(st, "orphan", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_timewait = rrddim_add(st, "timewait", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.tcp_inuse);
rrddim_set_by_pointer(st, rd_orphan, (collected_number)sockstat_root.tcp_orphan);
rrddim_set_by_pointer(st, rd_timewait, (collected_number)sockstat_root.tcp_tw);
rrddim_set_by_pointer(st, rd_alloc, (collected_number)sockstat_root.tcp_alloc);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_tcp_mem == CONFIG_BOOLEAN_YES || (do_tcp_mem == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.tcp_mem || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_tcp_mem = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_mem = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_tcp_mem"
, NULL
, "tcp"
, NULL
, "IPv4 TCP Sockets Memory"
, "KiB"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_TCP_MEM
, update_every
, RRDSET_TYPE_AREA
);
rd_mem = rrddim_add(st, "mem", NULL, sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_mem, (collected_number)sockstat_root.tcp_mem);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_udp_sockets == CONFIG_BOOLEAN_YES || (do_udp_sockets == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.udp_inuse ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_udp_sockets = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_inuse = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_udp_sockets"
, NULL
, "udp"
, NULL
, "IPv4 UDP Sockets"
, "sockets"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_UDP
, update_every
, RRDSET_TYPE_LINE
);
rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.udp_inuse);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_udp_mem == CONFIG_BOOLEAN_YES || (do_udp_mem == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.udp_mem ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_udp_mem = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_mem = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_udp_mem"
, NULL
, "udp"
, NULL
, "IPv4 UDP Sockets Memory"
, "KiB"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_UDP_MEM
, update_every
, RRDSET_TYPE_AREA
);
rd_mem = rrddim_add(st, "mem", NULL, sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_mem, (collected_number)sockstat_root.udp_mem);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_udplite_sockets == CONFIG_BOOLEAN_YES || (do_udplite_sockets == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.udplite_inuse ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_udplite_sockets = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_inuse = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_udplite_sockets"
, NULL
, "udplite"
, NULL
, "IPv4 UDPLITE Sockets"
, "sockets"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_UDPLITE
, update_every
, RRDSET_TYPE_LINE
);
rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.udplite_inuse);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_raw_sockets == CONFIG_BOOLEAN_YES || (do_raw_sockets == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.raw_inuse ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_raw_sockets = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_inuse = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_raw_sockets"
, NULL
, "raw"
, NULL
, "IPv4 RAW Sockets"
, "sockets"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_RAW
, update_every
, RRDSET_TYPE_LINE
);
rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.raw_inuse);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_frag_sockets == CONFIG_BOOLEAN_YES || (do_frag_sockets == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.frag_inuse ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_frag_sockets = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_inuse = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_frag_sockets"
, NULL
, "fragments"
, NULL
, "IPv4 FRAG Sockets"
, "fragments"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_FRAGMENTS
, update_every
, RRDSET_TYPE_LINE
);
rd_inuse = rrddim_add(st, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_inuse, (collected_number)sockstat_root.frag_inuse);
rrdset_done(st);
}
// ------------------------------------------------------------------------
if(do_frag_mem == CONFIG_BOOLEAN_YES || (do_frag_mem == CONFIG_BOOLEAN_AUTO &&
(sockstat_root.frag_memory ||
netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES))) {
do_frag_mem = CONFIG_BOOLEAN_YES;
static RRDSET *st = NULL;
static RRDDIM *rd_mem = NULL;
if(unlikely(!st)) {
st = rrdset_create_localhost(
"ipv4"
, "sockstat_frag_mem"
, NULL
, "fragments"
, NULL
, "IPv4 FRAG Sockets Memory"
, "KiB"
, PLUGIN_PROC_NAME
, PLUGIN_PROC_MODULE_NET_SOCKSTAT_NAME
, NETDATA_CHART_PRIO_IPV4_FRAGMENTS_MEM
, update_every
, RRDSET_TYPE_AREA
);
rd_mem = rrddim_add(st, "mem", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(st);
rrddim_set_by_pointer(st, rd_mem, (collected_number)sockstat_root.frag_memory);
rrdset_done(st);
}
return 0;
}