oconfig: fix oconfig_free to free all elements
[collectd.git] / src / openvpn.c
index 2aca414..2c93a00 100644 (file)
@@ -1,9 +1,9 @@
 /**
  * collectd - src/openvpn.c
- * Copyright (C) 2008  Doug MacEachern
- * Copyright (C) 2009  Florian octo Forster
- * Copyright (C) 2009  Marco Chiappero
- * Copyright (C) 2009  Fabian Schuh
+ * Copyright (C) 2008       Doug MacEachern
+ * Copyright (C) 2009,2010  Florian octo Forster
+ * Copyright (C) 2009       Marco Chiappero
+ * Copyright (C) 2009       Fabian Schuh
  *
  * 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
@@ -20,7 +20,7 @@
  *
  * Authors:
  *   Doug MacEachern <dougm at hyperic.com>
- *   Florian octo Forster <octo at verplant.org>
+ *   Florian octo Forster <octo at collectd.org>
  *   Marco Chiappero <marco at absence.it>
  *   Fabian Schuh <mail at xeroc.org>
  **/
@@ -114,13 +114,13 @@ static void numusers_submit (char *pinst, char *tinst, gauge_t value)
 } /* void numusers_submit */
 
 /* dispatches stats about traffic (TCP or UDP) generated by the tunnel per single endpoint */
-static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx)
+static void iostats_submit (char *pinst, char *tinst, derive_t rx, derive_t tx)
 {
        value_t values[2];
        value_list_t vl = VALUE_LIST_INIT;
 
-       values[0].counter = rx;
-       values[1].counter = tx;
+       values[0].derive = rx;
+       values[1].derive = tx;
 
        /* NOTE ON THE NEW NAMING SCHEMA:
         *       using plugin_instance to identify each vpn config (and
@@ -144,13 +144,13 @@ static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx
 
 /* dispatches stats about data compression shown when in single mode */
 static void compression_submit (char *pinst, char *tinst,
-               counter_t uncompressed, counter_t compressed)
+               derive_t uncompressed, derive_t compressed)
 {
        value_t values[2];
        value_list_t vl = VALUE_LIST_INIT;
 
-       values[0].counter = uncompressed;
-       values[1].counter = compressed;
+       values[0].derive = uncompressed;
+       values[1].derive = compressed;
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
@@ -173,11 +173,11 @@ static int single_read (char *name, FILE *fh)
        const int max_fields = STATIC_ARRAY_SIZE (fields);
        int  fields_num, read = 0;
 
-       counter_t link_rx, link_tx;
-       counter_t tun_rx, tun_tx;
-       counter_t pre_compress, post_compress;
-       counter_t pre_decompress, post_decompress;
-       counter_t overhead_rx, overhead_tx;
+       derive_t link_rx, link_tx;
+       derive_t tun_rx, tun_tx;
+       derive_t pre_compress, post_compress;
+       derive_t pre_decompress, post_decompress;
+       derive_t overhead_rx, overhead_tx;
 
        link_rx = 0;
        link_tx = 0;
@@ -265,7 +265,7 @@ static int multi1_read (char *name, FILE *fh)
 {
        char buffer[1024];
        char *fields[10];
-       int  fields_num, read = 0, found_header = 0;
+       int  fields_num, found_header = 0;
        long long sum_users = 0;
 
        /* read the file until the "ROUTING TABLE" line is found (no more info after) */
@@ -312,17 +312,15 @@ static int multi1_read (char *name, FILE *fh)
                                                atoll (fields[3])); /* "Bytes Sent" */
                        }
                }
-
-               read = 1;
        }
 
+       if (ferror (fh))
+               return (0);
+
        if (collect_user_count)
-       {
                numusers_submit(name, name, sum_users);
-               read = 1;
-       }
 
-       return (read);
+       return (1);
 } /* int multi1_read */
 
 /* for reading status version 2 */