From: Ruben Kerkhof Date: Fri, 8 Jun 2018 16:24:19 +0000 (+0200) Subject: Merge pull request #2702 from elfiesmelfie/feat_snmp_agent X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=e11b359144492baa97d648efc700203d0b56d32e;hp=258e6aee6f33a7b5a6d21ccdca2ee50888e0ac45 Merge pull request #2702 from elfiesmelfie/feat_snmp_agent snmp_agent: new features --- diff --git a/Makefile.am b/Makefile.am index 232ddd6e..83b76a03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -195,6 +195,8 @@ endif collectd_SOURCES = \ + src/daemon/cmd.c \ + src/daemon/cmd.h \ src/daemon/collectd.c \ src/daemon/collectd.h \ src/daemon/configfile.c \ diff --git a/src/daemon/cmd.c b/src/daemon/cmd.c new file mode 100644 index 00000000..7b779955 --- /dev/null +++ b/src/daemon/cmd.c @@ -0,0 +1,271 @@ +/** + * collectd - src/daemon/cmd.c + * Copyright (C) 2005-2007 Florian octo Forster + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **/ + +#include "cmd.h" +#include "collectd.h" + +#include "common.h" +#include + +static void *do_flush(void __attribute__((unused)) * arg) { + INFO("Flushing all data."); + plugin_flush(/* plugin = */ NULL, + /* timeout = */ 0, + /* ident = */ NULL); + INFO("Finished flushing all data."); + pthread_exit(NULL); + return NULL; +} + +static void sig_int_handler(int __attribute__((unused)) signal) { + stop_collectd(); +} + +static void sig_term_handler(int __attribute__((unused)) signal) { + stop_collectd(); +} + +static void sig_usr1_handler(int __attribute__((unused)) signal) { + pthread_t thread; + pthread_attr_t attr; + + /* flushing the data might take a while, + * so it should be done asynchronously */ + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_create(&thread, &attr, do_flush, NULL); + pthread_attr_destroy(&attr); +} + +#if COLLECT_DAEMON +static int pidfile_create(void) { + FILE *fh; + const char *file = global_option_get("PIDFile"); + + if ((fh = fopen(file, "w")) == NULL) { + ERROR("fopen (%s): %s", file, STRERRNO); + return 1; + } + + fprintf(fh, "%i\n", (int)getpid()); + fclose(fh); + + return 0; +} /* static int pidfile_create (const char *file) */ + +static int pidfile_remove(void) { + const char *file = global_option_get("PIDFile"); + if (file == NULL) + return 0; + + return unlink(file); +} /* static int pidfile_remove (const char *file) */ +#endif /* COLLECT_DAEMON */ + +#ifdef KERNEL_LINUX +static int notify_upstart(void) { + char const *upstart_job = getenv("UPSTART_JOB"); + + if (upstart_job == NULL) + return 0; + + if (strcmp(upstart_job, "collectd") != 0) { + WARNING("Environment specifies unexpected UPSTART_JOB=\"%s\", expected " + "\"collectd\". Ignoring the variable.", + upstart_job); + return 0; + } + + NOTICE("Upstart detected, stopping now to signal readiness."); + raise(SIGSTOP); + unsetenv("UPSTART_JOB"); + + return 1; +} + +static int notify_systemd(void) { + size_t su_size; + const char *notifysocket = getenv("NOTIFY_SOCKET"); + if (notifysocket == NULL) + return 0; + + if ((strlen(notifysocket) < 2) || + ((notifysocket[0] != '@') && (notifysocket[0] != '/'))) { + ERROR("invalid notification socket NOTIFY_SOCKET=\"%s\": path must be " + "absolute", + notifysocket); + return 0; + } + NOTICE("Systemd detected, trying to signal readiness."); + + unsetenv("NOTIFY_SOCKET"); + + int fd; +#if defined(SOCK_CLOEXEC) + fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, /* protocol = */ 0); +#else + fd = socket(AF_UNIX, SOCK_DGRAM, /* protocol = */ 0); +#endif + if (fd < 0) { + ERROR("creating UNIX socket failed: %s", STRERRNO); + return 0; + } + + struct sockaddr_un su = {0}; + su.sun_family = AF_UNIX; + if (notifysocket[0] != '@') { + /* regular UNIX socket */ + sstrncpy(su.sun_path, notifysocket, sizeof(su.sun_path)); + su_size = sizeof(su); + } else { + /* Linux abstract namespace socket: specify address as "\0foo", i.e. + * start with a null byte. Since null bytes have no special meaning in + * that case, we have to set su_size correctly to cover only the bytes + * that are part of the address. */ + sstrncpy(su.sun_path, notifysocket, sizeof(su.sun_path)); + su.sun_path[0] = 0; + su_size = sizeof(sa_family_t) + strlen(notifysocket); + if (su_size > sizeof(su)) + su_size = sizeof(su); + } + + const char buffer[] = "READY=1\n"; + if (sendto(fd, buffer, strlen(buffer), MSG_NOSIGNAL, (void *)&su, + (socklen_t)su_size) < 0) { + ERROR("sendto(\"%s\") failed: %s", notifysocket, STRERRNO); + close(fd); + return 0; + } + + unsetenv("NOTIFY_SOCKET"); + close(fd); + return 1; +} +#endif /* KERNEL_LINUX */ + +int main(int argc, char **argv) { + struct cmdline_config config = init_config(argc, argv); + +#if COLLECT_DAEMON + /* + * fork off child + */ + struct sigaction sig_chld_action = {.sa_handler = SIG_IGN}; + + sigaction(SIGCHLD, &sig_chld_action, NULL); + + /* + * Only daemonize if we're not being supervised + * by upstart or systemd (when using Linux). + */ + if (config.daemonize +#ifdef KERNEL_LINUX + && notify_upstart() == 0 && notify_systemd() == 0 +#endif + ) { + pid_t pid; + if ((pid = fork()) == -1) { + /* error */ + fprintf(stderr, "fork: %s", STRERRNO); + return 1; + } else if (pid != 0) { + /* parent */ + /* printf ("Running (PID %i)\n", pid); */ + return 0; + } + + /* Detach from session */ + setsid(); + + /* Write pidfile */ + if (pidfile_create()) + exit(2); + + /* close standard descriptors */ + close(2); + close(1); + close(0); + + int status = open("/dev/null", O_RDWR); + if (status != 0) { + ERROR("Error: Could not connect `STDIN' to `/dev/null' (status %d)", + status); + return 1; + } + + status = dup(0); + if (status != 1) { + ERROR("Error: Could not connect `STDOUT' to `/dev/null' (status %d)", + status); + return 1; + } + + status = dup(0); + if (status != 2) { + ERROR("Error: Could not connect `STDERR' to `/dev/null', (status %d)", + status); + return 1; + } + } /* if (config.daemonize) */ +#endif /* COLLECT_DAEMON */ + + struct sigaction sig_pipe_action = {.sa_handler = SIG_IGN}; + + sigaction(SIGPIPE, &sig_pipe_action, NULL); + + /* + * install signal handlers + */ + struct sigaction sig_int_action = {.sa_handler = sig_int_handler}; + + if (sigaction(SIGINT, &sig_int_action, NULL) != 0) { + ERROR("Error: Failed to install a signal handler for signal INT: %s", + STRERRNO); + return 1; + } + + struct sigaction sig_term_action = {.sa_handler = sig_term_handler}; + + if (sigaction(SIGTERM, &sig_term_action, NULL) != 0) { + ERROR("Error: Failed to install a signal handler for signal TERM: %s", + STRERRNO); + return 1; + } + + struct sigaction sig_usr1_action = {.sa_handler = sig_usr1_handler}; + + if (sigaction(SIGUSR1, &sig_usr1_action, NULL) != 0) { + ERROR("Error: Failed to install a signal handler for signal USR1: %s", + STRERRNO); + return 1; + } + + int exit_status = run_loop(config.test_readall); + +#if COLLECT_DAEMON + if (config.daemonize) + pidfile_remove(); +#endif /* COLLECT_DAEMON */ + + return exit_status; +} /* int main */ diff --git a/src/daemon/cmd.h b/src/daemon/cmd.h new file mode 100644 index 00000000..152ee63e --- /dev/null +++ b/src/daemon/cmd.h @@ -0,0 +1,41 @@ +/** + * collectd - src/daemon/cmd.h + * Copyright (C) 2018 Florian octo Forster + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **/ + +#ifndef CMD_H +#define CMD_H + +#include + +struct cmdline_config { + bool test_config; + bool test_readall; + bool create_basedir; + const char *configfile; + bool daemonize; +}; + +void stop_collectd(void); +struct cmdline_config init_config(int argc, char **argv); +int run_loop(bool test_readall); + +#endif /* CMD_H */ diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index 7e859750..b4668e06 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -25,6 +25,7 @@ * Alvaro Barcellos **/ +#include "cmd.h" #include "collectd.h" #include "common.h" @@ -33,7 +34,6 @@ #include #include -#include #if HAVE_LOCALE_H #include @@ -53,32 +53,6 @@ static int loop; -static void *do_flush(void __attribute__((unused)) * arg) { - INFO("Flushing all data."); - plugin_flush(/* plugin = */ NULL, - /* timeout = */ 0, - /* ident = */ NULL); - INFO("Finished flushing all data."); - pthread_exit(NULL); - return NULL; -} - -static void sig_int_handler(int __attribute__((unused)) signal) { loop++; } - -static void sig_term_handler(int __attribute__((unused)) signal) { loop++; } - -static void sig_usr1_handler(int __attribute__((unused)) signal) { - pthread_t thread; - pthread_attr_t attr; - - /* flushing the data might take a while, - * so it should be done asynchronously */ - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - pthread_create(&thread, &attr, do_flush, NULL); - pthread_attr_destroy(&attr); -} - static int init_hostname(void) { const char *str = global_option_get("Hostname"); if (str && str[0] != '\0') { @@ -318,120 +292,6 @@ static int do_shutdown(void) { return plugin_shutdown_all(); } /* int do_shutdown */ -#if COLLECT_DAEMON -static int pidfile_create(void) { - FILE *fh; - const char *file = global_option_get("PIDFile"); - - if ((fh = fopen(file, "w")) == NULL) { - ERROR("fopen (%s): %s", file, STRERRNO); - return 1; - } - - fprintf(fh, "%i\n", (int)getpid()); - fclose(fh); - - return 0; -} /* static int pidfile_create (const char *file) */ - -static int pidfile_remove(void) { - const char *file = global_option_get("PIDFile"); - if (file == NULL) - return 0; - - return unlink(file); -} /* static int pidfile_remove (const char *file) */ -#endif /* COLLECT_DAEMON */ - -#ifdef KERNEL_LINUX -static int notify_upstart(void) { - char const *upstart_job = getenv("UPSTART_JOB"); - - if (upstart_job == NULL) - return 0; - - if (strcmp(upstart_job, "collectd") != 0) { - WARNING("Environment specifies unexpected UPSTART_JOB=\"%s\", expected " - "\"collectd\". Ignoring the variable.", - upstart_job); - return 0; - } - - NOTICE("Upstart detected, stopping now to signal readiness."); - raise(SIGSTOP); - unsetenv("UPSTART_JOB"); - - return 1; -} - -static int notify_systemd(void) { - size_t su_size; - const char *notifysocket = getenv("NOTIFY_SOCKET"); - if (notifysocket == NULL) - return 0; - - if ((strlen(notifysocket) < 2) || - ((notifysocket[0] != '@') && (notifysocket[0] != '/'))) { - ERROR("invalid notification socket NOTIFY_SOCKET=\"%s\": path must be " - "absolute", - notifysocket); - return 0; - } - NOTICE("Systemd detected, trying to signal readiness."); - - unsetenv("NOTIFY_SOCKET"); - - int fd; -#if defined(SOCK_CLOEXEC) - fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, /* protocol = */ 0); -#else - fd = socket(AF_UNIX, SOCK_DGRAM, /* protocol = */ 0); -#endif - if (fd < 0) { - ERROR("creating UNIX socket failed: %s", STRERRNO); - return 0; - } - - struct sockaddr_un su = {0}; - su.sun_family = AF_UNIX; - if (notifysocket[0] != '@') { - /* regular UNIX socket */ - sstrncpy(su.sun_path, notifysocket, sizeof(su.sun_path)); - su_size = sizeof(su); - } else { - /* Linux abstract namespace socket: specify address as "\0foo", i.e. - * start with a null byte. Since null bytes have no special meaning in - * that case, we have to set su_size correctly to cover only the bytes - * that are part of the address. */ - sstrncpy(su.sun_path, notifysocket, sizeof(su.sun_path)); - su.sun_path[0] = 0; - su_size = sizeof(sa_family_t) + strlen(notifysocket); - if (su_size > sizeof(su)) - su_size = sizeof(su); - } - - const char buffer[] = "READY=1\n"; - if (sendto(fd, buffer, strlen(buffer), MSG_NOSIGNAL, (void *)&su, - (socklen_t)su_size) < 0) { - ERROR("sendto(\"%s\") failed: %s", notifysocket, STRERRNO); - close(fd); - return 0; - } - - unsetenv("NOTIFY_SOCKET"); - close(fd); - return 1; -} -#endif /* KERNEL_LINUX */ - -struct cmdline_config { - bool test_config; - bool test_readall; - bool create_basedir; - const char *configfile; - bool daemonize; -}; - static void read_cmdline(int argc, char **argv, struct cmdline_config *config) { /* read options */ while (1) { @@ -516,9 +376,9 @@ static int configure_collectd(struct cmdline_config *config) { return 0; } -int main(int argc, char **argv) { - int exit_status = 0; +void stop_collectd(void) { loop++; } +struct cmdline_config init_config(int argc, char **argv) { struct cmdline_config config = { .daemonize = true, .create_basedir = true, .configfile = CONFIGFILE, }; @@ -526,7 +386,7 @@ int main(int argc, char **argv) { read_cmdline(argc, argv, &config); if (config.test_config) - return 0; + exit(EXIT_SUCCESS); if (optind < argc) exit_usage(1); @@ -536,109 +396,18 @@ int main(int argc, char **argv) { if (configure_collectd(&config) != 0) exit(EXIT_FAILURE); -#if COLLECT_DAEMON - /* - * fork off child - */ - struct sigaction sig_chld_action = {.sa_handler = SIG_IGN}; - - sigaction(SIGCHLD, &sig_chld_action, NULL); - - /* - * Only daemonize if we're not being supervised - * by upstart or systemd (when using Linux). - */ - if (config.daemonize -#ifdef KERNEL_LINUX - && notify_upstart() == 0 && notify_systemd() == 0 -#endif - ) { - pid_t pid; - if ((pid = fork()) == -1) { - /* error */ - fprintf(stderr, "fork: %s", STRERRNO); - return 1; - } else if (pid != 0) { - /* parent */ - /* printf ("Running (PID %i)\n", pid); */ - return 0; - } - - /* Detach from session */ - setsid(); - - /* Write pidfile */ - if (pidfile_create()) - exit(2); - - /* close standard descriptors */ - close(2); - close(1); - close(0); - - int status = open("/dev/null", O_RDWR); - if (status != 0) { - ERROR("Error: Could not connect `STDIN' to `/dev/null' (status %d)", - status); - return 1; - } - - status = dup(0); - if (status != 1) { - ERROR("Error: Could not connect `STDOUT' to `/dev/null' (status %d)", - status); - return 1; - } - - status = dup(0); - if (status != 2) { - ERROR("Error: Could not connect `STDERR' to `/dev/null', (status %d)", - status); - return 1; - } - } /* if (config.daemonize) */ -#endif /* COLLECT_DAEMON */ - - struct sigaction sig_pipe_action = {.sa_handler = SIG_IGN}; - - sigaction(SIGPIPE, &sig_pipe_action, NULL); - - /* - * install signal handlers - */ - struct sigaction sig_int_action = {.sa_handler = sig_int_handler}; - - if (sigaction(SIGINT, &sig_int_action, NULL) != 0) { - ERROR("Error: Failed to install a signal handler for signal INT: %s", - STRERRNO); - return 1; - } - - struct sigaction sig_term_action = {.sa_handler = sig_term_handler}; - - if (sigaction(SIGTERM, &sig_term_action, NULL) != 0) { - ERROR("Error: Failed to install a signal handler for signal TERM: %s", - STRERRNO); - return 1; - } - - struct sigaction sig_usr1_action = {.sa_handler = sig_usr1_handler}; + return config; +} - if (sigaction(SIGUSR1, &sig_usr1_action, NULL) != 0) { - ERROR("Error: Failed to install a signal handler for signal USR1: %s", - STRERRNO); - return 1; - } +int run_loop(bool test_readall) { + int exit_status = 0; - /* - * run the actual loops - */ if (do_init() != 0) { ERROR("Error: one or more plugin init callbacks failed."); exit_status = 1; } - if (config.test_readall) { + if (test_readall) { if (plugin_read_all_once() != 0) { ERROR("Error: one or more plugin read callbacks failed."); exit_status = 1; @@ -656,10 +425,5 @@ int main(int argc, char **argv) { exit_status = 1; } -#if COLLECT_DAEMON - if (config.daemonize) - pidfile_remove(); -#endif /* COLLECT_DAEMON */ - return exit_status; -} /* int main */ +} /* int run_loop */ diff --git a/src/daemon/collectd.h b/src/daemon/collectd.h index 87f05a23..459da4dc 100644 --- a/src/daemon/collectd.h +++ b/src/daemon/collectd.h @@ -240,26 +240,6 @@ #define __attribute__(x) /**/ #endif -#if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__ -#undef strcpy -#undef strcat -#undef strtok -#pragma GCC poison strcpy strcat strtok -#endif - -/* - * Special hack for the perl plugin: Because the later included perl.h defines - * a macro which is never used, but contains `sprintf', we cannot poison that - * identifies just yet. The parl plugin will do that itself once perl.h is - * included. - */ -#ifndef DONT_POISON_SPRINTF_YET -#if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__ -#undef sprintf -#pragma GCC poison sprintf -#endif -#endif - #ifndef GAUGE_FORMAT #define GAUGE_FORMAT "%.15g" #endif diff --git a/src/intel_rdt.c b/src/intel_rdt.c index 667033c0..62ce9b80 100644 --- a/src/intel_rdt.c +++ b/src/intel_rdt.c @@ -25,9 +25,9 @@ * Serhiy Pshyk **/ +#include "collectd.h" #include "common.h" #include "utils_config_cores.h" -#include "collectd.h" #include @@ -336,8 +336,8 @@ static int rdt_config(oconfig_item_t *ci) { return 0; } -static void rdt_submit_derive(char *cgroup, char *type, char *type_instance, - derive_t value) { +static void rdt_submit_derive(const char *cgroup, const char *type, + const char *type_instance, derive_t value) { value_list_t vl = VALUE_LIST_INIT; vl.values = &(value_t){.derive = value}; @@ -352,8 +352,8 @@ static void rdt_submit_derive(char *cgroup, char *type, char *type_instance, plugin_dispatch_values(&vl); } -static void rdt_submit_gauge(char *cgroup, char *type, char *type_instance, - gauge_t value) { +static void rdt_submit_gauge(const char *cgroup, const char *type, + const char *type_instance, gauge_t value) { value_list_t vl = VALUE_LIST_INIT; vl.values = &(value_t){.gauge = value}; diff --git a/src/lua.c b/src/lua.c index 8cfb7045..f66d8526 100644 --- a/src/lua.c +++ b/src/lua.c @@ -28,27 +28,18 @@ * Ruben Kerkhof **/ -/* defines a macro using "sprintf". Although not used here, - * GCC will complain about the macro definition. */ -#define DONT_POISON_SPRINTF_YET - +#include "collectd.h" #include "common.h" #include "plugin.h" -#include "collectd.h" +#include "utils_lua.h" /* Include the Lua API header files. */ #include #include #include -#include "utils_lua.h" #include -#if COLLECT_DEBUG && __GNUC__ -#undef sprintf -#pragma GCC poison sprintf -#endif - typedef struct lua_script_s { char *script_path; lua_State *lua_state; diff --git a/src/perl.c b/src/perl.c index 306d4138..31c68ad7 100644 --- a/src/perl.c +++ b/src/perl.c @@ -33,21 +33,11 @@ /* do not automatically get the thread specific Perl interpreter */ #define PERL_NO_GET_CONTEXT -#define DONT_POISON_SPRINTF_YET 1 -#include "collectd.h" - -#undef DONT_POISON_SPRINTF_YET - #include #include #include -#if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__ -#undef sprintf -#pragma GCC poison sprintf -#endif - #include /* Some versions of Perl define their own version of DEBUG... :-/ */ diff --git a/src/processes.c b/src/processes.c index ffe6c5aa..86e99c3a 100644 --- a/src/processes.c +++ b/src/processes.c @@ -909,7 +909,7 @@ static void ps_submit_proc_list(procstat_t *ps) { gauge_t const delay_factor = 1000000000.0; struct { - char *type_instance; + const char *type_instance; gauge_t rate_ns; } delay_metrics[] = { {"delay-cpu", ps->delay_cpu}, diff --git a/src/utils_lua.c b/src/utils_lua.c index 1f060f84..11ac0010 100644 --- a/src/utils_lua.c +++ b/src/utils_lua.c @@ -24,10 +24,6 @@ * Florian Forster **/ -/* defines a macro using "sprintf". Although not used here, - * GCC will complain about the macro definition. */ -#define DONT_POISON_SPRINTF_YET - #include "common.h" #include "utils_lua.h" diff --git a/src/utils_lua.h b/src/utils_lua.h index 61d9070e..e5a3d746 100644 --- a/src/utils_lua.h +++ b/src/utils_lua.h @@ -27,12 +27,9 @@ #ifndef UTILS_LUA_H #define UTILS_LUA_H 1 -#include "plugin.h" #include "collectd.h" +#include "plugin.h" -#ifndef DONT_POISON_SPRINTF_YET -#error "Files including utils_lua.h need to define DONT_POISON_SPRINTF_YET." -#endif #include /* diff --git a/src/virt.c b/src/virt.c index 1ce376cb..87ab8fdc 100644 --- a/src/virt.c +++ b/src/virt.c @@ -1024,7 +1024,8 @@ static void domain_state_submit_notif(virDomainPtr dom, int state, int reason) { char msg[DATA_MAX_NAME_LEN]; const char *state_str = domain_states[state]; #ifdef HAVE_DOM_REASON - if ((reason < 0) || ((size_t)reason >= STATIC_ARRAY_SIZE(domain_reasons[0]))) { + if ((reason < 0) || + ((size_t)reason >= STATIC_ARRAY_SIZE(domain_reasons[0]))) { ERROR(PLUGIN_NAME ": Array index out of bounds: reason=%d", reason); return; } @@ -1584,7 +1585,7 @@ static int get_block_stats(struct block_device *block_dev) { #define NM_ADD_STR_ITEMS(_items, _size) \ do { \ - for (size_t _i = 0; _i < _size; ++_i) { \ + for (size_t _i = 0; _i < _size; ++_i) { \ DEBUG(PLUGIN_NAME \ " plugin: Adding notification metadata name=%s value=%s", \ _items[_i].name, _items[_i].value); \ @@ -1824,7 +1825,7 @@ static int get_if_dev_stats(struct interface_device *if_dev) { return 0; } -static int domain_lifecycle_event_cb(__attribute__((unused)) virConnectPtr conn, +static int domain_lifecycle_event_cb(__attribute__((unused)) virConnectPtr con_, virDomainPtr dom, int event, int detail, __attribute__((unused)) void *opaque) { int domain_state = map_domain_event_to_state(event);