Fixed typo (vm_data vs. vm_stat), included mach/mach_host.h.
[collectd.git] / src / traffic.c
index d3cea5a..45e4cfe 100644 (file)
 # define TRAFFIC_HAVE_READ 0
 #endif
 
+#define BUFSIZE 512
+
 static char *traffic_filename_template = "traffic-%s.rrd";
 
 static char *ds_def[] =
 {
-       "DS:incoming:COUNTER:25:0:U",
-       "DS:outgoing:COUNTER:25:0:U",
+       "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:U",
        NULL
 };
 static int ds_num = 2;
@@ -53,7 +55,6 @@ static void traffic_init (void)
 {
 #ifdef HAVE_LIBKSTAT
        kstat_t *ksp_chain;
-       kstat_named_t *kn;
        unsigned long long val;
 
        numif = 0;
@@ -80,19 +81,19 @@ static void traffic_init (void)
 
 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
+#if TRAFFIC_HAVE_READ
 static void traffic_submit (char *device,
                unsigned long long incoming,
                unsigned long long outgoing)
@@ -104,9 +105,7 @@ static void traffic_submit (char *device,
 
        plugin_submit (MODULE_NAME, device, buf);
 }
-#undef BUFSIZE
 
-#if TRAFFIC_HAVE_READ
 static void traffic_read (void)
 {
 #ifdef KERNEL_LINUX
@@ -193,4 +192,5 @@ void module_register (void)
        plugin_register (MODULE_NAME, traffic_init, traffic_read, traffic_write);
 }
 
+#undef BUFSIZE
 #undef MODULE_NAME