From 3458d610e8b99eb88c2f06ad576b4f46e0169877 Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Fri, 26 Sep 2014 12:02:27 +0200
Subject: [PATCH 22/22] openvpn: Change data type from COUNTER to DERIVE

COUNTER is not what we want here, so we will use DERIVE.
---
 src/openvpn.c | 26 +++++++++++++-------------
 src/types.db  |  2 ++
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/openvpn.c b/src/openvpn.c
index 2db3677..d446e99 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -116,13 +116,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
@@ -137,7 +137,7 @@ static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx
 	if (pinst != NULL)
 		sstrncpy (vl.plugin_instance, pinst,
 				sizeof (vl.plugin_instance));
-	sstrncpy (vl.type, "if_octets", sizeof (vl.type));
+	sstrncpy (vl.type, "if_octets_derive", sizeof (vl.type));
 	if (tinst != NULL)
 		sstrncpy (vl.type_instance, tinst, sizeof (vl.type_instance));
 
@@ -146,13 +146,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);
@@ -161,7 +161,7 @@ static void compression_submit (char *pinst, char *tinst,
 	if (pinst != NULL)
 		sstrncpy (vl.plugin_instance, pinst,
 				sizeof (vl.plugin_instance));
-	sstrncpy (vl.type, "compression", sizeof (vl.type));
+	sstrncpy (vl.type, "compression_derive", sizeof (vl.type));
 	if (tinst != NULL)
 		sstrncpy (vl.type_instance, tinst, sizeof (vl.type_instance));
 
@@ -175,11 +175,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;
diff --git a/src/types.db b/src/types.db
index ad54240..03ec75b 100644
--- a/src/types.db
+++ b/src/types.db
@@ -18,6 +18,7 @@ cache_result		value:COUNTER:0:4294967295
 cache_size		value:GAUGE:0:4294967295
 charge			value:GAUGE:0:U
 compression		uncompressed:COUNTER:0:U, compressed:COUNTER:0:U
+compression_derive	uncompressed:DERIVE:0:U, compressed:DERIVE:0:U
 compression_ratio	value:GAUGE:0:2
 connections		value:COUNTER:0:U
 conntrack		entropy:GAUGE:0:4294967295
@@ -74,6 +75,7 @@ if_dropped		rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
 if_errors		rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
 if_multicast		value:COUNTER:0:4294967295
 if_octets		rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
+if_octets_derive	rx:DERIVE:0:U, tx:DERIVE:0:U
 if_packets		rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
 if_rx_errors		value:COUNTER:0:4294967295
 if_tx_errors		value:COUNTER:0:4294967295
-- 
1.9.3

