summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fc1ccf3)
raw | patch | inline | side by side (parent: fc1ccf3)
author | niki <niki> | |
Thu, 15 Dec 2005 12:11:40 +0000 (12:11 +0000) | ||
committer | niki <niki> | |
Thu, 15 Dec 2005 12:11:40 +0000 (12:11 +0000) |
diff --git a/src/Makefile.am b/src/Makefile.am
index fe1076b7fbddcd59266382bce86d35a13e90a14b..11a0862939c7cc77ebc51d429d6266ee57362646 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
multicast.c multicast.h \
plugin.c plugin.h
#collectd_CFLAGS = -DPLUGINDIR='"$(pkglibdir)"'
-collectd_CPPFLAGS = -DLOCALSTATEDIR='"$(localstatedir)"' -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) "-dlopen" self
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
diff --git a/src/collectd.c b/src/collectd.c
index 633d0230cdec080c7f5a924eba6e4e6fb44e112e..9932fd90a4830ed21f00104f3d940558c92a8913 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
"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"
"\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);
}
pid_t pid;
#endif
- char *plugindir = NULL;
- char *basedir = DATADIR;
+ char *confdir = SYSCONFDIR;
+ char *pidfile = PIDFILE;
+ char *plugindir = PLUGINDIR;
+ char *datadir = PKGLOCALSTATEDIR;
int daemonize = 1;
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 */
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;
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]);
return (1);
}
- 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);
}
#endif
start_client ();
- /*
- * close syslog
- */
+ /* close syslog */
syslog (LOG_INFO, "Exiting normally");
closelog ();
diff --git a/src/collectd.h b/src/collectd.h
index 1614483a28bcd350002879a33322ffad7ea039b5..0b63aa1a0451c33f8ca1d7c74bf44c7c6be218a6 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.h
# 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
-
#define MODE_SERVER 0x01
#define MODE_CLIENT 0x02
#define MODE_LOCAL 0x03
diff --git a/src/quota_mnt.c b/src/quota_mnt.c
index 53e1f9911cdb3001e4115be9082ed038f7a1cb87..ed42c7637f70ad4e82f155b1ea9708577da725c3 100644 (file)
--- a/src/quota_mnt.c
+++ b/src/quota_mnt.c
-/* *** *** *** local functions *** *** *** */
-
-
+/* *** *** *** ********************* *** *** *** */
+/* *** *** *** private functions *** *** *** */
#if 0
#if HAVE_GETMNTENT
diff --git a/src/quota_plugin.c b/src/quota_plugin.c
index 6dac92c0ee547822c83fab099d1973890a65442a..eb39aed3e39f2fe70d557b8d074b283e0f131d60 100644 (file)
--- a/src/quota_plugin.c
+++ b/src/quota_plugin.c
#define MODULE_NAME "quota"
-/* *** *** *** local constants *** *** *** */
+/* *** *** *** ********************* *** *** *** */
+/* *** *** *** private constants *** *** *** */
static const char *quota_filename_template = MODULE_NAME "-%s.rrd";
-
static char *quota_ds_def[] =
{
"DS:blocks:GAUGE:25:0:U",
};
static const int quota_ds_num = 10;
-/* *** *** *** local functions *** *** *** */
+static void quota_submit(quota_t *q);
+static void quota_init(void);
+static void quota_read(void);
+static void quota_write(char *host, char *inst, char *val);
+
+/* *** *** *** ********************* *** *** *** */
+/* *** *** *** private functions *** *** *** */
#define BUFSIZE 1024
static void
DBG("failed");
return;
}
+ /* quota-<type>-<name>-<id>-<path> */
+ /* quota-usrquota-niki-500-_img.rrd */
+ /* the '/' are converted to '_'... */
n = name = (char *)smalloc(strlen(q->type) + 1 + strlen(q->name)
+ 1 + strlen(q->id) + 1 + strlen(q->dir) + 1);
sstrncpy(n, q->type, strlen(q->type)+1);
} /* static void quota_submit(quota_t *q) */
#undef BUFSIZE
-/* *** *** *** local plugin functions *** *** *** */
+/* *** *** *** **************************** *** *** *** */
+/* *** *** *** private plugin functions *** *** *** */
static void
quota_init(void)
{
DBG_STARTFILE("quota debug file opened.");
-}
+} /* static void quota_init(void) */
static void
quota_read(void)
quota_fs_freequota(quota);
quota_mnt_freelist(list);
-}
+} /* static void quota_read(void) */
static void
quota_write(char *host, char *inst, char *val)
}
rrd_update_file(host, file, val, quota_ds_def, quota_ds_num);
-}
+} /* static void quota_write(char *host, char *inst, char *val) */
-/* *** *** *** global functions *** *** *** */
+/* *** *** *** ******************** *** *** *** */
+/* *** *** *** public functions *** *** *** */
void
module_register(void)
{
plugin_register(MODULE_NAME, quota_init, quota_read, quota_write);
-}
+} /* void module_register(void) */
diff --git a/src/quota_plugin.h b/src/quota_plugin.h
index 6dea2aabd16c62223d9168878e79c80ad13e26cb..cb6478591daf784951532c64e73477f043498bb7 100644 (file)
--- a/src/quota_plugin.h
+++ b/src/quota_plugin.h
#if !COLLECTD_QUOTA_PLUGIN_H
#define COLLECTD_QUOTA_PLUGIN_H 1
-#include "common.h"
-
void module_register(void);
#endif /* !COLLECTD_QUOTA_PLUGIN_H */
diff --git a/src/utils_debug.c b/src/utils_debug.c
index db59525e3f94a5497dd56597c98266ce54b52498..5b1900ddfd7bca23a4624f199665388ff6ba296f 100644 (file)
--- a/src/utils_debug.c
+++ b/src/utils_debug.c
#include "common.h"
#include "utils_debug.h"
-/* *** *** *** global variables *** *** *** */
#if COLLECT_DEBUG
#define DEFAULT_FILENAME "collectd.log"
const char *format, va_list ap);
/* if preemptive threads are used, these vars need some sort of locking! */
-/* pth is non-preemptive, so no locking is necessary (?) */
+/* pth is non-preemptive, so no locking is necessary */
static FILE *cu_debug_file = NULL;
static char *cu_debug_filename = NULL;