Merge branch 'collectd-5.4' into collectd-5.5
[collectd.git] / src / processes.c
index a17c127..51ae95d 100644 (file)
 #endif
 
 # include <dirent.h>
+
+#ifndef MAXCOMLEN
+#  define MAXCOMLEN 16
+#endif
+
 /* #endif KERNEL_SOLARIS */
 
 #else
@@ -550,6 +555,12 @@ static int ps_config (oconfig_item_t *ci)
 {
        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;
 
@@ -570,6 +581,15 @@ static int ps_config (oconfig_item_t *ci)
                                                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)