diff --git a/src/ipc.c b/src/ipc.c
index c10cdb1d687b6c1e2b2787c3e4f5c8469d216ecc..3763f24837addb2a9b2f523093a49b745119cb78 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
#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;
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);
} /* }}} */
-#if KERNEL_AIX
+#if KERNEL_LINUX
+static int ipc_read_sem (void) /* {{{ */
+{
+ struct seminfo seminfo;
+ union semun arg;
+ int status;
+
+ arg.array = (void *) &seminfo;
+
+ status = semctl (/* id = */ 0, /* num = */ 0, SEM_INFO, arg);
+ if (status == -1)
+ {
+ char errbuf[1024];
+ ERROR("ipc plugin: semctl(2) failed: %s. "
+ "Maybe the kernel is not configured for semaphores?",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);
+ }
+
+ ipc_submit_g("sem", "count", "arrays", seminfo.semusz);
+ ipc_submit_g("sem", "count", "total", seminfo.semaem);
+
+ return (0);
+} /* }}} int ipc_read_sem */
+
+static int ipc_read_shm (void) /* {{{ */
+{
+ struct shm_info shm_info;
+ int status;
+
+ status = shmctl (/* id = */ 0, SHM_INFO, (void *) &shm_info);
+ if (status == -1)
+ {
+ char errbuf[1024];
+ ERROR("ipc plugin: shmctl(2) failed: %s. "
+ "Maybe the kernel is not configured for shared memory?",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);
+ }
+
+ 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);
+ return (0);
+}
+/* }}} int ipc_read_shm */
+
+static int ipc_read_msg (void) /* {{{ */
+{
+ struct msginfo msginfo;
+
+ if ( msgctl(0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo) < 0 )
+ {
+ ERROR("Kernel is not configured for message queues");
+ return (-1);
+ }
+ ipc_submit_g("msg", "count", "queues", msginfo.msgmni);
+ ipc_submit_g("msg", "count", "headers", msginfo.msgmap);
+ ipc_submit_g("msg", "count", "space", msginfo.msgtql);
+
+ return (0);
+}
+/* }}} int ipc_read_msg */
+
+static int ipc_init (void) /* {{{ */
+{
+ pagesize_g = sysconf(_SC_PAGESIZE);
+ return (0);
+}
+/* }}} */
+/* #endif KERNEL_LINUX */
+
+#elif KERNEL_AIX
static caddr_t ipc_get_info (cid_t cid, int cmd, int version, int stsize, int *nmemb) /* {{{ */
{
int size = 0;
@@ -148,27 +227,9 @@ static caddr_t ipc_get_info (cid_t cid, int cmd, int version, int stsize, int *n
return buff;
} /* }}} */
-#endif /* KERNEL_AIX */
static int ipc_read_sem (void) /* {{{ */
{
-#if KERNEL_LINUX
- struct seminfo seminfo;
- union semun arg;
-
- arg.array = (ushort *) (void *) &seminfo;
-
- if ( semctl(0, 0, SEM_INFO, arg) < 0 )
- {
- ERROR("Kernel is not configured for semaphores");
- return (-1);
- }
-
- ipc_submit_g("sem_used_arrays", seminfo.semusz);
- ipc_submit_g("sem_used", seminfo.semaem);
-
-/* #endif KERNEL_LINUX */
-#elif KERNEL_AIX
ipcinfo_sem_t *ipcinfo_sem;
unsigned short sem_nsems=0;
unsigned short sems=0;
}
free(ipcinfo_sem);
- ipc_submit_g("sem_used_arrays", sem_nsems);
- ipc_submit_g("sem_used", sems);
-#endif /* KERNEL_AIX */
+ ipc_submit_g("sem", "count", "arrays", sem_nsems);
+ ipc_submit_g("sem", "count", "total", sems);
return (0);
-}
-/* }}} */
+} /* }}} int ipc_read_sem */
static int ipc_read_shm (void) /* {{{ */
{
-#if KERNEL_LINUX
- struct shm_info shm_info;
- pagesize_g = sysconf(_SC_PAGESIZE);
-
- if ( shmctl(0, SHM_INFO, (struct shmid_ds *) (void *) &shm_info) < 0 )
- {
- 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);
-/* #endif KERNEL_LINUX */
-#elif KERNEL_AIX
ipcinfo_shm_t *ipcinfo_shm;
ipcinfo_shm_t *pshm;
unsigned int shm_segments=0;
}
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);
}
-/* }}} */
+/* }}} int ipc_read_shm */
static int ipc_read_msg (void) /* {{{ */
{
-#if KERNEL_LINUX
- struct msginfo msginfo;
-
- if ( msgctl(0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo) < 0 )
- {
- 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);
-/* #endif KERNEL_LINUX */
-#elif KERNEL_AIX
ipcinfo_msg_t *ipcinfo_msg;
uint32_t msg_used_space=0;
uint32_t msg_alloc_queues=0;
msg_alloc_queues++;
msg_used_space += ipcinfo_msg[i].msg_cbytes;
msg_qnum += ipcinfo_msg[i].msg_qnum;
- }
+
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);
-#endif /* KERNEL_AIX */
+ 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);
+
return (0);
}
/* }}} */
+#endif /* KERNEL_AIX */
static int ipc_read (void) /* {{{ */
{
}
/* }}} */
-#ifdef KERNEL_LINUX
-static int ipc_init (void) /* {{{ */
-{
- pagesize_g = sysconf(_SC_PAGESIZE);
- return (0);
-}
-/* }}} */
-#endif /* KERNEL_LINUX */
-
void module_register (void) /* {{{ */
{
#ifdef KERNEL_LINUX