X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fprocesses.c;h=51ae95d49049c3c6e346ad60333d3f8c272146a4;hb=abc30f241619b3eb66c801c324390e1e9e6e001f;hp=90d4d79e863ed4f9d1abd24e7fb78f1152f4d1ee;hpb=1fc00932fd49fa535551cc4bba09c4e4be059ab4;p=collectd.git diff --git a/src/processes.c b/src/processes.c index 90d4d79e..51ae95d4 100644 --- a/src/processes.c +++ b/src/processes.c @@ -129,6 +129,11 @@ #endif # include + +#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) @@ -1283,6 +1303,10 @@ static int ps_read_process(long pid, procstat_t *ps, char *state) ps->num_proc = 0; ps->num_lwp = 0; *state = (char) 'Z'; + + sfree(myStatus); + sfree(myInfo); + sfree(myUsage); return (0); } else { ps->num_proc = 1; @@ -2047,9 +2071,6 @@ static int ps_read (void) pse.io_syscr = -1; pse.io_syscw = -1; - pse.cswitch_vol = -1; - pse.cswitch_invol = -1; - ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse); switch (procs[i].p_stat) @@ -2292,9 +2313,6 @@ static int ps_read (void) pse.io_syscr = ps.io_syscr; pse.io_syscw = ps.io_syscw; - pse.cswitch_vol = -1; - pse.cswitch_invol = -1; - switch (state) { case 'R': running++; break;