network plugin: Compatibility fixes with old versions of libgcrypt.
[collectd.git] / src / csv.c
index b5333b4..d01f47d 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
@@ -1,6 +1,6 @@
 /**
  * collectd - src/csv.c
- * Copyright (C) 2007  Florian octo Forster
+ * Copyright (C) 2007-2009  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -23,6 +23,7 @@
 #include "plugin.h"
 #include "common.h"
 #include "utils_cache.h"
+#include "utils_parse_option.h"
 
 /*
  * Private variables
@@ -248,7 +249,8 @@ static int csv_config (const char *key, const char *value)
        return (0);
 } /* int csv_config */
 
-static int csv_write (const data_set_t *ds, const value_list_t *vl)
+static int csv_write (const data_set_t *ds, const value_list_t *vl,
+               user_data_t __attribute__((unused)) *user_data)
 {
        struct stat  statbuf;
        char         filename[512];
@@ -273,8 +275,22 @@ static int csv_write (const data_set_t *ds, const value_list_t *vl)
 
        if (use_stdio)
        {
+               size_t i;
+
+               escape_string (filename, sizeof (filename));
+
+               /* Replace commas by colons for PUTVAL compatible output. */
+               for (i = 0; i < sizeof (values); i++)
+               {
+                       if (values[i] == 0)
+                               break;
+                       else if (values[i] == ',')
+                               values[i] = ':';
+               }
+
                fprintf (use_stdio == 1 ? stdout : stderr,
-                        "%s=%s\n", filename, values);
+                        "PUTVAL %s interval=%i %s\n",
+                        filename, interval_g, values);
                return (0);
        }
 
@@ -341,5 +357,5 @@ void module_register (void)
 {
        plugin_register_config ("csv", csv_config,
                        config_keys, config_keys_num);
-       plugin_register_write ("csv", csv_write);
+       plugin_register_write ("csv", csv_write, /* user_data = */ NULL);
 } /* void module_register */