X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fswap.c;h=7fa72dc92458ae6d2993cd897eaeb1110a599990;hb=5cdafc6cb9228b93cf9b6956c92df61d00bd2a9e;hp=1cf707797f1057b4fb6124c763a46e057b2753ee;hpb=89783745dc59079eab34e0c52de6e5e972f50eb2;p=collectd.git diff --git a/src/swap.c b/src/swap.c index 1cf70779..7fa72dc9 100644 --- a/src/swap.c +++ b/src/swap.c @@ -36,6 +36,10 @@ # include #endif +#if HAVE_STATGRAB_H +# include +#endif + #undef MAX #define MAX(x,y) ((x) > (y) ? (x) : (y)) @@ -52,10 +56,10 @@ static kstat_t *ksp; /* No global variables */ /* #endif defined(VM_SWAPUSAGE) */ -#elif HAVE_LIBKVM +#elif HAVE_LIBKVM_GETSWAPINFO static kvm_t *kvm_obj = NULL; int kvm_pagesize; -/* #endif HAVE_LIBKVM */ +/* #endif HAVE_LIBKVM_GETSWAPINFO */ #elif HAVE_LIBSTATGRAB /* No global variables */ @@ -82,7 +86,7 @@ static int swap_init (void) /* No init stuff */ /* #endif defined(VM_SWAPUSAGE) */ -#elif HAVE_LIBKVM +#elif HAVE_LIBKVM_GETSWAPINFO if (kvm_obj != NULL) { kvm_close (kvm_obj); @@ -101,7 +105,7 @@ static int swap_init (void) ERROR ("swap plugin: kvm_open failed."); return (-1); } -/* #endif HAVE_LIBKVM */ +/* #endif HAVE_LIBKVM_GETSWAPINFO */ #elif HAVE_LIBSTATGRAB /* No init stuff */ @@ -120,8 +124,8 @@ static void swap_submit (const char *type_instance, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "swap"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "swap", sizeof (vl.plugin)); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); plugin_dispatch_values ("swap", &vl); @@ -255,7 +259,7 @@ static int swap_read (void) swap_submit ("free", sw_usage.xsu_avail); /* #endif VM_SWAPUSAGE */ -#elif HAVE_LIBKVM +#elif HAVE_LIBKVM_GETSWAPINFO struct kvm_swap data_s; int status; @@ -281,7 +285,7 @@ static int swap_read (void) swap_submit ("used", used); swap_submit ("free", free); -/* #endif HAVE_LIBKVM */ +/* #endif HAVE_LIBKVM_GETSWAPINFO */ #elif HAVE_LIBSTATGRAB sg_swap_stats *swap;