**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "configfile.h"
# undef SAVE_FOB_64
#endif
+# include <sys/user.h>
# include <dirent.h>
+
+#ifndef MAXCOMLEN
+# define MAXCOMLEN 16
+#endif
+
/* #endif KERNEL_SOLARIS */
#else
return (0);
} /* int ps_list_match */
-static void ps_update_counter (
- _Bool init,
- derive_t *group_counter,
- derive_t *curr_counter, unsigned long *curr_value,
- derive_t new_counter, unsigned long new_value) {
- if (init)
- {
- *curr_value = new_value;
- *curr_counter += new_value;
- *group_counter += new_value;
- return;
- }
-
- if (new_counter < *curr_counter)
- {
- *curr_value = new_counter + (ULONG_MAX - *curr_counter);
- }
- else
- {
- *curr_value = new_counter - *curr_counter;
- }
- *curr_counter = new_counter;
- *group_counter += *curr_value;
+static void ps_update_counter (_Bool init, derive_t *group_counter,
+ derive_t *curr_counter, unsigned long *curr_value,
+ derive_t new_counter, unsigned long new_value)
+{
+ if (init)
+ {
+ *curr_value = new_value;
+ *curr_counter += new_value;
+ *group_counter += new_value;
+ return;
+ }
+
+ if (new_counter < *curr_counter)
+ *curr_value = new_counter + (ULONG_MAX - *curr_counter);
+ else
+ *curr_value = new_counter - *curr_counter;
+
+ *curr_counter = new_counter;
+ *group_counter += *curr_value;
}
/* add process entry to 'instances' of process 'name' (or refresh it) */
for (ps = list_head_g; ps != NULL; ps = ps->next)
{
- _Bool want_init;
+ _Bool want_init;
if ((ps_list_match (name, cmdline, ps)) == 0)
continue;
{
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)
if (fclose (fh))
{
char errbuf[1024];
- WARNING ("processes: fclose: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ WARNING ("processes: fclose: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
}
}
closedir (dh);