[collectd] [PATCH] added TED "The energy detective" plugin

edreed at reedhome.net edreed at reedhome.net
Sun Mar 1 18:21:22 CET 2009


From: user <user at ubuntu810desktop.localdomain>

---
 configure.in    |  181 +------------------------------
 src/Makefile.am |   57 +++-------
 src/ted.c       |  327 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/types.db    |    4 +-
 4 files changed, 348 insertions(+), 221 deletions(-)
 create mode 100644 src/ted.c

diff --git a/configure.in b/configure.in
index 3445e21..791d7f0 100644
--- a/configure.in
+++ b/configure.in
@@ -1254,96 +1254,6 @@ then
 fi
 # }}}
 
-# --with-java {{{
-with_java_home="$JAVA_HOME"
-with_java_vmtype="client"
-with_java_cflags=""
-with_java_libs=""
-AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
-[
-	if test "x$withval" = "xno"
-	then
-		with_java="no"
-	else if test "x$withval" = "xyes"
-	then
-		with_java="yes"
-	else
-		with_java_home="$withval"
-		with_java="yes"
-	fi; fi
-],
-[with_java="yes"])
-if test "x$with_java" = "xyes"
-then
-	if test -d "$with_java_home"
-	then
-		if test -d "$with_java_home/include"
-		then
-			JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$with_java_home/include"
-		else
-			JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$with_java_home"
-		fi
-		
-		if test -d "$with_java_home/lib"
-		then
-			JAVA_LDFLAGS="$JAVA_LDFLAGS -L$with_java_home/lib"
-		else
-			JAVA_LDFLAGS="$JAVA_LDFLAGS -L$with_java_home"
-		fi
-	else if test "x$with_java_home" != "x"
-	then
-		AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
-	fi; fi
-fi
-
-if test "x$JAVA_CPPFLAGS" != "x"
-then
-	AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
-fi
-if test "x$JAVA_CFLAGS" != "x"
-then
-	AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
-fi
-if test "x$JAVA_LDFLAGS" != "x"
-then
-	AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
-fi
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_CFLAGS="$CFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
-CFLAGS="$CFLAGS $JAVA_CFLAGS"
-LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
-
-if test "x$with_java" = "xyes"
-then
-	AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
-fi
-if test "x$with_java" = "xyes"
-then
-	AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
-	[with_java="yes"],
-	[with_java="no (libjvm not found)"],
-	[$JAVA_LIBS])
-fi
-if test "x$with_java" = "xyes"
-then
-	JAVA_LIBS="$JAVA_LIBS -ljvm"
-	AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-CFLAGS="$SAVE_CFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-AC_SUBST(JAVA_CPPFLAGS)
-AC_SUBST(JAVA_CFLAGS)
-AC_SUBST(JAVA_LDFLAGS)
-AC_SUBST(JAVA_LIBS)
-AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
-# }}}
-
 # --with-libmysql {{{
 with_mysql_config="mysql_config"
 with_mysql_cflags=""
@@ -2944,10 +2854,10 @@ plugin_libvirt="no"
 plugin_load="no"
 plugin_memory="no"
 plugin_multimeter="no"
+plugin_ted="no"
 plugin_nfs="no"
 plugin_perl="no"
 plugin_processes="no"
-plugin_protocols="no"
 plugin_serial="no"
 plugin_swap="no"
 plugin_tape="no"
@@ -2972,7 +2882,6 @@ then
 	plugin_memory="yes"
 	plugin_nfs="yes"
 	plugin_processes="yes"
-	plugin_protocols="yes"
 	plugin_serial="yes"
 	plugin_swap="yes"
 	plugin_tcpconns="yes"
@@ -3091,6 +3000,7 @@ fi
 if test "x$have_termios_h" = "xyes"
 then
 	plugin_multimeter="yes"
+	plugin_ted="yes"
 fi
 
 if test "x$have_thread_info" = "xyes"
@@ -3154,7 +3064,6 @@ AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
-AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
 AC_PLUGIN([load],        [$plugin_load],       [System load])
 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
@@ -3165,6 +3074,7 @@ AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
+AC_PLUGIN([ted],  [$plugin_ted], [Read ted values])
 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
 AC_PLUGIN([network],     [yes],                [Network communication plugin])
@@ -3182,7 +3092,6 @@ AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
-AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
@@ -3207,86 +3116,6 @@ AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
 
-dnl Default configuration file
-# Load either syslog or logfile
-LOAD_PLUGIN_SYSLOG=""
-LOAD_PLUGIN_LOGFILE=""
-
-AC_MSG_CHECKING([which default log plugin to load])
-default_log_plugin="none"
-if test "x$enable_syslog" = "xyes"
-then
-	default_log_plugin="syslog"
-else
-	LOAD_PLUGIN_SYSLOG="##"
-fi
-
-if test "x$enable_logfile" = "xyes"
-then
-	if test "x$default_log_plugin" = "xnone"
-	then
-		default_log_plugin="logfile"
-	else
-		LOAD_PLUGIN_LOGFILE="#"
-	fi
-else
-	LOAD_PLUGIN_LOGFILE="##"
-fi
-AC_MSG_RESULT([$default_log_plugin])
-
-AC_SUBST(LOAD_PLUGIN_SYSLOG)
-AC_SUBST(LOAD_PLUGIN_LOGFILE)
-
-DEFAULT_LOG_LEVEL="info"
-if test "x$enable_debug" = "xyes"
-then
-	DEFAULT_LOG_LEVEL="debug"
-fi
-AC_SUBST(DEFAULT_LOG_LEVEL)
-
-# Load only one of rrdtool, network, csv in the default config.
-LOAD_PLUGIN_RRDTOOL=""
-LOAD_PLUGIN_NETWORK=""
-LOAD_PLUGIN_CSV=""
-
-AC_MSG_CHECKING([which default write plugin to load])
-default_write_plugin="none"
-if test "x$enable_rrdtool" = "xyes"
-then
-	default_write_plugin="rrdtool"
-else
-	LOAD_PLUGIN_RRDTOOL="##"
-fi
-
-if test "x$enable_network" = "xyes"
-then
-	if test "x$default_write_plugin" = "xnone"
-	then
-		default_write_plugin="network"
-	else
-		LOAD_PLUGIN_NETWORK="#"
-	fi
-else
-	LOAD_PLUGIN_NETWORK="##"
-fi
-
-if test "x$enable_csv" = "xyes"
-then
-	if test "x$default_write_plugin" = "xnone"
-	then
-		default_write_plugin="csv"
-	else
-		LOAD_PLUGIN_CSV="#"
-	fi
-else
-	LOAD_PLUGIN_CSV="##"
-fi
-AC_MSG_RESULT([$default_write_plugin])
-
-AC_SUBST(LOAD_PLUGIN_RRDTOOL)
-AC_SUBST(LOAD_PLUGIN_NETWORK)
-AC_SUBST(LOAD_PLUGIN_CSV)
-
 dnl ip_vs.h
 if test "x$ac_system" = "xLinux" \
 	&& test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
@@ -3382,7 +3211,6 @@ Configuration:
     libesmtp  . . . . . . $with_libesmtp
     libiokit  . . . . . . $with_libiokit
     libiptc . . . . . . . $with_libiptc
-    libjvm  . . . . . . . $with_java
     libkstat  . . . . . . $with_kstat
     libkvm  . . . . . . . $with_libkvm
     libmysql  . . . . . . $with_libmysql
@@ -3437,7 +3265,6 @@ Configuration:
     iptables  . . . . . . $enable_iptables
     ipvs  . . . . . . . . $enable_ipvs
     irq . . . . . . . . . $enable_irq
-    java  . . . . . . . . $enable_java
     libvirt . . . . . . . $enable_libvirt
     load  . . . . . . . . $enable_load
     logfile . . . . . . . $enable_logfile
@@ -3448,6 +3275,7 @@ Configuration:
     memcached . . . . . . $enable_memcached
     memory  . . . . . . . $enable_memory
     multimeter  . . . . . $enable_multimeter
+    ted . . . . . . . . . $enable_ted
     mysql . . . . . . . . $enable_mysql
     netlink . . . . . . . $enable_netlink
     network . . . . . . . $enable_network
@@ -3465,7 +3293,6 @@ Configuration:
     postgresql  . . . . . $enable_postgresql
     powerdns  . . . . . . $enable_powerdns
     processes . . . . . . $enable_processes
-    protocols . . . . . . $enable_protocols
     rrdcached . . . . . . $enable_rrdcached
     rrdtool . . . . . . . $enable_rrdtool
     sensors . . . . . . . $enable_sensors
diff --git a/src/Makefile.am b/src/Makefile.am
index 5401bba..84aed55 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -378,17 +378,6 @@ collectd_LDADD += "-dlopen" irq.la
 collectd_DEPENDENCIES += irq.la
 endif
 
-if BUILD_PLUGIN_JAVA
-pkglib_LTLIBRARIES += java.la
-java_la_SOURCES = java.c
-java_la_CPPFLAGS = $(AM_CPPFLAGS) $(JAVA_CPPFLAGS)
-java_la_CFLAGS = $(AM_CFLAGS) $(JAVA_CFLAGS)
-java_la_LDFLAGS = -module -avoid-version $(JAVA_LDFLAGS)
-java_la_LIBADD = $(JAVA_LIBS)
-collectd_LDADD += "-dlopen" java.la
-collectd_DEPENDENCIES += java.la
-endif
-
 if BUILD_PLUGIN_LIBVIRT
 pkglib_LTLIBRARIES += libvirt.la
 libvirt_la_SOURCES = libvirt.c
@@ -497,6 +486,15 @@ collectd_LDADD += "-dlopen" multimeter.la
 collectd_DEPENDENCIES += multimeter.la
 endif
 
+if BUILD_PLUGIN_TED
+pkglib_LTLIBRARIES += ted.la
+ted_la_SOURCES = ted.c
+ted_la_LDFLAGS = -module -avoid-version
+collectd_LDADD += "-dlopen" ted.la
+collectd_DEPENDENCIES += ted.la
+endif
+
+
 if BUILD_PLUGIN_MYSQL
 pkglib_LTLIBRARIES += mysql.la
 mysql_la_SOURCES = mysql.c
@@ -691,14 +689,6 @@ processes_la_LIBADD += -lkvm
 endif
 endif
 
-if BUILD_PLUGIN_PROTOCOLS
-pkglib_LTLIBRARIES += protocols.la
-protocols_la_SOURCES = protocols.c
-protocols_la_LDFLAGS = -module -avoid-version
-collectd_LDADD += "-dlopen" protocols.la
-collectd_DEPENDENCIES += protocols.la
-endif
-
 if BUILD_PLUGIN_RRDCACHED
 pkglib_LTLIBRARIES += rrdcached.la
 rrdcached_la_SOURCES = rrdcached.c utils_rrdcreate.c utils_rrdcreate.h
@@ -932,34 +922,19 @@ collectd_DEPENDENCIES += xmms.la
 endif
 
 
-dist_man_MANS = collectd.1 \
-		collectd.conf.5 \
-		collectd-email.5 \
-		collectd-exec.5 \
-		collectd-java.5
-		collectdmon.1 \
-		collectd-nagios.1 \
-		collectd-perl.5 \
-		collectd-snmp.5 \
-		collectd-unixsock.5 \
+dist_man_MANS = collectd.1 collectd-nagios.1 collectd.conf.5 \
+		collectd-email.5 collectd-exec.5 collectd-perl.5 \
+		collectd-snmp.5 collectd-unixsock.5 collectdmon.1 \
 		types.db.5
 
 #collectd_1_SOURCES = collectd.pod
 
 EXTRA_DIST = types.db
 
-EXTRA_DIST +=   collectd.conf.pod \
-		collectd-email.pod \
-		collectd-exec.pod \
-		collectd-java.pod \
-		collectdmon.pod \
-		collectd-nagios.pod \
-		collectd-perl.pod \
-		collectd.pod \
-		collectd-snmp.pod \
-		collectd-unixsock.pod \
-		postgresql_default.conf \
-		types.db.pod
+EXTRA_DIST += collectd-email.pod collectd-exec.pod collectd-nagios.pod \
+	collectd-perl.pod collectd-snmp.pod collectd-unixsock.pod \
+	collectd.conf.pod collectd.pod collectdmon.pod types.db.pod \
+	postgresql_default.conf
 
 .pod.1:
 	pod2man --release=$(VERSION) --center=$(PACKAGE) $< \
diff --git a/src/ted.c b/src/ted.c
new file mode 100644
index 0000000..8b9c14c
--- /dev/null
+++ b/src/ted.c
@@ -0,0 +1,327 @@
+/**
+ * collectd - src/ted.c
+ * Copyright (C) 2005,2006  Peter Holik
+ *
+ * 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ * Authors:
+ *   Eric Reed <ericr at reedhome.net>
+ *
+ *  This is a collectd module for The Energy Detective: A low-cost whole
+ * house energy monitoring system. For more information on TED, see
+ * http://theenergydetective.com
+ *
+ * This module was not created by Energy, Inc. nor is it supported by
+ * them in any way. It was created using information from two sources:
+ * David Satterfield's TED module for Misterhouse, and Micah Dowty's TED
+ * Python Module.
+ * 
+ * This has only tested with the model 1001 RDU, with
+ * firmware version 9.01U. The USB port is uses the very common FTDI
+ * USB-to-serial chip, so the RDU will show up as a serial device on
+ * Windows, Mac OS, or Linux.
+ **/
+
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
+#include "configfile.h"
+
+#if HAVE_TERMIOS_H && HAVE_SYS_IOCTL_H && HAVE_MATH_H
+# include <termios.h>
+# include <sys/ioctl.h>
+# include <math.h>
+#else
+# error "No applicable input method."
+#endif
+
+
+
+#define LINE_LENGTH 282
+#define PKT_REQUEST  "\xAA"
+#define ESCAPE       0x10
+#define PKT_BEGIN    0x04
+#define PKT_END      0x03
+
+#define DEFAULT_DEVICE "/dev/ttyUSB"
+#define CLIENT_LIST_PREFIX  "CLIENT_LIST,"
+
+static char *device = NULL;
+static int fd = -1;
+
+static const char *config_keys[] = { "Device" };
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+
+
+
+
+static int ted_read_value(double *kv, double *voltage)
+{
+	int retry = 3; /* sometimes we receive garbadge */
+
+	do
+	{
+		struct timeval time_end;
+
+		tcflush(fd, TCIFLUSH);
+
+		if (gettimeofday (&time_end, NULL) < 0)
+	        {
+			char errbuf[1024];
+	                ERROR ("ted plugin: gettimeofday failed: %s",
+					sstrerror (errno, errbuf,
+						sizeof (errbuf)));
+	                return (-1);
+	        }
+	        time_end.tv_sec++;	
+
+		while (1)
+		{
+		        unsigned char buf[4096];
+		        unsigned char package_buffer[4096];
+                        char sResultByte;
+                        char sCmd[1];
+			int status;
+                        int byte;
+                        int package_length=-1;
+                        int start_flag=0;
+                        int escape_flag=0;
+    			struct timeval timeout;
+    			struct timeval time_now;
+                        sCmd[0] = 0xAA;
+
+			status = write (fd, sCmd, 1);
+                        INFO ("status of write %d",status);
+			if (status < 0)
+			{
+				ERROR ("ted plugin: swrite failed.");
+				return (-1);
+			}
+
+
+			if (gettimeofday (&time_now, NULL) < 0)
+	                {
+				char errbuf[1024];
+		                ERROR ("ted plugin: "
+						"gettimeofday failed: %s",
+						sstrerror (errno, errbuf,
+							sizeof (errbuf)));
+	                        return (-1);
+	                }
+			/*if (timeval_cmp (time_end, time_now, &timeout) < 0)
+	                        break; */
+
+                        usleep(700000);
+			status = select(fd+1, NULL, NULL, NULL, &timeout);
+                        INFO ("status 1 %d",status);
+                        status = 1;
+
+
+
+			if (status > 0) /* usually we succeed */
+			{
+				status = read(fd, buf, 4096);
+                                INFO ("status of read %d",status);
+
+				if ((status < 0) && ((errno == EAGAIN) || (errno == EINTR)))
+				        continue;
+
+                                       for (byte=0; byte< status; byte++) {
+                                            sResultByte = buf[byte];
+                                            if (escape_flag) {
+                                                escape_flag = 0;
+                                                if ((sResultByte==ESCAPE) & (package_length > 0)){
+                                                    package_buffer[package_length] = ESCAPE;
+                                                    package_length++;  
+                                                    }          
+                                                else if (sResultByte==PKT_BEGIN){
+                                                    start_flag = 1;
+                                                    package_length=0;
+                                                    }
+                                                else if  (sResultByte==PKT_END){
+                                                    package_buffer[package_length] = '\0';
+                                                    package_length++;
+                                                    }
+                                                }
+                                            else if (sResultByte == ESCAPE)
+                                                escape_flag = 1;
+                                            else if (package_length >= 0){
+                                                package_buffer[package_length] = sResultByte;
+                                                package_length++;  
+                                                }
+
+                                        }
+
+                                 INFO ("read package_length %d",package_length);
+				
+				if (package_length == 279)
+				{
+                                    *kv = ((package_buffer[248] * 256) + package_buffer[247])*10.0;
+                                    INFO ("kv %f",*kv);
+                                    *voltage = ((package_buffer[252] * 256) + package_buffer[251])/10.0;
+                                    INFO ("voltage %f",*voltage);
+                                    return (0); /* value received */
+                                }
+                                else
+                                    INFO ("Not the correct package");
+                                    usleep(700000);
+                                    continue;
+                                    //return (-1); /* Not pro package */
+			}
+			else if (!status) /* Timeout */
+            		{
+	                        break;
+			}
+			else if ((status == -1) && ((errno == EAGAIN) || (errno == EINTR)))
+			{
+                                usleep(700000);
+			        continue;
+			}
+			else /* status == -1 */
+            		{
+				char errbuf[1024];
+		                ERROR ("ted plugin: "
+						"select failed: %s",
+						sstrerror (errno, errbuf, sizeof (errbuf)));
+	                        break;
+			}
+		}
+	} while (--retry);
+
+	return (-2);  /* no value received */
+} /* int ted_read_value */
+
+static int ted_init (void)
+{
+	int i;
+        int status;
+	//char device[] = "/dev/ttyUSB ";
+        char sCmd[1];
+
+        char buf[4096];
+        sCmd[0] = 0xAA;
+        
+        if (device == NULL)
+            device = DEFAULT_DEVICE;
+        
+	for (i = 0; i < 10; i++)
+	{
+		device[strlen(device)-1] = i + '0'; 
+
+		if ((fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK)) > 0)
+		{
+                        struct termios options;
+                        // Get the current options for the port...
+                        tcgetattr(fd, &options);                        
+                        options.c_cflag = B19200 | CS8 | CSTOPB | CREAD | CLOCAL;
+			options.c_iflag = IGNBRK | IGNPAR;
+	    		options.c_oflag = 0;
+			options.c_lflag = 0;
+			options.c_cc[VTIME] = 3;
+			options.c_cc[VMIN]  = 50;
+                                            
+                        // Set the new options for the port...
+                        tcflush(fd, TCIFLUSH);
+                        tcsetattr(fd, TCSANOW, &options);
+                        
+			status = swrite (fd, sCmd, 1);
+                        if (status < 0)
+                            continue;
+                        usleep(900000);
+                        status = read(fd, buf, 4096);
+                        if (status < 0)
+                            continue;
+                        INFO ("status of read %d",status);
+                        INFO ("length of read %d", strlen(buf));
+			
+				INFO ("ted plugin: Device "
+						"found at %s", device);
+				return (0);
+			
+		}
+	}
+
+	ERROR ("ted plugin: No device found");
+	return (-1);
+}
+#undef LINE_LENGTH
+
+static void ted_submit (char *type_instance, double value)
+{
+	value_t values[1];
+	value_list_t vl = VALUE_LIST_INIT;
+
+	values[0].gauge = value;
+
+	vl.values = values;
+	vl.values_len = 1;
+	sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+	sstrncpy (vl.plugin, "ted", sizeof (vl.plugin));
+	sstrncpy (vl.type, "ted", sizeof (vl.type));
+	sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+
+	plugin_dispatch_values (&vl);
+}
+
+static int ted_config (const char *key, const char *value)
+{
+	if (strcasecmp ("Device", key) == 0)
+	{
+		sfree (device);
+		device = sstrdup (value);
+	}
+	else
+	{
+		return (-1);
+	}
+        return (0);
+} /* int openvpn_config */
+
+
+static int ted_read (void)
+{
+	double kv;
+        double voltage;
+
+	if (fd < 0)
+		return (-1);
+
+	if (ted_read_value (&kv,&voltage) != 0)
+		return (-1);
+
+	ted_submit ("kv", kv);	
+        ted_submit ("voltage", voltage);
+	return (0);
+} /* int ted_read */
+
+static int ted_shutdown (void)
+{
+	if (fd >= 0)
+	{
+		close (fd);
+		fd = -1;
+	}
+
+	return (0);
+}
+
+void module_register (void)
+{
+	plugin_register_config ("ted", ted_config,
+				config_keys, config_keys_num);
+	plugin_register_init ("ted", ted_init);
+	plugin_register_read ("ted", ted_read);
+	plugin_register_shutdown ("ted", ted_shutdown);
+} /* void module_register */
diff --git a/src/types.db b/src/types.db
index db46984..7d05e08 100644
--- a/src/types.db
+++ b/src/types.db
@@ -66,6 +66,7 @@ memcached_octets	rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
 memcached_ops		value:COUNTER:0:134217728
 memory			value:GAUGE:0:281474976710656
 multimeter		value:GAUGE:U:U
+ted			value:GAUGE:U:U
 mysql_commands		value:COUNTER:0:U
 mysql_handler		value:COUNTER:0:U
 mysql_octets		rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
@@ -84,11 +85,8 @@ pg_numbackends		value:GAUGE:0:U
 pg_scan			value:COUNTER:0:U
 pg_xact			value:COUNTER:0:U
 ping			ping:GAUGE:0:65535
-ping_droprate		value:GAUGE:0:100
-ping_stddev		value:GAUGE:0:65535
 players			value:GAUGE:0:1000000
 power			value:GAUGE:0:U
-protocol_counter	value:COUNTER:0:U
 ps_count		processes:GAUGE:0:1000000, threads:GAUGE:0:1000000
 ps_cputime		user:COUNTER:0:16000000, syst:COUNTER:0:16000000
 ps_pagefaults		minflt:COUNTER:0:9223372036854775807, majflt:COUNTER:0:9223372036854775807
-- 
1.5.6.3




More information about the collectd mailing list