Various plugins: Use the IS_TRUE and IS_FALSE macros everywhere.
[collectd.git] / src / rrdcached.c
index f9d65ca..bca10be 100644 (file)
@@ -75,7 +75,9 @@ static int value_list_to_string (char *buffer, int buffer_len,
   for (i = 0; i < ds->ds_num; i++)
   {
     if ((ds->ds[i].type != DS_TYPE_COUNTER)
-        && (ds->ds[i].type != DS_TYPE_GAUGE))
+        && (ds->ds[i].type != DS_TYPE_GAUGE)
+       && (ds->ds[i].type != DS_TYPE_DERIVE)
+       && (ds->ds[i].type != DS_TYPE_ABSOLUTE))
       return (-1);
 
     if (ds->ds[i].type == DS_TYPE_COUNTER)
@@ -83,10 +85,19 @@ static int value_list_to_string (char *buffer, int buffer_len,
       status = ssnprintf (buffer + offset, buffer_len - offset,
           ":%llu", vl->values[i].counter);
     }
-    else /* if (ds->ds[i].type == DS_TYPE_GAUGE) */
+    else if (ds->ds[i].type == DS_TYPE_GAUGE) 
     {
       status = ssnprintf (buffer + offset, buffer_len - offset,
-          ":%lf", vl->values[i].gauge);
+          ":%f", vl->values[i].gauge);
+    }
+    else if (ds->ds[i].type == DS_TYPE_DERIVE) {
+      status = ssnprintf (buffer + offset, buffer_len - offset,
+         ":%"PRIi64, vl->values[i].derive);
+    }
+    else /* if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */ {
+      status = ssnprintf (buffer + offset, buffer_len - offset,
+         ":%"PRIu64, vl->values[i].absolute);
     }
 
     if ((status < 1) || (status >= (buffer_len - offset)))
@@ -181,18 +192,14 @@ static int rc_config (const char *key, const char *value)
   }
   else if (strcasecmp ("CreateFiles", key) == 0)
   {
-    if ((strcasecmp ("false", value) == 0)
-        || (strcasecmp ("no", value) == 0)
-        || (strcasecmp ("off", value) == 0))
+    if (IS_FALSE (value))
       config_create_files = 0;
     else
       config_create_files = 1;
   }
   else if (strcasecmp ("CollectStatistics", key) == 0)
   {
-    if ((strcasecmp ("false", value) == 0)
-        || (strcasecmp ("no", value) == 0)
-        || (strcasecmp ("off", value) == 0))
+    if (IS_FALSE (value))
       config_collect_stats = 0;
     else
       config_collect_stats = 1;
@@ -221,7 +228,6 @@ static int rc_read (void)
 
   vl.values = values;
   vl.values_len = 1;
-  vl.time = time (NULL);
 
   if ((strncmp ("unix:", daemon_address, strlen ("unix:")) == 0)
       || (daemon_address[0] == '/'))
@@ -315,7 +321,8 @@ static int rc_init (void)
   return (0);
 } /* int rc_init */
 
-static int rc_write (const data_set_t *ds, const value_list_t *vl)
+static int rc_write (const data_set_t *ds, const value_list_t *vl,
+    user_data_t __attribute__((unused)) *user_data)
 {
   char filename[512];
   char values[512];
@@ -406,7 +413,7 @@ void module_register (void)
   plugin_register_config ("rrdcached", rc_config,
       config_keys, config_keys_num);
   plugin_register_init ("rrdcached", rc_init);
-  plugin_register_write ("rrdcached", rc_write);
+  plugin_register_write ("rrdcached", rc_write, /* user_data = */ NULL);
   plugin_register_shutdown ("rrdcached", rc_shutdown);
 } /* void module_register */