From: niki Date: Sat, 17 Dec 2005 03:27:30 +0000 (+0000) Subject: cleanup, pidfile_remove bugfix, options (configdir?) X-Git-Tag: collectd-3.6.0~45 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f92d4465f4dc3d819cbc917ad2abf2a108521f6c;p=collectd.git cleanup, pidfile_remove bugfix, options (configdir?) --- diff --git a/src/Makefile.am b/src/Makefile.am index 6b85c035..bd2d25f4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ collectd_SOURCES = collectd.c collectd.h \ #collectd_CFLAGS = -DPLUGINDIR='"$(pkglibdir)"' collectd_CPPFLAGS = $(LTDLINCL) collectd_CPPFLAGS += -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"' +collectd_CPPFLAGS += -DCONFIGDIR='"${sysconfdir}/${PACKAGE_NAME}.d"' collectd_CPPFLAGS += -DPKGLOCALSTATEDIR='"${localstatedir}/lib/${PACKAGE_NAME}"' if BUILD_FEATURE_DAEMON collectd_CPPFLAGS += -DPIDFILE='"${localstatedir}/run/${PACKAGE_NAME}.pid"' diff --git a/src/collectd.c b/src/collectd.c index 5458a2ca..c7ea35b6 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -49,12 +49,14 @@ time_t curtime; int operating_mode; #endif -static void sigIntHandler (int signal) +static void +sigIntHandler (int signal) { loop++; } -static int change_basedir (char *dir) +static int +change_basedir (char *dir) { int dirlen = strlen (dir); @@ -90,7 +92,8 @@ static int change_basedir (char *dir) } /* static int change_basedir (char *dir) */ #ifdef HAVE_LIBKSTAT -static void update_kstat (void) +static void +update_kstat (void) { if (kc == NULL) { @@ -115,15 +118,20 @@ static void update_kstat (void) } /* static void update_kstat (void) */ #endif /* HAVE_LIBKSTAT */ -static void exit_usage (char *name) +static void +exit_usage (char *name) { printf ("Usage: "PACKAGE" [OPTIONS]\n\n" "Available options:\n" " General:\n" - /* " -C Configuration file.\n" " Default: "CONFIGFILE"\n" + /* sure you want a configFILE? + what about a configDIR? - niki */ + /* + " -C Configuration directory.\n" + " Default: "CONFIGDIR"\n" */ #if COLLECT_DAEMON " -P PID file.\n" @@ -156,7 +164,8 @@ static void exit_usage (char *name) exit (0); } /* static void exit_usage (char *name) */ -static int start_client (void) +static int +start_client (void) { int sleepingtime; @@ -202,7 +211,8 @@ static int start_client (void) } /* static int start_client (void) */ #ifdef HAVE_LIBRRD -static int start_server (void) +static int +start_server (void) { char *host; char *type; @@ -225,7 +235,8 @@ static int start_server (void) #endif /* HAVE_LIBRRD */ #if COLLECT_DAEMON -static int pidfile_create (char *file) +static int +pidfile_create (const char *file) { FILE *fh; @@ -242,20 +253,26 @@ static int pidfile_create (char *file) fclose(fh); return (0); -} /* static int pidfile_create (char *file) */ +} /* static int pidfile_create (const char *file) */ #endif /* COLLECT_DAEMON */ #if COLLECT_DAEMON -static int pidfile_remove (void) +static int +pidfile_remove (const char *file) { - return (unlink (PIDFILE)); -} /* static int pidfile_remove (void) */ + if (file == NULL) { + file = PIDFILE; + } + return (unlink (file)); +} /* static int pidfile_remove (const char *file) */ #endif /* COLLECT_DAEMON */ -int main (int argc, char **argv) +int +main (int argc, char **argv) { struct sigaction sigIntAction, sigChldAction; char *configfile = CONFIGFILE; +/* or char *configdir = CONFIGDIR; */ char *plugindir = PLUGINDIR; char *datadir = PKGLOCALSTATEDIR; #if COLLECT_DAEMON @@ -314,6 +331,7 @@ int main (int argc, char **argv) #endif /* HAVE_LIBRRD */ case 'C': configfile = optarg; + /* configdir = optarg; */ break; #if COLLECT_DAEMON case 'P': @@ -442,8 +460,8 @@ int main (int argc, char **argv) #if COLLECT_DAEMON if (daemonize) - pidfile_remove(); + pidfile_remove(pidfile); #endif /* COLLECT_DAEMON */ return (0); -} +} /* int main (int argc, char **argv) */ diff --git a/src/collectd.h b/src/collectd.h index 922aebf1..a469bd4d 100644 --- a/src/collectd.h +++ b/src/collectd.h @@ -192,4 +192,6 @@ extern time_t curtime; extern int operating_mode; +int main (int argc, char **argv); + #endif /* COLLECTD_H */