summaryrefslogtreecommitdiffstats
path: root/src/collectors/plugins.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/collectors/plugins.d')
-rw-r--r--src/collectors/plugins.d/README.md2
-rw-r--r--src/collectors/plugins.d/local_listeners.c26
-rw-r--r--src/collectors/plugins.d/ndsudo.c49
-rw-r--r--src/collectors/plugins.d/plugins_d.c41
-rw-r--r--src/collectors/plugins.d/plugins_d.h1
-rw-r--r--src/collectors/plugins.d/pluginsd_internals.c2
6 files changed, 89 insertions, 32 deletions
diff --git a/src/collectors/plugins.d/README.md b/src/collectors/plugins.d/README.md
index a1549af4..6b53dbed 100644
--- a/src/collectors/plugins.d/README.md
+++ b/src/collectors/plugins.d/README.md
@@ -20,7 +20,7 @@ from external processes, thus allowing Netdata to use **external plugins**.
| [charts.d.plugin](/src/collectors/charts.d.plugin/README.md) | `BASH` | all | a **plugin orchestrator** for data collection modules written in `BASH` v4+. |
| [cups.plugin](/src/collectors/cups.plugin/README.md) | `C` | all | monitors **CUPS** |
| [ebpf.plugin](/src/collectors/ebpf.plugin/README.md) | `C` | linux | monitors different metrics on environments using kernel internal functions. |
-| [go.d.plugin](/src/go/collectors/go.d.plugin/README.md) | `GO` | all | collects metrics from the system, applications, or third-party APIs. |
+| [go.d.plugin](/src/go/plugin/go.d/README.md) | `GO` | all | collects metrics from the system, applications, or third-party APIs. |
| [ioping.plugin](/src/collectors/ioping.plugin/README.md) | `C` | all | measures disk latency. |
| [freeipmi.plugin](/src/collectors/freeipmi.plugin/README.md) | `C` | linux | collects metrics from enterprise hardware sensors, on Linux servers. |
| [nfacct.plugin](/src/collectors/nfacct.plugin/README.md) | `C` | linux | collects netfilter firewall, connection tracker and accounting metrics using `libmnl` and `libnetfilter_acct`. |
diff --git a/src/collectors/plugins.d/local_listeners.c b/src/collectors/plugins.d/local_listeners.c
index 2829b3e3..2a729b34 100644
--- a/src/collectors/plugins.d/local_listeners.c
+++ b/src/collectors/plugins.d/local_listeners.c
@@ -15,6 +15,14 @@ static const char *protocol_name(LOCAL_SOCKET *n) {
else
return "UNKNOWN_IPV4";
}
+ else if(is_local_socket_ipv46(n)) {
+ if (n->local.protocol == IPPROTO_TCP)
+ return "TCP46";
+ else if(n->local.protocol == IPPROTO_UDP)
+ return "UDP46";
+ else
+ return "UNKNOWN_IPV46";
+ }
else if(n->local.family == AF_INET6) {
if (n->local.protocol == IPPROTO_TCP)
return "TCP6";
@@ -35,6 +43,10 @@ static void print_local_listeners(LS_STATE *ls __maybe_unused, LOCAL_SOCKET *n,
ipv4_address_to_txt(n->local.ip.ipv4, local_address);
ipv4_address_to_txt(n->remote.ip.ipv4, remote_address);
}
+ else if(is_local_socket_ipv46(n)) {
+ strncpyz(local_address, "*", sizeof(local_address) - 1);
+ remote_address[0] = '\0';
+ }
else if(n->local.family == AF_INET6) {
ipv6_address_to_txt(&n->local.ip.ipv6, local_address);
ipv6_address_to_txt(&n->remote.ip.ipv6, remote_address);
@@ -93,8 +105,10 @@ int main(int argc, char **argv) {
.cmdline = true,
.comm = false,
.namespaces = true,
+ .tcp_info = false,
.max_errors = 10,
+ .max_concurrent_namespaces = 10,
.cb = print_local_listeners,
.data = NULL,
@@ -212,6 +226,7 @@ int main(int argc, char **argv) {
ls.config.comm = true;
ls.config.cmdline = true;
ls.config.namespaces = true;
+ ls.config.tcp_info = true;
ls.config.uid = true;
ls.config.max_errors = SIZE_MAX;
ls.config.cb = print_local_listeners_debug;
@@ -276,8 +291,17 @@ int main(int argc, char **argv) {
}
}
+ SPAWN_SERVER *spawn_server = spawn_server_create(SPAWN_SERVER_OPTION_CALLBACK, NULL, local_sockets_spawn_server_callback, argc, (const char **)argv);
+ if(spawn_server == NULL) {
+ fprintf(stderr, "Cannot create spawn server.\n");
+ exit(1);
+ }
+ ls.spawn_server = spawn_server;
+
local_sockets_process(&ls);
+ spawn_server_destroy(spawn_server);
+
getrusage(RUSAGE_SELF, &ended);
if(debug) {
@@ -285,7 +309,7 @@ int main(int argc, char **argv) {
unsigned long long system = ended.ru_stime.tv_sec * 1000000ULL + ended.ru_stime.tv_usec - started.ru_stime.tv_sec * 1000000ULL + started.ru_stime.tv_usec;
unsigned long long total = user + system;
- fprintf(stderr, "CPU Usage %llu user, %llu system, %llu total\n", user, system, total);
+ fprintf(stderr, "CPU Usage %llu user, %llu system, %llu total, %zu namespaces, %zu nl requests (without namespaces)\n", user, system, total, ls.stats.namespaces_found, ls.stats.mnl_sends);
}
return 0;
diff --git a/src/collectors/plugins.d/ndsudo.c b/src/collectors/plugins.d/ndsudo.c
index d53ca9f2..d2cf4fae 100644
--- a/src/collectors/plugins.d/ndsudo.c
+++ b/src/collectors/plugins.d/ndsudo.c
@@ -14,6 +14,31 @@ struct command {
const char *search[MAX_SEARCH];
} allowed_commands[] = {
{
+ .name = "exim-bpc",
+ .params = "-bpc",
+ .search =
+ {
+ [0] = "exim",
+ [1] = NULL,
+ },
+ },
+ {
+ .name = "nsd-control-stats",
+ .params = "stats_noreset",
+ .search = {
+ [0] = "nsd-control",
+ [1] = NULL,
+ },
+ },
+ {
+ .name = "chronyc-serverstats",
+ .params = "serverstats",
+ .search = {
+ [0] = "chronyc",
+ [1] = NULL,
+ },
+ },
+ {
.name = "dmsetup-status-cache",
.params = "status --target cache --noflush",
.search = {
@@ -38,6 +63,14 @@ struct command {
},
},
{
+ .name = "smartctl-json-scan-open",
+ .params = "--json --scan-open",
+ .search = {
+ [0] = "smartctl",
+ [1] = NULL,
+ },
+ },
+ {
.name = "smartctl-json-device-info",
.params = "--json --all {{deviceName}} --device {{deviceType}} --nocheck {{powerMode}}",
.search = {
@@ -54,6 +87,14 @@ struct command {
},
},
{
+ .name = "fail2ban-client-status-socket",
+ .params = "-s {{socket_path}} status",
+ .search = {
+ [0] = "fail2ban-client",
+ [1] = NULL,
+ },
+ },
+ {
.name = "fail2ban-client-status-jail",
.params = "status {{jail}}",
.search = {
@@ -62,6 +103,14 @@ struct command {
},
},
{
+ .name = "fail2ban-client-status-jail-socket",
+ .params = "-s {{socket_path}} status {{jail}}",
+ .search = {
+ [0] = "fail2ban-client",
+ [1] = NULL,
+ },
+ },
+ {
.name = "storcli-controllers-info",
.params = "/cALL show all J nolog",
.search = {
diff --git a/src/collectors/plugins.d/plugins_d.c b/src/collectors/plugins.d/plugins_d.c
index f5f55b77..85f1563c 100644
--- a/src/collectors/plugins.d/plugins_d.c
+++ b/src/collectors/plugins.d/plugins_d.c
@@ -68,23 +68,15 @@ static void pluginsd_worker_thread_cleanup(void *pptr) {
cd->unsafe.running = false;
cd->unsafe.thread = 0;
- pid_t pid = cd->unsafe.pid;
cd->unsafe.pid = 0;
- spinlock_unlock(&cd->unsafe.spinlock);
-
- if (pid) {
- siginfo_t info;
- netdata_log_info("PLUGINSD: 'host:%s', killing data collection child process with pid %d",
- rrdhost_hostname(cd->host), pid);
+ POPEN_INSTANCE *pi = cd->unsafe.pi;
+ cd->unsafe.pi = NULL;
- if (killpid(pid) != -1) {
- netdata_log_info("PLUGINSD: 'host:%s', waiting for data collection child process pid %d to exit...",
- rrdhost_hostname(cd->host), pid);
+ spinlock_unlock(&cd->unsafe.spinlock);
- netdata_waitid(P_PID, (id_t)pid, &info, WEXITED);
- }
- }
+ if (pi)
+ spawn_popen_kill(pi);
}
#define SERIAL_FAILURES_THRESHOLD 10
@@ -160,14 +152,13 @@ static void *pluginsd_worker_thread(void *arg) {
size_t count = 0;
while(service_running(SERVICE_COLLECTORS)) {
- FILE *fp_child_input = NULL;
- FILE *fp_child_output = netdata_popen(cd->cmd, &cd->unsafe.pid, &fp_child_input);
-
- if(unlikely(!fp_child_input || !fp_child_output)) {
+ cd->unsafe.pi = spawn_popen_run(cd->cmd);
+ if(!cd->unsafe.pi) {
netdata_log_error("PLUGINSD: 'host:%s', cannot popen(\"%s\", \"r\").",
rrdhost_hostname(cd->host), cd->cmd);
break;
}
+ cd->unsafe.pid = spawn_server_instance_pid(cd->unsafe.pi->si);
nd_log(NDLS_DAEMON, NDLP_DEBUG,
"PLUGINSD: 'host:%s' connected to '%s' running on pid %d",
@@ -190,15 +181,14 @@ static void *pluginsd_worker_thread(void *arg) {
};
ND_LOG_STACK_PUSH(lgs);
- count = pluginsd_process(cd->host, cd, fp_child_input, fp_child_output, 0);
+ count = pluginsd_process(cd->host, cd, cd->unsafe.pi->child_stdin_fp, cd->unsafe.pi->child_stdout_fp, 0);
nd_log(NDLS_DAEMON, NDLP_DEBUG,
"PLUGINSD: 'host:%s', '%s' (pid %d) disconnected after %zu successful data collections (ENDs).",
rrdhost_hostname(cd->host), cd->fullfilename, cd->unsafe.pid, count);
- killpid(cd->unsafe.pid);
-
- int worker_ret_code = netdata_pclose(fp_child_input, fp_child_output, cd->unsafe.pid);
+ int worker_ret_code = spawn_popen_kill(cd->unsafe.pi);
+ cd->unsafe.pi = NULL;
if(likely(worker_ret_code == 0))
pluginsd_worker_thread_handle_success(cd);
@@ -248,13 +238,6 @@ void *pluginsd_main(void *ptr) {
// disable some plugins by default
config_get_boolean(CONFIG_SECTION_PLUGINS, "slabinfo", CONFIG_BOOLEAN_NO);
- config_get_boolean(CONFIG_SECTION_PLUGINS, "logs-management",
-#if defined(LOGS_MANAGEMENT_DEV_MODE)
- CONFIG_BOOLEAN_YES
-#else
- CONFIG_BOOLEAN_NO
-#endif
- );
// it crashes (both threads) on Alpine after we made it multi-threaded
// works with "--device /dev/ipmi0", but this is not default
// see https://github.com/netdata/netdata/pull/15564 for details
@@ -273,7 +256,7 @@ void *pluginsd_main(void *ptr) {
if (unlikely(!service_running(SERVICE_COLLECTORS)))
break;
- errno = 0;
+ errno_clear();
DIR *dir = opendir(directory_name);
if (unlikely(!dir)) {
if (directory_errors[idx] != errno) {
diff --git a/src/collectors/plugins.d/plugins_d.h b/src/collectors/plugins.d/plugins_d.h
index ec17c314..51efa5a7 100644
--- a/src/collectors/plugins.d/plugins_d.h
+++ b/src/collectors/plugins.d/plugins_d.h
@@ -34,6 +34,7 @@ struct plugind {
bool running; // do not touch this structure after setting this to 1
bool enabled; // if this is enabled or not
ND_THREAD *thread;
+ POPEN_INSTANCE *pi;
pid_t pid;
} unsafe;
diff --git a/src/collectors/plugins.d/pluginsd_internals.c b/src/collectors/plugins.d/pluginsd_internals.c
index d03daf74..31f0f753 100644
--- a/src/collectors/plugins.d/pluginsd_internals.c
+++ b/src/collectors/plugins.d/pluginsd_internals.c
@@ -13,7 +13,7 @@ ssize_t send_to_plugin(const char *txt, void *data) {
return h2o_stream_write(parser->h2o_ctx, txt, strlen(txt));
#endif
- errno = 0;
+ errno_clear();
spinlock_lock(&parser->writer.spinlock);
ssize_t bytes = -1;