summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3bd15a4)
raw | patch | inline | side by side (parent: 3bd15a4)
author | Damian Bogel <kele@google.com> | |
Wed, 9 Sep 2015 15:37:05 +0000 (11:37 -0400) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 6 Oct 2017 05:53:00 +0000 (07:53 +0200) |
Makefile.am | patch | blob | history | |
src/daemon/collectd.c | patch | blob | history | |
src/daemon/collectd.h | patch | blob | history | |
src/daemon/globals.c | [new file with mode: 0644] | patch | blob |
src/daemon/globals.h | [new file with mode: 0644] | patch | blob |
diff --git a/Makefile.am b/Makefile.am
index 04636b3fac6b54c9ce498e9e04d86372bd246c04..ae027a36881d75e2145919a545bfd426ab31b9fb 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
src/daemon/configfile.h \
src/daemon/filter_chain.c \
src/daemon/filter_chain.h \
+ src/daemon/globals.c \
+ src/daemon/globals.h \
src/daemon/meta_data.c \
src/daemon/meta_data.h \
src/daemon/plugin.c \
diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c
index af8fb568bb21db3254c38bb76d1911a1cafc8a30..9ab929b985521e38d40de49ea7ea98d236437985 100644 (file)
--- a/src/daemon/collectd.c
+++ b/src/daemon/collectd.c
#define COLLECTD_LOCALE "C"
#endif
-/*
- * Global variables
- */
-char hostname_g[DATA_MAX_NAME_LEN];
-cdtime_t interval_g;
-int timeout_g;
-#if HAVE_LIBKSTAT
-kstat_ctl_t *kc;
-#endif /* HAVE_LIBKSTAT */
-
static int loop = 0;
static void *do_flush(void __attribute__((unused)) * arg) {
str = global_option_get("Hostname");
if ((str != NULL) && (str[0] != 0)) {
- sstrncpy(hostname_g, str, sizeof(hostname_g));
+ sstrncpy(hostname_g, str, hostname_g_size);
return 0;
}
- if (gethostname(hostname_g, sizeof(hostname_g)) != 0) {
+ if (gethostname(hostname_g, hostname_g_size) != 0) {
fprintf(stderr, "`gethostname' failed and no "
"hostname was configured.\n");
return -1;
if (ai_ptr->ai_canonname == NULL)
continue;
- sstrncpy(hostname_g, ai_ptr->ai_canonname, sizeof(hostname_g));
+ sstrncpy(hostname_g, ai_ptr->ai_canonname, hostname_g_size);
break;
}
status);
return 1;
}
- } /* if (daemonize) */
+ } /* if (config.daemonize) */
#endif /* COLLECT_DAEMON */
struct sigaction sig_pipe_action = {.sa_handler = SIG_IGN};
}
#if COLLECT_DAEMON
- if (daemonize)
+ if (config.daemonize)
pidfile_remove();
#endif /* COLLECT_DAEMON */
diff --git a/src/daemon/collectd.h b/src/daemon/collectd.h
index 01d484ee082fa3b05edad7da08acf33f2a1f2c83..223119504be740141fd9a27850148f58bac93f10 100644 (file)
--- a/src/daemon/collectd.h
+++ b/src/daemon/collectd.h
#define GAUGE_FORMAT "%.15g"
#endif
-/* Type for time as used by "utils_time.h" */
-typedef uint64_t cdtime_t;
-
-extern char hostname_g[];
-extern cdtime_t interval_g;
-extern int timeout_g;
+#include "globals.h"
#endif /* COLLECTD_H */
diff --git a/src/daemon/globals.c b/src/daemon/globals.c
--- /dev/null
+++ b/src/daemon/globals.c
@@ -0,0 +1,13 @@
+#include "globals.h"
+#include "plugin.h"
+/*
+ * Global variables
+ */
+char hostname_g[DATA_MAX_NAME_LEN];
+const int hostname_g_size = sizeof (hostname_g);
+cdtime_t interval_g;
+int pidfile_from_cli = 0;
+int timeout_g;
+#if HAVE_LIBKSTAT
+kstat_ctl_t *kc;
+#endif /* HAVE_LIBKSTAT */
diff --git a/src/daemon/globals.h b/src/daemon/globals.h
--- /dev/null
+++ b/src/daemon/globals.h
@@ -0,0 +1,14 @@
+#ifndef GLOBALS_H
+#define GLOBALS_H
+
+#include <inttypes.h>
+
+/* Type for time as used by "utils_time.h" */
+typedef uint64_t cdtime_t;
+
+extern char hostname_g[];
+extern const int hostname_g_size;
+extern cdtime_t interval_g;
+extern int pidfile_from_cli;
+extern int timeout_g;
+#endif /* GLOBALS_H */