summaryrefslogtreecommitdiffstats
path: root/src/collectors/plugins.d/plugins_d.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/collectors/plugins.d/plugins_d.c (renamed from collectors/plugins.d/plugins_d.c)94
1 files changed, 46 insertions, 48 deletions
diff --git a/collectors/plugins.d/plugins_d.c b/src/collectors/plugins.d/plugins_d.c
index 20061ad29..0bcb3df63 100644
--- a/collectors/plugins.d/plugins_d.c
+++ b/src/collectors/plugins.d/plugins_d.c
@@ -140,67 +140,65 @@ static void pluginsd_worker_thread_handle_error(struct plugind *cd, int worker_r
static void *pluginsd_worker_thread(void *arg) {
worker_register("PLUGINSD");
- netdata_thread_cleanup_push(pluginsd_worker_thread_cleanup, arg);
+ netdata_thread_cleanup_push(pluginsd_worker_thread_cleanup, arg)
+ {
+ struct plugind *cd = (struct plugind *) arg;
+ plugin_set_running(cd);
- {
- struct plugind *cd = (struct plugind *) arg;
- plugin_set_running(cd);
+ size_t count = 0;
- 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);
- 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)) {
- netdata_log_error("PLUGINSD: 'host:%s', cannot popen(\"%s\", \"r\").",
- rrdhost_hostname(cd->host), cd->cmd);
- break;
- }
-
- nd_log(NDLS_DAEMON, NDLP_DEBUG,
- "PLUGINSD: 'host:%s' connected to '%s' running on pid %d",
- rrdhost_hostname(cd->host),
- cd->fullfilename, cd->unsafe.pid);
+ if(unlikely(!fp_child_input || !fp_child_output)) {
+ netdata_log_error("PLUGINSD: 'host:%s', cannot popen(\"%s\", \"r\").",
+ rrdhost_hostname(cd->host), cd->cmd);
+ break;
+ }
- const char *plugin = strrchr(cd->fullfilename, '/');
- if(plugin)
- plugin++;
- else
- plugin = cd->fullfilename;
+ nd_log(NDLS_DAEMON, NDLP_DEBUG,
+ "PLUGINSD: 'host:%s' connected to '%s' running on pid %d",
+ rrdhost_hostname(cd->host),
+ cd->fullfilename, cd->unsafe.pid);
- char module[100];
- snprintfz(module, sizeof(module), "plugins.d[%s]", plugin);
- ND_LOG_STACK lgs[] = {
- ND_LOG_FIELD_TXT(NDF_MODULE, module),
- ND_LOG_FIELD_TXT(NDF_NIDL_NODE, rrdhost_hostname(cd->host)),
- ND_LOG_FIELD_TXT(NDF_SRC_TRANSPORT, "pluginsd"),
- ND_LOG_FIELD_END(),
- };
- ND_LOG_STACK_PUSH(lgs);
+ const char *plugin = strrchr(cd->fullfilename, '/');
+ if(plugin)
+ plugin++;
+ else
+ plugin = cd->fullfilename;
- count = pluginsd_process(cd->host, cd, fp_child_input, fp_child_output, 0);
+ char module[100];
+ snprintfz(module, sizeof(module), "plugins.d[%s]", plugin);
+ ND_LOG_STACK lgs[] = {
+ ND_LOG_FIELD_TXT(NDF_MODULE, module),
+ ND_LOG_FIELD_TXT(NDF_NIDL_NODE, rrdhost_hostname(cd->host)),
+ ND_LOG_FIELD_TXT(NDF_SRC_TRANSPORT, "pluginsd"),
+ ND_LOG_FIELD_END(),
+ };
+ ND_LOG_STACK_PUSH(lgs);
- 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);
+ count = pluginsd_process(cd->host, cd, fp_child_input, fp_child_output, 0);
- killpid(cd->unsafe.pid);
+ 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);
- int worker_ret_code = netdata_pclose(fp_child_input, fp_child_output, cd->unsafe.pid);
+ killpid(cd->unsafe.pid);
- if(likely(worker_ret_code == 0))
- pluginsd_worker_thread_handle_success(cd);
- else
- pluginsd_worker_thread_handle_error(cd, worker_ret_code);
+ int worker_ret_code = netdata_pclose(fp_child_input, fp_child_output, cd->unsafe.pid);
- cd->unsafe.pid = 0;
+ if(likely(worker_ret_code == 0))
+ pluginsd_worker_thread_handle_success(cd);
+ else
+ pluginsd_worker_thread_handle_error(cd, worker_ret_code);
- if(unlikely(!plugin_is_enabled(cd)))
- break;
- }
- }
+ cd->unsafe.pid = 0;
+ if(unlikely(!plugin_is_enabled(cd)))
+ break;
+ }
+ }
netdata_thread_cleanup_pop(1);
return NULL;
}