From: octo Date: Sat, 10 Jun 2006 12:33:34 +0000 (+0000) Subject: processes branch: A first version to collect more detailed process statistics.. X-Git-Tag: collectd-3.11.0~76^2~17 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b1aae570f75a93f475814aa0753ecdb15f967767;p=collectd.git processes branch: A first version to collect more detailed process statistics.. --- diff --git a/src/processes.c b/src/processes.c index fae1c2d0..79c49ef9 100644 --- a/src/processes.c +++ b/src/processes.c @@ -92,6 +92,20 @@ static char *ds_def[] = }; static int ds_num = 6; +typedef struct procstat +{ +#define PROCSTAT_NAME_LEN 256 + char name[PROCSTAT_NAME_LEN]; + unsigned int num_proc; + unsigned int num_lwp; + unsigned int vmem_rss; + unsigned int vmem_minflt; + unsigned int vmem_majflt; + unsigned int cpu_user; + unsigned int cpu_system; + struct procstat *next; +} procstat_t; + #if HAVE_THREAD_INFO static mach_port_t port_host_self; static mach_port_t port_task_self; @@ -104,6 +118,45 @@ static mach_msg_type_number_t pset_list_len; /* No global variables */ #endif /* KERNEL_LINUX */ +static void ps_list_add (procstat_t *list, procstat_t *entry) +{ + procstat_t *ptr; + + ptr = list; + while ((ptr != NULL) && (strcmp (ptr->name, entry->name) != 0)) + ptr = ptr->next; + + if (ptr == NULL) + return; + + ptr->num_proc += entry->num_proc; + ptr->num_lwp += entry->num_lwp; + ptr->vmem_rss += entry->vmem_rss; + ptr->vmem_minflt += entry->vmem_minflt; + ptr->vmem_maxflt += entry->vmem_maxflt; + ptr->cpu_user += entry->cpu_user; + ptr->cpu_system += entry->cpu_system; +} + +static void ps_list_reset (procstat_t *ps) +{ + while (ps != NULL) + { + ps->num_proc = 0; + ps->num_lwp = 0; + ps->vmem_rss = 0; + ps->vmem_minflt = 0; + ps->vmem_maxflt = 0; + ps->cpu_user = 0; + ps->cpu_system = 0; + ps = ps->next; + } +} + +static int ps_config (char *key, char *value) +{ +} + static void ps_init (void) { #if HAVE_THREAD_INFO