From: octo Date: Fri, 14 Apr 2006 07:15:17 +0000 (+0000) Subject: Corrected many defines, moved log-mode functionality out of the `rrd_*' functions... X-Git-Tag: collectd-3.8.6^2~44^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a9e8ad509f86d0e2cb5f7ac39da5955c53fe3e60;p=collectd.git Corrected many defines, moved log-mode functionality out of the `rrd_*' functions, reverted the debug-messaged in `configfile.c' and so on.. All in all minimized the patch and corrected it where neccessary.. --- diff --git a/src/collectd.c b/src/collectd.c index 369c2664..7b264e83 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -41,8 +41,7 @@ kstat_ctl_t *kc; * exported variables */ time_t curtime; - -int operating_mode; +int operating_mode; static void sigIntHandler (int signal) { diff --git a/src/common.c b/src/common.c index 3018fa49..0b603fa8 100644 --- a/src/common.c +++ b/src/common.c @@ -183,7 +183,7 @@ int escape_slashes (char *buf, int buf_len) return (0); } -int check_create_dir (const char *file_orig) +static int check_create_dir (const char *file_orig) { struct stat statbuf; @@ -287,7 +287,7 @@ int check_create_dir (const char *file_orig) return (0); } -int log_create_file (char *filename, char **ds_def, int ds_num) +static int log_create_file (char *filename, char **ds_def, int ds_num) { FILE *log; int i; @@ -336,7 +336,7 @@ int log_create_file (char *filename, char **ds_def, int ds_num) return 0; } -int log_update_file (char *host, char *file, char *values, +static int log_update_file (char *host, char *file, char *values, char **ds_def, int ds_num) { char *tmp; @@ -411,9 +411,9 @@ int log_update_file (char *host, char *file, char *values, return (0); } /* int log_update_file */ -int rrd_create_file (char *filename, char **ds_def, int ds_num) +#if HAVE_LIBRRD +static int rrd_create_file (char *filename, char **ds_def, int ds_num) { -#ifdef HAVE_LIBRRD char **argv; int argc; int i, j; @@ -453,17 +453,17 @@ int rrd_create_file (char *filename, char **ds_def, int ds_num) free (argv); return (status); -#else - return (1); -#endif /* HAVE_LIBRRD */ } +#endif /* HAVE_LIBRRD */ int rrd_update_file (char *host, char *file, char *values, char **ds_def, int ds_num) { +#if HAVE_LIBRRD struct stat statbuf; char full_file[1024]; char *argv[4] = { "update", full_file, values, NULL }; +#endif /* HAVE_LIBRRD */ /* I'd rather have a function `common_update_file' to make this * decission, but for that we'd need to touch all plugins.. */ @@ -471,6 +471,7 @@ int rrd_update_file (char *host, char *file, char *values, return (log_update_file (host, file, values, ds_def, ds_num)); +#if HAVE_LIBRRD /* host == NULL => local mode */ if (host != NULL) { @@ -502,7 +503,6 @@ int rrd_update_file (char *host, char *file, char *values, return (-1); } -#ifdef HAVE_LIBRRD optind = 0; /* bug in librrd? */ rrd_clear_error (); if (rrd_update (3, argv) == -1) @@ -510,8 +510,13 @@ int rrd_update_file (char *host, char *file, char *values, syslog (LOG_WARNING, "rrd_update failed: %s: %s", full_file, rrd_get_error ()); return (-1); } -#endif /* HAVE_LIBRRD */ return (0); +/* #endif HAVE_LIBRRD */ + +#else + syslog (LOG_ERR, "`rrd_update_file' was called, but collectd isn't linked against librrd!"); + return (-1); +#endif } #ifdef HAVE_LIBKSTAT diff --git a/src/common.h b/src/common.h index 59984b18..ae93635f 100644 --- a/src/common.h +++ b/src/common.h @@ -103,8 +103,8 @@ int strjoin (char *dst, size_t dst_len, char **fields, size_t fields_num, const */ int escape_slashes (char *buf, int buf_len); -int rrd_update_file (char *host, char *file, char *values, char **ds_def, - int ds_num); +int rrd_update_file (char *host, char *file, char *values, + char **ds_def, int ds_num); #ifdef HAVE_LIBKSTAT int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name); diff --git a/src/configfile.c b/src/configfile.c index 70ee6d60..45fe6845 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -236,8 +236,7 @@ static int cf_callback_mode (const char *shortvar, const char *var, void *extra) { DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...", - shortvar, var, (arguments) ? arguments : "", - (value) ? value : "?"); + shortvar, var, arguments, value); if (strcasecmp (value, "Client") == 0) operating_mode = MODE_CLIENT; @@ -271,8 +270,7 @@ static int cf_callback_mode_plugindir (const char *shortvar, const char *var, void *extra) { DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...", - shortvar, var, (arguments) ? arguments : "", - (value) ? value : "?"); + shortvar, var, arguments, value); plugin_set_dir (value); @@ -286,8 +284,7 @@ static int cf_callback_mode_option (const char *shortvar, const char *var, cf_mode_item_t *item; DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...", - shortvar, var, (arguments) ? arguments : "", - (value) ? value : "?"); + shortvar, var, arguments, value); if (extra == NULL) { @@ -337,8 +334,7 @@ static int cf_callback_mode_loadmodule (const char *shortvar, const char *var, void *extra) { DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...", - shortvar, var, (arguments) ? arguments : "", - (value) ? value : "?"); + shortvar, var, arguments, value); if (plugin_load (value)) syslog (LOG_ERR, "plugin_load (%s): failed to load plugin", value); @@ -361,8 +357,7 @@ static int cf_callback_socket (const char *shortvar, const char *var, char *service = NET_DEFAULT_PORT; DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...", - shortvar, var, (arguments) ? arguments : "", - (value) ? value : "?"); + shortvar, var, arguments, value); buffer = strdup (value); if (buffer == NULL) @@ -405,8 +400,7 @@ static int cf_callback_plugin (const char *shortvar, const char *var, void *extra) { DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...", - shortvar, var, (arguments) ? arguments : "", - (value) ? value : "?"); + shortvar, var, arguments, value); if (flags == LC_FLAGS_SECTIONSTART) { @@ -467,8 +461,7 @@ static int cf_callback_plugin_dispatch (const char *shortvar, const char *var, void *extra) { DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...", - shortvar, var, (arguments) ? arguments : "", - (value) ? value : "?"); + shortvar, var, arguments, value); if ((nesting_depth == 0) || (current_module == NULL)) {