author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sun, 24 Apr 2016 11:25:21 +0000 (13:25 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sun, 24 Apr 2016 11:25:21 +0000 (13:25 +0200) |
processes: warn about process names above OS limit
src/collectd.conf.pod | patch | blob | history | |
src/processes.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index c67b19e899d216a053375648aa8d7572de9b056f..416365678e007ff4059a0537e370ac070ed7df3c 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
(RSS), user- and system-time used, number of processes and number of threads,
io data (where available) and minor and major pagefaults.
+Some platforms have a limit on the length of process names. I<Name> must stay
+below this limit.
+
=item B<ProcessMatch> I<name> I<regex>
Similar to the B<Process> option this allows to select more detailed
diff --git a/src/processes.c b/src/processes.c
index 164d33cbfc4b9ec4a88173acc006057ccfc023df..7711f25de02d3c94d43b8a72e772e1d2e696621e 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
# undef SAVE_FOB_64
#endif
+# include <sys/user.h>
# include <dirent.h>
/* #endif KERNEL_SOLARIS */
{
int i;
+#if KERNEL_LINUX
+ const size_t max_procname_len = 15;
+#elif KERNEL_SOLARIS || KERNEL_FREEBSD
+ const size_t max_procname_len = MAXCOMLEN -1;
+#endif
+
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *c = ci->children + i;
c->children_num, c->values[0].value.string);
}
+#if KERNEL_LINUX || KERNEL_SOLARIS || KERNEL_FREEBSD
+ if (strlen (c->values[0].value.string) > max_procname_len) {
+ WARNING ("processes plugin: this platform has a %zu character limit "
+ "to process names. The `Process \"%s\"' option will "
+ "not work as expected.",
+ max_procname_len, c->values[0].value.string);
+ }
+#endif
+
ps_list_register (c->values[0].value.string, NULL);
}
else if (strcasecmp (c->key, "ProcessMatch") == 0)