X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Finterface.c;h=806a336dfde09c814c9ab9f204e5770758251893;hb=fd9c88963b04c9e9050a952ba0f018493e8b7638;hp=52b2ddf0866f07f10abbfb8fb13a16a13b60e7c5;hpb=2b6176cab4f092354177473bbc74c5cdc2eaa2ec;p=collectd.git diff --git a/src/interface.c b/src/interface.c index 52b2ddf0..806a336d 100644 --- a/src/interface.c +++ b/src/interface.c @@ -46,6 +46,10 @@ # include #endif +#if HAVE_STATGRAB_H +# include +#endif + /* * Various people have reported problems with `getifaddrs' and varying versions * of `glibc'. That's why it's disabled by default. Since more statistics are @@ -58,10 +62,8 @@ # endif /* !COLLECT_GETIFADDRS */ #endif /* KERNEL_LINUX */ -#if HAVE_GETIFADDRS || KERNEL_LINUX || HAVE_LIBKSTAT || HAVE_LIBSTATGRAB -# define INTERFACE_HAVE_READ 1 -#else -# define INTERFACE_HAVE_READ 0 +#if !HAVE_GETIFADDRS && !KERNEL_LINUX && !HAVE_LIBKSTAT && !HAVE_LIBSTATGRAB +# error "No applicable input method." #endif /* @@ -132,7 +134,6 @@ static int interface_config (const char *key, const char *value) #if HAVE_LIBKSTAT static int interface_init (void) { -#if HAVE_LIBKSTAT kstat_t *ksp_chain; unsigned long long val; @@ -155,7 +156,6 @@ static int interface_init (void) continue; ksp[numif++] = ksp_chain; } -#endif /* HAVE_LIBKSTAT */ return (0); } /* int interface_init */ @@ -181,7 +181,6 @@ static int check_ignore_if (const char *interface) return (1 - if_list_action); } /* int check_ignore_if */ -#if INTERFACE_HAVE_READ static void if_submit (const char *dev, const char *type, unsigned long long rx, unsigned long long tx) @@ -198,11 +197,12 @@ static void if_submit (const char *dev, const char *type, vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "interface"); - strncpy (vl.type_instance, dev, sizeof (vl.type_instance)); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "interface", sizeof (vl.plugin)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, dev, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void if_submit */ static int interface_read (void) @@ -353,7 +353,6 @@ static int interface_read (void) return (0); } /* int interface_read */ -#endif /* INTERFACE_HAVE_READ */ void module_register (void) { @@ -362,7 +361,5 @@ void module_register (void) #if HAVE_LIBKSTAT plugin_register_init ("interface", interface_init); #endif -#if INTERFACE_HAVE_READ plugin_register_read ("interface", interface_read); -#endif } /* void module_register */