Code

Added "type" to the value_list_t struct.
[collectd.git] / src / vserver.c
index 651844fc06ddc4efc82b70dc7284d2f35bbd68ea..a22240303c8c17540372cbcdd3edbd1a859ed76c 100644 (file)
@@ -4,8 +4,7 @@
  *
  * 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.
+ * Free Software Foundation; only version 2 of the license is applicable.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
 
 #define BUFSIZE 512
 
-#define MODULE_NAME "vserver"
 #define PROCDIR "/proc/virtual"
 
-#if defined(KERNEL_LINUX)
-# define VSERVER_HAVE_READ 1
-#else
-# define VSERVER_HAVE_READ 0
-#endif /* defined(KERNEL_LINUX) */
+#if !KERNEL_LINUX
+# error "No applicable input method."
+#endif
 
-#if VSERVER_HAVE_READ
 static int pagesize = 0;
 
 static int vserver_init (void)
@@ -65,9 +60,10 @@ static void traffic_submit (const char *plugin_instance,
        strcpy (vl.host, hostname_g);
        strcpy (vl.plugin, "vserver");
        strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+       strcpy (vl.type, "if_octets");
        strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-       plugin_dispatch_values ("if_octets", &vl);
+       plugin_dispatch_values (&vl);
 } /* void traffic_submit */
 
 static void load_submit (const char *plugin_instance,
@@ -86,8 +82,9 @@ static void load_submit (const char *plugin_instance,
        strcpy (vl.host, hostname_g);
        strcpy (vl.plugin, "vserver");
        strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+       strcpy (vl.type, "load");
 
-       plugin_dispatch_values ("load", &vl);
+       plugin_dispatch_values (&vl);
 }
 
 static void submit_gauge (const char *plugin_instance, const char *type,
@@ -105,9 +102,10 @@ static void submit_gauge (const char *plugin_instance, const char *type,
        strcpy (vl.host, hostname_g);
        strcpy (vl.plugin, "vserver");
        strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+       strncpy (vl.type, type, sizeof (vl.type));
        strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-       plugin_dispatch_values (type, &vl);
+       plugin_dispatch_values (&vl);
 } /* void submit_gauge */
 
 static inline long long __get_sock_bytes(const char *s)
@@ -307,14 +305,11 @@ static int vserver_read (void)
 
        return (0);
 } /* int vserver_read */
-#endif /* VSERVER_HAVE_READ */
 
 void module_register (void)
 {
-#if VSERVER_HAVE_READ
        plugin_register_init ("vserver", vserver_init);
        plugin_register_read ("vserver", vserver_read);
-#endif /* VSERVER_HAVE_READ */
 } /* void module_register(void) */
 
 /* vim: set ts=4 sw=4 noexpandtab : */