From: octo Date: Sat, 17 Dec 2005 08:49:23 +0000 (+0000) Subject: Took a closer `look' at last nights changes.. X-Git-Tag: collectd-3.6.0~41 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f4d470590b45f3380170acc9e3a1b5e428524e23;p=collectd.git Took a closer `look' at last nights changes.. --- diff --git a/TODO b/TODO index edb073f5..f98488fe 100644 --- a/TODO +++ b/TODO @@ -3,3 +3,4 @@ For version 3.*: * Port tape module to Linux * Maybe look into porting the serial module * Ping bug (disabled) +* Handle sigterm diff --git a/src/Makefile.am b/src/Makefile.am index bd2d25f4..6b85c035 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,6 @@ 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 af3d1061..76c62d9c 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -49,14 +49,12 @@ 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); @@ -92,8 +90,7 @@ change_basedir (char *dir) } /* static int change_basedir (char *dir) */ #if HAVE_LIBKSTAT -static void -update_kstat (void) +static void update_kstat (void) { if (kc == NULL) { @@ -118,8 +115,7 @@ 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" @@ -127,12 +123,6 @@ exit_usage (char *name) " 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" " Default: "PIDFILE"\n" @@ -164,8 +154,7 @@ exit_usage (char *name) exit (0); } /* static void exit_usage (char *name) */ -static int -start_client (void) +static int start_client (void) { int sleepingtime; @@ -211,8 +200,7 @@ start_client (void) } /* static int start_client (void) */ #if HAVE_LIBRRD -static int -start_server (void) +static int start_server (void) { char *host; char *type; @@ -235,8 +223,7 @@ start_server (void) #endif /* HAVE_LIBRRD */ #if COLLECT_DAEMON -static int -pidfile_create (const char *file) +static int pidfile_create (const char *file) { FILE *fh; @@ -257,8 +244,7 @@ pidfile_create (const char *file) #endif /* COLLECT_DAEMON */ #if COLLECT_DAEMON -static int -pidfile_remove (const char *file) +static int pidfile_remove (const char *file) { if (file == NULL) { file = PIDFILE; @@ -267,18 +253,16 @@ pidfile_remove (const char *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 char *pidfile = PIDFILE; pid_t pid; - int daemonize = 1; + int daemonize = 1; #endif #if COLLECT_DEBUG char *logfile = LOGFILE; @@ -331,7 +315,6 @@ main (int argc, char **argv) #endif /* HAVE_LIBRRD */ case 'C': configfile = optarg; - /* configdir = optarg; */ break; #if COLLECT_DAEMON case 'P': diff --git a/src/users.c b/src/users.c index 486c7bdf..2739c2be 100644 --- a/src/users.c +++ b/src/users.c @@ -32,31 +32,32 @@ # endif /* HAVE_UTMP_H */ #endif /* HAVE_UTMPX_H */ - - #define MODULE_NAME "users" static char *rrd_file = "users.rrd"; -static char *ds_def[] = { +static char *ds_def[] = +{ "DS:users:GAUGE:25:0:65535", NULL }; static int ds_num = 1; +static void users_init (void) +{ + /* we have nothing to do here :-) */ + return; +} /* static void users_init(void) */ - -static void users_submit(unsigned int users); -static void users_init(void); -static void users_read(void); -static void users_write(char *host, char *inst, char *val); - - +static void users_write (char *host, char *inst, char *val) +{ + rrd_update_file(host, rrd_file, val, ds_def, ds_num); + return; +} /* static void users_write(char *host, char *inst, char *val) */ /* I don't like this temporary macro definition - well it's used everywhere else in the collectd-sources, so I will just stick with it... */ #define BUFSIZE 256 -static void -users_submit(unsigned int users) +static void users_submit (unsigned int users) { char buf[BUFSIZE] = ""; @@ -71,17 +72,7 @@ users_submit(unsigned int users) } /* static void users_submit(unsigned int users) */ #undef BUFSIZE - - -static void -users_init(void) -{ - /* we have nothing to do here :-) */ - return; -} /* static void users_init(void) */ - -static void -users_read(void) +static void users_read (void) { #if HAVE_GETUTXENT unsigned int users = 0; @@ -98,9 +89,10 @@ users_read(void) } endutxent(); - users_submit(users); -#else /* !HAVE_GETUTXENT */ -# if HAVE_GETUTENT + users_submit (users); +/* #endif HAVE_GETUTXENT */ + +#elif HAVE_GETUTENT unsigned int users = 0; struct utmp *entry = NULL; @@ -116,25 +108,13 @@ users_read(void) endutent(); users_submit(users); -# endif /* HAVE_GETUTENT */ -#endif /* HAVE_GETUTXENT */ +#endif /* HAVE_GETUTENT */ return; } /* static void users_read(void) */ -static void -users_write(char *host, char *inst, char *val) +void module_register (void) { - rrd_update_file(host, rrd_file, val, ds_def, ds_num); - return; -} /* static void users_write(char *host, char *inst, char *val) */ - - - -void -module_register(void) -{ - plugin_register(MODULE_NAME, users_init, users_read, users_write); + plugin_register (MODULE_NAME, users_init, users_read, users_write); return; } /* void module_register(void) */ -