size_t count = 0;
- while(likely(1)) {
+ for(;;) {
if(unlikely(netdata_exit)) break;
FILE *fp = mypopen(cd->cmd, &cd->pid);
info("PLUGINSD: '%s' running on pid %d", cd->fullfilename, cd->pid);
RRDSET *st = NULL;
- char *s;
uint32_t hash;
while(likely(fgets(line, PLUGINSD_LINE_MAX, fp) != NULL)) {
// debug(D_PLUGINSD, "PLUGINSD: %s: %s", cd->filename, line);
int w = pluginsd_split_words(line, words, MAX_WORDS);
- s = words[0];
+ char *s = words[0];
if(unlikely(!s || !*s || !w)) {
// debug(D_PLUGINSD, "PLUGINSD: empty line");
continue;
unsigned long long microseconds = 0;
if(microseconds_txt && *microseconds_txt) microseconds = strtoull(microseconds_txt, NULL, 10);
if(microseconds) rrdset_next_usec(st, microseconds);
- else rrdset_next_plugins(st);
+ else rrdset_next(st);
}
}
else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
error("PLUGINSD: %s sleeping for %llu. Will kill with SIGCONT pid %d to wake it up.\n", cd->fullfilename, susec, cd->pid);
usleep(susec);
killpid(cd->pid, SIGCONT);
- bcopy(&now, &last, sizeof(struct timeval));
+ memmove(&last, &now, sizeof(struct timeval));
break;
}
#endif
// get the return code
int code = mypclose(fp, cd->pid);
-
- if(netdata_exit) {
- cd->pid = 0;
- cd->enabled = 0;
- cd->obsolete = 1;
- pthread_exit(NULL);
- return NULL;
- }
-
- if(code != 0) {
+
+ if(unlikely(netdata_exit)) break;
+ else if(code != 0) {
// the plugin reports failure
if(likely(!cd->successful_collections)) {
// we have collected something
if(likely(cd->serial_failures <= 10)) {
- error("PLUGINSD: '%s' exited with error code %d, but has given useful output in the past (%zu times). Waiting a bit before starting it again.", cd->fullfilename, code, cd->successful_collections);
+ error("PLUGINSD: '%s' exited with error code %d, but has given useful output in the past (%zu times). %s", cd->fullfilename, code, cd->successful_collections, cd->enabled?"Waiting a bit before starting it again.":"Will not start it again - it is disabled.");
sleep((unsigned int) (cd->update_every * 10));
}
else {
// we have collected nothing so far
if(likely(cd->serial_failures <= 10)) {
- error("PLUGINSD: '%s' (pid %d) does not generate useful output but it reports success (exits with 0). Waiting a bit before starting it again.", cd->fullfilename, cd->pid);
+ error("PLUGINSD: '%s' (pid %d) does not generate useful output but it reports success (exits with 0). %s.", cd->fullfilename, cd->pid, cd->enabled?"Waiting a bit before starting it again.":"Will not start it again - it is disabled.");
sleep((unsigned int) (cd->update_every * 10));
}
else {
}
cd->pid = 0;
- if(unlikely(!cd->enabled))
- break;
+ if(unlikely(!cd->enabled)) break;
}
+ info("PLUGINSD: '%s' thread exiting", cd->fullfilename);
+
cd->obsolete = 1;
pthread_exit(NULL);
return NULL;
if(scan_frequency < 1) scan_frequency = 1;
- while(likely(1)) {
+ for(;;) {
if(unlikely(netdata_exit)) break;
dir = opendir(dir_name);
sleep((unsigned int) scan_frequency);
}
+ info("PLUGINS.D thread exiting");
+
pthread_exit(NULL);
return NULL;
}