Code

Merged revisioni 312 to configfile branch
authorocto <octo>
Fri, 16 Dec 2005 10:11:34 +0000 (10:11 +0000)
committerocto <octo>
Fri, 16 Dec 2005 10:11:34 +0000 (10:11 +0000)
src/Makefile.am
src/collectd.c
src/collectd.h

index f4ac403ce21a5ac49ab12974d674f3abe504f02b..186c19b2c0eee9088b63e85a8ca4ed9882f62a04 100644 (file)
@@ -14,7 +14,11 @@ collectd_SOURCES = collectd.c collectd.h \
                   plugin.c plugin.h \
                   configfile.c configfile.h
 #collectd_CFLAGS = -DPLUGINDIR='"$(pkglibdir)"'
-collectd_CPPFLAGS = -DLOCALSTATEDIR='"$(localstatedir)"' -DSYSCONFDIR='"$(sysconfdir)"' -DPLUGINDIR='"$(pkglibdir)"'
+collectd_CPPFLAGS =
+collectd_CPPFLAGS += -DSYSCONFDIR='"${sysconfdir}"'
+collectd_CPPFLAGS += -DPKGLOCALSTATEDIR='"${localstatedir}/${PACKAGE_NAME}"'
+collectd_CPPFLAGS += -DPIDFILE='"${localstatedir}/run/${PACKAGE_NAME}.pid"'
+collectd_CPPFLAGS += -DPLUGINDIR='"${pkglibdir}"'
 collectd_LDFLAGS = -export-dynamic
 collectd_CFLAGS = -Werror
 collectd_LDADD = $(LIBLTDL) libconfig/libconfig.la "-dlopen" self
@@ -155,6 +159,7 @@ if BUILD_MODULE_USERS
 pkglib_LTLIBRARIES += users.la
 users_la_SOURCES = users.c users.h
 users_la_LDFLAGS = -module -avoid-version
+users_la_CFLAGS = -Werror
 collectd_LDADD += "-dlopen" users.la
 collectd_DEPENDENCIES += users.la
 endif
index ca7edb5408478bf8641b7110032d76f6fe30fee0..394ac84338a0a5914c1d9b74f11e42dc9178110f 100644 (file)
@@ -121,15 +121,19 @@ void exit_usage (char *name)
                        
                        "Available options:\n"
                        "  General:\n"
-                       "    -d <dir>        Base directory to use.\n"
+                       "    -C <dir>        Configuration directory.\n"
                        "                    Default: %s\n"
-                       "    -P <dir>        Set the plugin-directory\n"
+                       "    -P <file>       PID File.\n"
                        "                    Default: %s\n"
-                       "    -f              Don't fork to the background\n"
+                       "    -M <dir>        Module/Plugin directory.\n"
+                       "                    Default: %s\n"
+                       "    -D <dir>        Data storage directory.\n"
+                       "                    Default: %s\n"
+                       "    -f              Don't fork to the background.\n"
 #ifdef HAVE_LIBRRD
-                       "    -l              Start in local mode (no network)\n"
-                       "    -c              Start in client (sender) mode\n"
-                       "    -s              Start in server (listener) mode\n"
+                       "    -l              Start in local mode (no network).\n"
+                       "    -c              Start in client (sender) mode.\n"
+                       "    -s              Start in server (listener) mode.\n"
 #endif /* HAVE_LIBRRD */
 #if COLLECT_PING
                        "  Ping:\n"
@@ -139,7 +143,7 @@ void exit_usage (char *name)
                        "\n%s %s, http://verplant.org/collectd/\n"
                        "by Florian octo Forster <octo@verplant.org>\n"
                        "for contributions see `AUTHORS'\n",
-                       PACKAGE, DATADIR, PLUGINDIR, PACKAGE, VERSION);
+                       PACKAGE, SYSCONFDIR, PIDFILE, PLUGINDIR, PKGLOCALSTATEDIR, PACKAGE, VERSION);
        exit (0);
 }
 
@@ -239,9 +243,10 @@ int main (int argc, char **argv)
        pid_t pid;
 #endif
 
-       char *plugindir = NULL;
-       char *basedir = DATADIR;
-       char *configfile = NULL;
+       char *confdir = SYSCONFDIR;
+       char *pidfile =  PIDFILE;
+       char *plugindir = PLUGINDIR;
+       char *datadir = PKGLOCALSTATEDIR;
 
        int daemonize = 1;
 
@@ -249,19 +254,15 @@ int main (int argc, char **argv)
        operating_mode = MODE_LOCAL;
 #endif
        
-       /*
-        * open syslog
-        */
+       /* open syslog */
        openlog (PACKAGE, LOG_CONS | LOG_PID, LOG_DAEMON);
 
-       /*
-        * read options
-        */
+       /* read options */
        while (1)
        {
                int c;
 
-               c = getopt (argc, argv, "d:fP:h"
+               c = getopt (argc, argv, "C:P:M:D:fh"
 #if HAVE_LIBRRD
                                "csl"
 #endif /* HAVE_LIBRRD */
@@ -288,8 +289,17 @@ int main (int argc, char **argv)
                                operating_mode = MODE_LOCAL;
                                break;
 #endif /* HAVE_LIBRRD */
-                       case 'd':
-                               basedir = optarg;
+                       case 'C':
+                               confdir = optarg;
+                               break;
+                       case 'P':
+                               pidfile = optarg;
+                               break;
+                       case 'M':
+                               plugindir = optarg;
+                               break;
+                       case 'D':
+                               datadir = optarg;
                                break;
                        case 'f':
                                daemonize = 0;
@@ -302,10 +312,6 @@ int main (int argc, char **argv)
                                        fprintf (stderr, "Maximum of %i ping hosts reached.\n", MAX_PINGHOSTS);
                                break;
 #endif /* COLLECT_PING */
-                       case 'P':
-                               plugindir = optarg;
-                               break;
-
                        case 'h':
                        default:
                                exit_usage (argv[0]);
@@ -329,9 +335,9 @@ int main (int argc, char **argv)
         * Change directory. We do this _after_ reading the config and loading
         * modules to relative paths work as expected.
         */
-       if (change_basedir (basedir))
+       if (change_basedir (datadir))
        {
-               fprintf (stderr, "Error: Unable to change to directory `%s'.\n", basedir);
+               fprintf (stderr, "Error: Unable to change to directory `%s'.\n", datadir);
                return (1);
        }
 
@@ -403,9 +409,7 @@ int main (int argc, char **argv)
 #endif
                start_client ();
 
-       /*
-        * close syslog
-        */
+       /* close syslog */
        syslog (LOG_INFO, "Exiting normally");
        closelog ();
 
index 32b9735d1b77c2ae094fd9ac44440cc8ddddb0f7..7a3eb8d5bb51fa280964d428fa11408936a28535 100644 (file)
 # include <ctype.h>
 #endif
 
+#if HAVE_SYSLOG
+# define syslog(...) syslog(__VA_ARGS__)
+# if HAVE_OPENLOG
+#  define openlog(...) openlog(__VA_ARGS__)
+# else
+#  define openlog(...) /**/
+# endif
+# if HAVE_CLOSELOG
+#  define closelog(...) closelog(__VA_ARGS__)
+# else
+#  define closelog(...) /**/
+# endif
+#else
+# define syslog(...) /**/
+# define openlog(...) /**/
+# define closelog(...) /**/
+#endif
+
 #ifndef HAVE_RRD_H
 #undef HAVE_LIBRRD
 #endif
 #include <statgrab.h>
 #endif
 
-#ifndef LOCALSTATEDIR
-#define LOCALSTATEDIR "/opt/collectd/var"
-#endif
-
-#ifndef DATADIR
-#define DATADIR LOCALSTATEDIR"/lib/collectd"
-#endif
-
-#ifndef PLUGINDIR
-#define PLUGINDIR "/opt/collectd/lib/collectd"
-#endif
-
-#ifndef PIDFILE
-#define PIDFILE LOCALSTATEDIR"/run/collectd.pid"
-#endif
-
 #ifndef SYSCONFDIR
 #define SYSCONFDIR "/opt/collectd/etc"
 #endif