Change IPC plugin to use type_instances.
authorAndrés J. Díaz <ajdiaz@connectical.com>
Tue, 24 Feb 2015 16:54:08 +0000 (17:54 +0100)
committerAndrés J. Díaz <ajdiaz@connectical.com>
Wed, 25 Feb 2015 13:01:46 +0000 (14:01 +0100)
Now the IPC plugin uses a combination of plugin_instance and type_instance
to avoid creation of types.db. Just "segments" type is needed now.

src/Makefile.am
src/ipc.c
src/types.db

index eb10a2b..3a16544 100644 (file)
@@ -400,9 +400,8 @@ endif # BUILD_PLUGIN_INTERFACE
 if BUILD_PLUGIN_IPC
 pkglib_LTLIBRARIES += ipc.la
 ipc_la_SOURCES = ipc.c
-ipc_la_LDFLAGS = -module -avoid-version
-collectd_LDADD += "-dlopen" ipc.la
-collectd_DEPENDENCIES += ipc.la
+ipc_la_CFLAGS = $(AM_CFLAGS)
+ipc_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 endif
 
 if BUILD_PLUGIN_IPTABLES
index c10cdb1..3cf5367 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -89,7 +89,10 @@ static long pagesize_g;
 #endif
 
 __attribute__ ((nonnull(1)))
-static void ipc_submit_g (const char *type, gauge_t value) /* {{{ */
+static void ipc_submit_g (const char *plugin_instance,
+                          const char *type,
+                          const char *type_instance,
+                          gauge_t value) /* {{{ */
 {
   value_t values[1];
   value_list_t vl = VALUE_LIST_INIT;
@@ -100,7 +103,10 @@ static void ipc_submit_g (const char *type, gauge_t value) /* {{{ */
   vl.values_len = 1;
   sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "ipc", sizeof (vl.plugin));
+  sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
+  if (type_instance != NULL)
+    sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
   plugin_dispatch_values (&vl);
 } /* }}} */
@@ -164,8 +170,8 @@ static int ipc_read_sem (void) /* {{{ */
     return (-1);
   }
 
-  ipc_submit_g("sem_used_arrays", seminfo.semusz);
-  ipc_submit_g("sem_used", seminfo.semaem);
+  ipc_submit_g("sem", "count", "arrays", seminfo.semusz);
+  ipc_submit_g("sem", "count", "total", seminfo.semaem);
 
 /* #endif KERNEL_LINUX */
 #elif KERNEL_AIX
@@ -185,8 +191,8 @@ static int ipc_read_sem (void) /* {{{ */
   }
   free(ipcinfo_sem);
 
-  ipc_submit_g("sem_used_arrays", sem_nsems);
-  ipc_submit_g("sem_used", sems);
+  ipc_submit_g("sem", "count", "arrays", sem_nsems);
+  ipc_submit_g("sem", "count", "total", sems);
 #endif /* KERNEL_AIX */
 
   return (0);
@@ -204,10 +210,10 @@ static int ipc_read_shm (void) /* {{{ */
     ERROR("Kernel is not configured for shared memory");
     return (-1);
   }
-  ipc_submit_g("shm_segments", shm_info.used_ids);
-  ipc_submit_g("shm_bytes_total", shm_info.shm_tot * pagesize_g);
-  ipc_submit_g("shm_bytes_rss", shm_info.shm_rss * pagesize_g);
-  ipc_submit_g("shm_bytes_swapped", shm_info.shm_swp * pagesize_g);
+  ipc_submit_g("shm", "segments", NULL, shm_info.used_ids);
+  ipc_submit_g("shm", "bytes", "total", shm_info.shm_tot * pagesize_g);
+  ipc_submit_g("shm", "bytes", "rss", shm_info.shm_rss * pagesize_g);
+  ipc_submit_g("shm", "bytes", "swapped", shm_info.shm_swp * pagesize_g);
 /* #endif KERNEL_LINUX */
 #elif KERNEL_AIX
   ipcinfo_shm_t *ipcinfo_shm;
@@ -227,8 +233,8 @@ static int ipc_read_shm (void) /* {{{ */
   }
   free(ipcinfo_shm);
 
-  ipc_submit_g("shm_segments", shm_segments);
-  ipc_submit_g("shm_bytes_total", shm_bytes);
+  ipc_submit_g("shm", "segments", NULL, shm_segments);
+  ipc_submit_g("shm", "bytes", "total", shm_bytes);
 
 #endif /* KERNEL_AIX */
   return (0);
@@ -245,9 +251,9 @@ static int ipc_read_msg (void) /* {{{ */
     ERROR("Kernel is not configured for message queues");
     return (-1);
   }
-  ipc_submit_g("msg_alloc_queues", msginfo.msgmni);
-  ipc_submit_g("msg_used_headers", msginfo.msgmap);
-  ipc_submit_g("msg_used_space", msginfo.msgtql);
+  ipc_submit_g("msg", "count", "queues", msginfo.msgmni);
+  ipc_submit_g("msg", "count", "headers", msginfo.msgmap);
+  ipc_submit_g("msg", "count", "space", msginfo.msgtql);
 /* #endif KERNEL_LINUX */
 #elif KERNEL_AIX
   ipcinfo_msg_t *ipcinfo_msg;
@@ -268,9 +274,9 @@ static int ipc_read_msg (void) /* {{{ */
   }
   free(ipcinfo_msg);
 
-  ipc_submit_g("msg_alloc_queues", msg_alloc_queues);
-  ipc_submit_g("msg_used_headers", msg_qnum);
-  ipc_submit_g("msg_used_space", msg_used_space);
+  ipc_submit_g("msg", "count", "queues", msg_alloc_queues);
+  ipc_submit_g("msg", "count", "headers", msg_qnum);
+  ipc_submit_g("msg", "count", "space", msg_used_space);
 #endif /* KERNEL_AIX */
   return (0);
 }
index 2df98cd..b11aa3c 100644 (file)
@@ -105,9 +105,6 @@ memcached_octets    rx:DERIVE:0:U, tx:DERIVE:0:U
 memcached_ops          value:DERIVE:0:U
 memory                 value:GAUGE:0:281474976710656
 memory_lua             value:GAUGE:0:281474976710656
-msg_alloc_queues  value:GAUGE:0:65535
-msg_used_headers  value:GAUGE:0:65535
-msg_used_space    value:GAUGE:0:65535
 multimeter             value:GAUGE:U:U
 mutex_operations       value:DERIVE:0:U
 mysql_commands         value:DERIVE:0:U
@@ -179,13 +176,8 @@ response_code              value:GAUGE:0:U
 route_etx              value:GAUGE:0:U
 route_metric           value:GAUGE:0:U
 routes                 value:GAUGE:0:U
-sem_used_arrays    value:GAUGE:0:65535
-sem_used    value:GAUGE:0:65535
+segments               value:GAUGE:0:65535
 serial_octets          rx:DERIVE:0:U, tx:DERIVE:0:U
-shm_bytes_rss    value:GAUGE:0:65535
-shm_bytes_swapped  value:GAUGE:0:65535
-shm_bytes_total    value:GAUGE:0:65535
-shm_segments    value:GAUGE:0:65535
 signal_noise           value:GAUGE:U:0
 signal_power           value:GAUGE:U:0
 signal_quality         value:GAUGE:0:U