X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fprocesses.c;h=261accbcbc7582218c6f5744cb818beba533ffe8;hb=8692579147f7e5cfbd4168a2da926dfd20e592f4;hp=0d670f5bb3787e9e473ce7367d3bbe1e392c72e0;hpb=4f05ee0090750ffb0f4915a894b7924566558988;p=collectd.git diff --git a/src/processes.c b/src/processes.c index 0d670f5b..261accbc 100644 --- a/src/processes.c +++ b/src/processes.c @@ -1,8 +1,9 @@ /** * collectd - src/processes.c - * Copyright (C) 2005 Lyonel Vincent - * Copyright (C) 2006-2008 Florian Forster (Mach code) - * Copyright (C) 2008 Oleg King + * Copyright (C) 2005 Lyonel Vincent + * Copyright (C) 2006-2008 Florian octo Forster + * Copyright (C) 2008 Oleg King + * Copyright (C) 2009 Sebastian Harl * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -85,14 +86,13 @@ # endif /* #endif KERNEL_LINUX */ -#elif HAVE_LIBKVM_GETPROCS +#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD # include +# include +# include # include # include -# if HAVE_SYS_SYSCTL_H -# include -# endif -/* #endif HAVE_LIBKVM_GETPROCS */ +/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */ #else # error "No applicable input method." @@ -102,6 +102,10 @@ # include #endif +#ifndef ARG_MAX +# define ARG_MAX 4096 +#endif + #define BUFSIZE 256 static const char *config_keys[] = @@ -173,9 +177,9 @@ static mach_msg_type_number_t pset_list_len; static long pagesize_g; /* #endif KERNEL_LINUX */ -#elif HAVE_LIBKVM_GETPROCS +#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD /* no global variables */ -#endif /* HAVE_LIBKVM_GETPROCS */ +#endif /* HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */ /* put name of process from config to list_head_g tree list_head_g is a list of 'procstat_t' structs with @@ -532,9 +536,9 @@ static int ps_init (void) pagesize_g, CONFIG_HZ); /* #endif KERNEL_LINUX */ -#elif HAVE_LIBKVM_GETPROCS +#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD /* no initialization */ -#endif /* HAVE_LIBKVM_GETPROCS */ +#endif /* HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */ return (0); } /* int ps_init */ @@ -549,7 +553,6 @@ static void ps_submit_state (const char *state, double value) vl.values = values; vl.values_len = 1; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "processes", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); @@ -567,7 +570,6 @@ static void ps_submit_proc_list (procstat_t *ps) vl.values = values; vl.values_len = 2; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "processes", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance)); @@ -819,7 +821,7 @@ static char *ps_get_cmdline (pid_t pid, char *name, char *buf, size_t buf_len) n = 0; while (42) { - size_t status; + ssize_t status; status = read (fd, (void *)buf_ptr, len); @@ -1276,7 +1278,7 @@ static int ps_read (void) ps_submit_proc_list (ps_ptr); /* #endif KERNEL_LINUX */ -#elif HAVE_LIBKVM_GETPROCS +#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD int running = 0; int sleeping = 0; int zombies = 0; @@ -1355,7 +1357,9 @@ static int ps_read (void) pse.num_proc = 1; pse.num_lwp = procs[i].ki_numthreads; + pse.vmem_size = procs[i].ki_size; pse.vmem_rss = procs[i].ki_rssize * getpagesize(); + pse.stack_size = procs[i].ki_ssize * getpagesize(); pse.vmem_minflt = 0; pse.vmem_minflt_counter = procs[i].ki_rusage.ru_minflt; pse.vmem_majflt = 0; @@ -1396,7 +1400,7 @@ static int ps_read (void) for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next) ps_submit_proc_list (ps_ptr); -#endif /* HAVE_LIBKVM_GETPROCS */ +#endif /* HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */ return (0); } /* int ps_read */