summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvkalintiris <vasilis@netdata.cloud>2021-02-25 14:29:41 +0200
committerGitHub <noreply@github.com>2021-02-25 14:29:41 +0200
commitad163251fca6056b3f88221cfc8f246ce1df3feb (patch)
treef64ad051b098c809a2ef155fc6a2610b0e517c1a
parent4455cb5d847a30f6ee9aa86bfc77637c83eb1f20 (diff)
Remove unreachable #else directives in plugins. (#10523)
They are unreachable because Makefile.am will conditionally include the relevant source files iff the #ifdef's argument is defined in configure.ac.
-rw-r--r--collectors/cups.plugin/cups_plugin.c14
-rw-r--r--collectors/freeipmi.plugin/freeipmi_plugin.c10
-rw-r--r--collectors/nfacct.plugin/plugin_nfacct.c57
-rw-r--r--collectors/xenstat.plugin/xenstat_plugin.c20
-rw-r--r--configure.ac6
-rw-r--r--daemon/buildinfo.c2
6 files changed, 14 insertions, 95 deletions
diff --git a/collectors/cups.plugin/cups_plugin.c b/collectors/cups.plugin/cups_plugin.c
index dc86437557..a80930e4db 100644
--- a/collectors/cups.plugin/cups_plugin.c
+++ b/collectors/cups.plugin/cups_plugin.c
@@ -7,6 +7,7 @@
*/
#include "../../libnetdata/libnetdata.h"
+#include <cups/cups.h>
#include <limits.h>
// callback required by fatal()
@@ -45,10 +46,6 @@ static int debug = 0;
static int netdata_update_every = 1;
static int netdata_priority = 100004;
-
-#ifdef HAVE_CUPS
-#include <cups/cups.h>
-
http_t *http; // connection to the cups daemon
/*
@@ -468,12 +465,3 @@ int main(int argc, char **argv) {
httpClose(http);
info("CUPS process exiting");
}
-
-#else // !HAVE_CUPS
-
-int main(int argc, char **argv)
-{
- fatal("cups.plugin is not compiled.");
-}
-
-#endif // !HAVE_CUPS
diff --git a/collectors/freeipmi.plugin/freeipmi_plugin.c b/collectors/freeipmi.plugin/freeipmi_plugin.c
index bd3c533cad..8229f55c1b 100644
--- a/collectors/freeipmi.plugin/freeipmi_plugin.c
+++ b/collectors/freeipmi.plugin/freeipmi_plugin.c
@@ -26,8 +26,6 @@
#include <unistd.h>
#include <sys/time.h>
-#ifdef HAVE_FREEIPMI
-
#define IPMI_PARSE_DEVICE_LAN_STR "lan"
#define IPMI_PARSE_DEVICE_LAN_2_0_STR "lan_2_0"
#define IPMI_PARSE_DEVICE_LAN_2_0_STR2 "lan20"
@@ -1861,11 +1859,3 @@ int main (int argc, char **argv) {
if(now_monotonic_sec() - started_t > 14400) exit(0);
}
}
-
-#else // !HAVE_FREEIPMI
-
-int main(int argc, char **argv) {
- fatal("freeipmi.plugin is not compiled.");
-}
-
-#endif // !HAVE_FREEIPMI
diff --git a/collectors/nfacct.plugin/plugin_nfacct.c b/collectors/nfacct.plugin/plugin_nfacct.c
index 996070f1ca..acdd0586d9 100644
--- a/collectors/nfacct.plugin/plugin_nfacct.c
+++ b/collectors/nfacct.plugin/plugin_nfacct.c
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "../../libnetdata/libnetdata.h"
+#include <linux/netfilter/nfnetlink_conntrack.h>
+#include <libmnl/libmnl.h>
+#include <libnetfilter_acct/libnetfilter_acct.h>
#define PLUGIN_NFACCT_NAME "nfacct.plugin"
@@ -13,9 +16,6 @@
#define NETDATA_CHART_PRIO_NETFILTER_PACKETS 8906
#define NETDATA_CHART_PRIO_NETFILTER_BYTES 8907
-#ifdef HAVE_LIBMNL
-#include <libmnl/libmnl.h>
-
static inline size_t mnl_buffer_size() {
long s = MNL_SOCKET_BUFFER_SIZE;
if(s <= 0) return 8192;
@@ -50,25 +50,13 @@ int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *
// required by get_system_cpus()
char *netdata_configured_host_prefix = "";
-
-// Variables
-
+// variables
static int debug = 0;
-
static int netdata_update_every = 1;
-// ----------------------------------------------------------------------------
-// DO_NFSTAT - collect netfilter connection tracker statistics via netlink
-// example: https://github.com/formorer/pkg-conntrack-tools/blob/master/src/conntrack.c
-
-#ifdef HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H
-#define DO_NFSTAT 1
-
#define RRD_TYPE_NET_STAT_NETFILTER "netfilter"
#define RRD_TYPE_NET_STAT_CONNTRACK "netlink"
-#include <linux/netfilter/nfnetlink_conntrack.h>
-
static struct {
int update_every;
char *buf;
@@ -530,16 +518,6 @@ static void nfstat_send_metrics() {
printf("END\n");
}
-#endif // HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H
-
-
-// ----------------------------------------------------------------------------
-// DO_NFACCT - collect netfilter accounting statistics via netlink
-
-#ifdef HAVE_LIBNETFILTER_ACCT
-#define DO_NFACCT 1
-
-#include <libnetfilter_acct/libnetfilter_acct.h>
struct nfacct_data {
char *name;
@@ -760,8 +738,6 @@ static void nfacct_send_metrics() {
printf("END\n");
}
-#endif // HAVE_LIBNETFILTER_ACCT
-
static void nfacct_signal_handler(int signo)
{
exit((signo == SIGPIPE)?1:0);
@@ -866,15 +842,13 @@ int main(int argc, char **argv) {
else if(freq)
error("update frequency %d seconds is too small for NFACCT. Using %d.", freq, netdata_update_every);
-#ifdef DO_NFACCT
- if(debug) fprintf(stderr, "nfacct.plugin: calling nfacct_init()\n");
+ if (debug)
+ fprintf(stderr, "nfacct.plugin: calling nfacct_init()\n");
int nfacct = !nfacct_init(netdata_update_every);
-#endif
-#ifdef DO_NFSTAT
- if(debug) fprintf(stderr, "nfacct.plugin: calling nfstat_init()\n");
+ if (debug)
+ fprintf(stderr, "nfacct.plugin: calling nfstat_init()\n");
int nfstat = !nfstat_init(netdata_update_every);
-#endif
// ------------------------------------------------------------------------
// the main loop
@@ -899,7 +873,6 @@ int main(int argc, char **argv) {
, dt
);
-#ifdef DO_NFACCT
if(likely(nfacct)) {
if(debug) fprintf(stderr, "nfacct.plugin: calling nfacct_collect()\n");
nfacct = !nfacct_collect();
@@ -909,9 +882,7 @@ int main(int argc, char **argv) {
nfacct_send_metrics();
}
}
-#endif
-#ifdef DO_NFSTAT
if(likely(nfstat)) {
if(debug) fprintf(stderr, "nfacct.plugin: calling nfstat_collect()\n");
nfstat = !nfstat_collect();
@@ -921,7 +892,6 @@ int main(int argc, char **argv) {
nfstat_send_metrics();
}
}
-#endif
fflush(stdout);
@@ -931,14 +901,3 @@ int main(int argc, char **argv) {
info("NFACCT process exiting");
}
-
-#else // !HAVE_LIBMNL
-
-int main(int argc, char **argv) {
- (void)argc;
- (void)argv;
-
- fatal("nfacct.plugin is not compiled.");
-}
-
-#endif // !HAVE_LIBMNL
diff --git a/collectors/xenstat.plugin/xenstat_plugin.c b/collectors/xenstat.plugin/xenstat_plugin.c
index 647ac1db77..a322dd1c11 100644
--- a/collectors/xenstat.plugin/xenstat_plugin.c
+++ b/collectors/xenstat.plugin/xenstat_plugin.c
@@ -2,6 +2,9 @@
#include "../../libnetdata/libnetdata.h"
+#include <xenstat.h>
+#include <libxl.h>
+
#define PLUGIN_XENSTAT_NAME "xenstat.plugin"
#define NETDATA_CHART_PRIO_XENSTAT_NODE_CPUS 30001
@@ -62,15 +65,9 @@ int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *
char *netdata_configured_host_prefix = "";
// Variables
-
static int debug = 0;
-
static int netdata_update_every = 1;
-#ifdef HAVE_LIBXENSTAT
-#include <xenstat.h>
-#include <libxl.h>
-
struct vcpu_metrics {
unsigned int id;
@@ -1093,14 +1090,3 @@ int main(int argc, char **argv) {
xenstat_uninit(xhandle);
info("XENSTAT process exiting");
}
-
-#else // !HAVE_LIBXENSTAT
-
-int main(int argc, char **argv) {
- (void)argc;
- (void)argv;
-
- fatal("xenstat.plugin is not compiled.");
-}
-
-#endif // !HAVE_LIBXENSTAT
diff --git a/configure.ac b/configure.ac
index 252cd3dd30..ac14f47bf6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -888,9 +888,7 @@ if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes"
-a "${have_libmnl}" = "yes" \
-a "${have_nfnetlink_conntrack}" = "yes"; then
enable_plugin_nfacct="yes"
- AC_DEFINE([HAVE_LIBMNL], [1], [libmnl usability])
- AC_DEFINE([HAVE_LIBNETFILTER_ACCT], [1], [libnetfilter_acct usability])
- AC_DEFINE([HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H], [1], [libnetfilter_nfnetlink_conntrack header usability])
+ AC_DEFINE([HAVE_NFACCT], [1], [netfilter accounting usability])
OPTIONAL_NFACCT_CFLAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
else
@@ -956,8 +954,6 @@ AC_MSG_CHECKING([if xenstat.plugin should be enabled])
if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
enable_plugin_xenstat="yes"
AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
- AC_DEFINE([HAVE_LIBXENLIGHT], [1], [libxenlight usability])
- AC_DEFINE([HAVE_LIBYAJL], [1], [libyajl usability])
OPTIONAL_XENSTAT_CFLAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
else
diff --git a/daemon/buildinfo.c b/daemon/buildinfo.c
index de02a72e1a..7546b708be 100644
--- a/daemon/buildinfo.c
+++ b/daemon/buildinfo.c
@@ -116,7 +116,7 @@
#define FEAT_CUPS "NO"
#endif
-#ifdef HAVE_LIBMNL
+#ifdef HAVE_NFACCT
#define FEAT_NFACCT "YES"
#else
#define FEAT_NFACCT "NO"