X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftraffic.c;h=7c852f819dc32cc071b2d56982b28daa45502d19;hb=8feb47511b38bfcc4bdde7cc50e1c2501356b7af;hp=ab2c8cc2316c37d44c319754c6dc090536764b4b;hpb=89ef5df52d495315cd26b8e3467153b93b2c2742;p=collectd.git diff --git a/src/traffic.c b/src/traffic.c index ab2c8cc2..7c852f81 100644 --- a/src/traffic.c +++ b/src/traffic.c @@ -32,6 +32,8 @@ # define TRAFFIC_HAVE_READ 0 #endif +#define BUFSIZE 512 + static char *traffic_filename_template = "traffic-%s.rrd"; static char *ds_def[] = @@ -49,7 +51,7 @@ static kstat_t *ksp[MAX_NUMIF]; static int numif = 0; #endif /* HAVE_LIBKSTAT */ -void traffic_init (void) +static void traffic_init (void) { #ifdef HAVE_LIBKSTAT kstat_t *ksp_chain; @@ -78,22 +80,22 @@ void traffic_init (void) #endif /* HAVE_LIBKSTAT */ } -void traffic_write (char *host, char *inst, char *val) +static void traffic_write (char *host, char *inst, char *val) { - char file[512]; + char file[BUFSIZE]; int status; - status = snprintf (file, 512, traffic_filename_template, inst); + status = snprintf (file, BUFSIZE, traffic_filename_template, inst); if (status < 1) return; - else if (status >= 512) + else if (status >= BUFSIZE) return; rrd_update_file (host, file, val, ds_def, ds_num); } -#define BUFSIZE 512 -void traffic_submit (char *device, +#if TRAFFIC_HAVE_READ +static void traffic_submit (char *device, unsigned long long incoming, unsigned long long outgoing) { @@ -104,10 +106,8 @@ void traffic_submit (char *device, plugin_submit (MODULE_NAME, device, buf); } -#undef BUFSIZE -#if TRAFFIC_HAVE_READ -void traffic_read (void) +static void traffic_read (void) { #ifdef KERNEL_LINUX FILE *fh; @@ -193,4 +193,5 @@ void module_register (void) plugin_register (MODULE_NAME, traffic_init, traffic_read, traffic_write); } +#undef BUFSIZE #undef MODULE_NAME