2 * collectd - src/processes.c
3 * Copyright (C) 2005 Lyonel Vincent
4 * Copyright (C) 2006 Florian Forster (Mach code)
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Lyonel Vincent <lyonel at ezix.org>
22 * Florian octo Forster <octo at verplant.org>
28 #include "utils_debug.h"
29 #include "configfile.h"
31 /* Include header files for the mach system, if they exist.. */
33 # if HAVE_MACH_MACH_INIT_H
34 # include <mach/mach_init.h>
36 # if HAVE_MACH_HOST_PRIV_H
37 # include <mach/host_priv.h>
39 # if HAVE_MACH_MACH_ERROR_H
40 # include <mach/mach_error.h>
42 # if HAVE_MACH_MACH_HOST_H
43 # include <mach/mach_host.h>
45 # if HAVE_MACH_MACH_PORT_H
46 # include <mach/mach_port.h>
48 # if HAVE_MACH_MACH_TYPES_H
49 # include <mach/mach_types.h>
51 # if HAVE_MACH_MESSAGE_H
52 # include <mach/message.h>
54 # if HAVE_MACH_PROCESSOR_SET_H
55 # include <mach/processor_set.h>
58 # include <mach/task.h>
60 # if HAVE_MACH_THREAD_ACT_H
61 # include <mach/thread_act.h>
63 # if HAVE_MACH_VM_REGION_H
64 # include <mach/vm_region.h>
66 # if HAVE_MACH_VM_MAP_H
67 # include <mach/vm_map.h>
69 # if HAVE_MACH_VM_PROT_H
70 # include <mach/vm_prot.h>
72 /* #endif HAVE_THREAD_INFO */
75 # if HAVE_LINUX_CONFIG_H
76 # include <linux/config.h>
79 # define CONFIG_HZ 100
81 #endif /* KERNEL_LINUX */
83 #define MODULE_NAME "processes"
85 #if HAVE_THREAD_INFO || KERNEL_LINUX
86 # define PROCESSES_HAVE_READ 1
88 # define PROCESSES_HAVE_READ 0
93 static char *processes_file = "processes.rrd";
94 static char *processes_ds_def[] =
96 "DS:running:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
97 "DS:sleeping:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
98 "DS:zombies:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
99 "DS:stopped:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
100 "DS:paging:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
101 "DS:blocked:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
104 static int processes_ds_num = 6;
106 static char *ps_rss_file = "processes/ps_rss-%s.rrd";
107 static char *ps_rss_ds_def[] =
110 "DS:byte:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807",
113 static int ps_rss_ds_num = 1;
115 static char *ps_cputime_file = "processes/ps_cputime-%s.rrd";
116 static char *ps_cputime_ds_def[] =
118 /* 1 second in user-mode per second ought to be enough.. */
119 "DS:user:COUNTER:"COLLECTD_HEARTBEAT":0:1000000",
120 "DS:syst:COUNTER:"COLLECTD_HEARTBEAT":0:1000000",
123 static int ps_cputime_ds_num = 2;
125 static char *ps_count_file = "processes/ps_count-%s.rrd";
126 static char *ps_count_ds_def[] =
128 "DS:processes:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
129 "DS:threads:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
132 static int ps_count_ds_num = 2;
134 static char *ps_pagefaults_file = "processes/ps_pagefaults-%s.rrd";
135 static char *ps_pagefaults_ds_def[] =
138 "DS:minflt:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
139 "DS:majflt:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
142 static int ps_pagefaults_ds_num = 2;
144 static char *config_keys[] =
149 static int config_keys_num = 1;
151 typedef struct procstat_entry_s
156 unsigned long num_proc;
157 unsigned long num_lwp;
158 unsigned long vmem_rss;
160 unsigned long vmem_minflt;
161 unsigned long vmem_majflt;
162 unsigned long vmem_minflt_counter;
163 unsigned long vmem_majflt_counter;
165 unsigned long cpu_user;
166 unsigned long cpu_system;
167 unsigned long cpu_user_counter;
168 unsigned long cpu_system_counter;
170 struct procstat_entry_s *next;
173 #define PROCSTAT_NAME_LEN 256
174 typedef struct procstat
176 char name[PROCSTAT_NAME_LEN];
178 unsigned long num_proc;
179 unsigned long num_lwp;
180 unsigned long vmem_rss;
182 unsigned long vmem_minflt_counter;
183 unsigned long vmem_majflt_counter;
185 unsigned long cpu_user_counter;
186 unsigned long cpu_system_counter;
188 struct procstat *next;
189 struct procstat_entry_s *instances;
192 static procstat_t *list_head_g = NULL;
195 static mach_port_t port_host_self;
196 static mach_port_t port_task_self;
198 static processor_set_name_array_t pset_list;
199 static mach_msg_type_number_t pset_list_len;
200 /* #endif HAVE_THREAD_INFO */
203 static long pagesize_g;
204 #endif /* KERNEL_LINUX */
207 /* ps_list_* not used yet */
208 /* #endif HAVE_THREAD_INFO */
211 static void ps_list_register (const char *name)
216 if ((new = (procstat_t *) malloc (sizeof (procstat_t))) == NULL)
218 memset (new, 0, sizeof (procstat_t));
219 strncpy (new->name, name, PROCSTAT_NAME_LEN);
221 for (ptr = list_head_g; ptr != NULL; ptr = ptr->next)
223 if (strcmp (ptr->name, name) == 0)
225 if (ptr->next == NULL)
235 static procstat_t *ps_list_search (const char *name)
239 for (ptr = list_head_g; ptr != NULL; ptr = ptr->next)
240 if (strcmp (ptr->name, name) == 0)
246 static void ps_list_add (const char *name, procstat_entry_t *entry)
249 procstat_entry_t *pse;
254 if ((ps = ps_list_search (name)) == NULL)
257 for (pse = ps->instances; pse != NULL; pse = pse->next)
258 if ((pse->id == entry->id) || (pse->next == NULL))
261 if ((pse == NULL) || (pse->id != entry->id))
263 procstat_entry_t *new;
265 new = (procstat_entry_t *) malloc (sizeof (procstat_entry_t));
268 memset (new, 0, sizeof (procstat_entry_t));
280 pse->num_proc = entry->num_proc;
281 pse->num_lwp = entry->num_lwp;
282 pse->vmem_rss = entry->vmem_rss;
284 ps->num_proc += pse->num_proc;
285 ps->num_lwp += pse->num_lwp;
286 ps->vmem_rss += pse->vmem_rss;
288 if ((entry->vmem_minflt_counter == 0)
289 && (entry->vmem_majflt_counter == 0))
291 pse->vmem_minflt_counter += entry->vmem_minflt;
292 pse->vmem_minflt = entry->vmem_minflt;
294 pse->vmem_majflt_counter += entry->vmem_majflt;
295 pse->vmem_majflt = entry->vmem_majflt;
299 if (entry->vmem_minflt_counter < pse->vmem_minflt_counter)
301 pse->vmem_minflt = entry->vmem_minflt_counter
302 + (ULONG_MAX - pse->vmem_minflt_counter);
306 pse->vmem_minflt = entry->vmem_minflt_counter - pse->vmem_minflt_counter;
308 pse->vmem_minflt_counter = entry->vmem_minflt_counter;
310 if (entry->vmem_majflt_counter < pse->vmem_majflt_counter)
312 pse->vmem_majflt = entry->vmem_majflt_counter
313 + (ULONG_MAX - pse->vmem_majflt_counter);
317 pse->vmem_majflt = entry->vmem_majflt_counter - pse->vmem_majflt_counter;
319 pse->vmem_majflt_counter = entry->vmem_majflt_counter;
322 ps->vmem_minflt_counter += pse->vmem_minflt;
323 ps->vmem_majflt_counter += pse->vmem_majflt;
325 if ((entry->cpu_user_counter == 0)
326 && (entry->cpu_system_counter == 0))
328 pse->cpu_user_counter += entry->cpu_user;
329 pse->cpu_user = entry->cpu_user;
331 pse->cpu_system_counter += entry->cpu_system;
332 pse->cpu_system = entry->cpu_system;
336 if (entry->cpu_user_counter < pse->cpu_user_counter)
338 pse->cpu_user = entry->cpu_user_counter
339 + (ULONG_MAX - pse->cpu_user_counter);
343 pse->cpu_user = entry->cpu_user_counter - pse->cpu_user_counter;
345 pse->cpu_user_counter = entry->cpu_user_counter;
347 if (entry->cpu_system_counter < pse->cpu_system_counter)
349 pse->cpu_system = entry->cpu_system_counter
350 + (ULONG_MAX - pse->cpu_system_counter);
354 pse->cpu_system = entry->cpu_system_counter - pse->cpu_system_counter;
356 pse->cpu_system_counter = entry->cpu_system_counter;
359 ps->cpu_user_counter += pse->cpu_user;
360 ps->cpu_system_counter += pse->cpu_system;
363 static void ps_list_reset (void)
366 procstat_entry_t *pse;
367 procstat_entry_t *pse_prev;
369 for (ps = list_head_g; ps != NULL; ps = ps->next)
381 DBG ("Removing this procstat entry cause it's too old: "
382 "id = %lu; name = %s;",
385 if (pse_prev == NULL)
387 ps->instances = pse->next;
393 pse_prev->next = pse->next;
395 pse = pse_prev->next;
404 } /* while (pse != NULL) */
405 } /* for (ps = list_head_g; ps != NULL; ps = ps->next) */
407 #endif /* KERNEL_LINUX */
409 static int ps_config (char *key, char *value)
411 if (strcasecmp (key, "Process") == 0)
413 ps_list_register (value);
423 static void ps_init (void)
426 kern_return_t status;
428 port_host_self = mach_host_self ();
429 port_task_self = mach_task_self ();
431 if (pset_list != NULL)
433 vm_deallocate (port_task_self,
434 (vm_address_t) pset_list,
435 pset_list_len * sizeof (processor_set_t));
440 if ((status = host_processor_sets (port_host_self,
442 &pset_list_len)) != KERN_SUCCESS)
444 syslog (LOG_ERR, "host_processor_sets failed: %s\n",
445 mach_error_string (status));
450 /* #endif HAVE_THREAD_INFO */
453 pagesize_g = sysconf(_SC_PAGESIZE);
454 DBG ("pagesize_g = %li; CONFIG_HZ = %i;",
455 pagesize_g, CONFIG_HZ);
456 #endif /* KERNEL_LINUX */
461 static void ps_write (char *host, char *inst, char *val)
463 rrd_update_file (host, processes_file, val,
464 processes_ds_def, processes_ds_num);
467 static void ps_rss_write (char *host, char *inst, char *val)
472 status = snprintf (filename, 256, ps_rss_file, inst);
473 if ((status < 1) || (status >= 256))
476 rrd_update_file (host, filename, val, ps_rss_ds_def, ps_rss_ds_num);
479 static void ps_cputime_write (char *host, char *inst, char *val)
484 status = snprintf (filename, 256, ps_cputime_file, inst);
485 if ((status < 1) || (status >= 256))
488 DBG ("host = %s; filename = %s; val = %s;",
489 host, filename, val);
490 rrd_update_file (host, filename, val,
491 ps_cputime_ds_def, ps_cputime_ds_num);
494 static void ps_count_write (char *host, char *inst, char *val)
499 status = snprintf (filename, 256, ps_count_file, inst);
500 if ((status < 1) || (status >= 256))
503 DBG ("host = %s; filename = %s; val = %s;",
504 host, filename, val);
505 rrd_update_file (host, filename, val,
506 ps_count_ds_def, ps_count_ds_num);
509 static void ps_pagefaults_write (char *host, char *inst, char *val)
514 status = snprintf (filename, 256, ps_pagefaults_file, inst);
515 if ((status < 1) || (status >= 256))
518 DBG ("host = %s; filename = %s; val = %s;",
519 host, filename, val);
520 rrd_update_file (host, filename, val,
521 ps_pagefaults_ds_def, ps_pagefaults_ds_num);
524 #if PROCESSES_HAVE_READ
525 static void ps_submit (int running,
534 if (snprintf (buf, BUFSIZE, "%u:%i:%i:%i:%i:%i:%i",
535 (unsigned int) curtime,
536 running, sleeping, zombies, stopped, paging,
540 DBG ("running = %i; sleeping = %i; zombies = %i; stopped = %i; paging = %i; blocked = %i;",
541 running, sleeping, zombies, stopped, paging, blocked);
543 plugin_submit (MODULE_NAME, "-", buf);
546 static void ps_submit_proc_list (procstat_t *ps)
553 snprintf (buffer, 64, "%u:%lu",
554 (unsigned int) curtime,
557 plugin_submit ("ps_rss", ps->name, buffer);
559 snprintf (buffer, 64, "%u:%u:%u",
560 (unsigned int) curtime,
561 /* Make the counter overflow */
562 (unsigned int) (ps->cpu_user_counter & 0xFFFFFFFF),
563 (unsigned int) (ps->cpu_system_counter & 0xFFFFFFFF));
565 plugin_submit ("ps_cputime", ps->name, buffer);
567 snprintf (buffer, 64, "%u:%lu:%lu",
568 (unsigned int) curtime,
569 ps->num_proc, ps->num_lwp);
571 plugin_submit ("ps_count", ps->name, buffer);
573 snprintf (buffer, 64, "%u:%lu:%lu",
574 (unsigned int) curtime,
575 ps->vmem_minflt_counter, ps->vmem_majflt_counter);
577 plugin_submit ("ps_pagefaults", ps->name, buffer);
579 DBG ("name = %s; num_proc = %lu; num_lwp = %lu; vmem_rss = %lu; "
580 "vmem_minflt_counter = %i; vmem_majflt_counter = %i; "
581 "cpu_user_counter = %i; cpu_system_counter = %i;",
582 ps->name, ps->num_proc, ps->num_lwp, ps->vmem_rss,
583 ps->vmem_minflt_counter, ps->vmem_majflt_counter, ps->cpu_user_counter,
584 ps->cpu_system_counter);
589 static int *ps_read_tasks (int pid)
592 int list_size = 1; /* size of allocated space, in elements */
593 int list_len = 0; /* number of currently used elements */
599 snprintf (dirname, 64, "/proc/%i/task", pid);
602 if ((dh = opendir (dirname)) == NULL)
604 syslog (LOG_NOTICE, "processes plugin: Failed to open directory `%s'",
609 while ((ent = readdir (dh)) != NULL)
611 if (!isdigit (ent->d_name[0]))
614 if ((list_len + 1) >= list_size)
617 int new_size = 2 * list_size;
618 /* Comes in sizes: 2, 4, 8, 16, ... */
620 new_ptr = (int *) realloc (list, (size_t) (sizeof (int) * new_size));
625 syslog (LOG_ERR, "processes plugin: "
626 "Failed to allocate more memory.");
631 list_size = new_size;
633 memset (list + list_len, 0, sizeof (int) * (list_size - list_len));
636 list[list_len] = atoi (ent->d_name);
637 if (list[list_len] != 0)
643 assert (list_len < list_size);
644 assert (list[list_len] == 0);
649 int ps_read_process (int pid, procstat_t *ps, char *state)
664 long long unsigned cpu_user_counter;
665 long long unsigned cpu_system_counter;
666 long long unsigned vmem_rss;
668 memset (ps, 0, sizeof (procstat_t));
670 snprintf (filename, 64, "/proc/%i/stat", pid);
673 if ((fh = fopen (filename, "r")) == NULL)
676 if (fgets (buffer, 1024, fh) == NULL)
684 fields_len = strsplit (buffer, fields, 64);
687 DBG ("`%s' has only %i fields..",
688 filename, fields_len);
691 else if (fields_len != 41)
693 DBG ("WARNING: (fields_len = %i) != 41", fields_len);
696 /* copy the name, strip brackets in the process */
697 name_len = strlen (fields[1]) - 2;
698 if ((fields[1][0] != '(') || (fields[1][name_len + 1] != ')'))
700 DBG ("No brackets found in process name: `%s'", fields[1]);
703 fields[1] = fields[1] + 1;
704 fields[1][name_len] = '\0';
705 strncpy (ps->name, fields[1], PROCSTAT_NAME_LEN);
707 ppid = atoi (fields[3]);
709 if ((tasks = ps_read_tasks (pid)) == NULL)
711 /* This happends for zombied, e.g. */
712 DBG ("ps_read_tasks (%i) failed.", pid);
722 for (i = 0; tasks[i] != 0; i++)
729 /* Leave the rest at zero if this is only an LWP */
730 if (ps->num_proc == 0)
732 DBG ("This is only an LWP: pid = %i; name = %s;",
737 cpu_user_counter = atoll (fields[13]);
738 cpu_system_counter = atoll (fields[14]);
739 vmem_rss = atoll (fields[23]);
740 ps->vmem_minflt_counter = atol (fields[9]);
741 ps->vmem_majflt_counter = atol (fields[11]);
743 /* Convert jiffies to useconds */
744 cpu_user_counter = cpu_user_counter * 1000000 / CONFIG_HZ;
745 cpu_system_counter = cpu_system_counter * 1000000 / CONFIG_HZ;
746 vmem_rss = vmem_rss * pagesize_g;
748 ps->cpu_user_counter = (unsigned long) cpu_user_counter;
749 ps->cpu_system_counter = (unsigned long) cpu_system_counter;
750 ps->vmem_rss = (unsigned long) vmem_rss;
752 *state = fields[2][0];
756 } /* int ps_read_process (...) */
757 #endif /* KERNEL_LINUX */
759 static void ps_read (void)
762 kern_return_t status;
765 processor_set_t port_pset_priv;
768 task_array_t task_list;
769 mach_msg_type_number_t task_list_len;
772 thread_act_array_t thread_list;
773 mach_msg_type_number_t thread_list_len;
774 thread_basic_info_data_t thread_data;
775 mach_msg_type_number_t thread_data_len;
784 * The Mach-concept is a little different from the traditional UNIX
785 * concept: All the work is done in threads. Threads are contained in
786 * `tasks'. Therefore, `task status' doesn't make much sense, since
787 * it's actually a `thread status'.
788 * Tasks are assigned to sets of processors, so that's where you go to
791 for (pset = 0; pset < pset_list_len; pset++)
793 if ((status = host_processor_set_priv (port_host_self,
795 &port_pset_priv)) != KERN_SUCCESS)
797 syslog (LOG_ERR, "host_processor_set_priv failed: %s\n",
798 mach_error_string (status));
802 if ((status = processor_set_tasks (port_pset_priv,
804 &task_list_len)) != KERN_SUCCESS)
806 syslog (LOG_ERR, "processor_set_tasks failed: %s\n",
807 mach_error_string (status));
808 mach_port_deallocate (port_task_self, port_pset_priv);
812 for (task = 0; task < task_list_len; task++)
814 status = task_threads (task_list[task], &thread_list,
816 if (status != KERN_SUCCESS)
818 /* Apple's `top' treats this case a zombie. It
819 * makes sense to some extend: A `zombie'
820 * thread is nonsense, since the task/process
823 DBG ("task_threads failed: %s",
824 mach_error_string (status));
825 if (task_list[task] != port_task_self)
826 mach_port_deallocate (port_task_self,
828 continue; /* with next task_list */
831 for (thread = 0; thread < thread_list_len; thread++)
833 thread_data_len = THREAD_BASIC_INFO_COUNT;
834 status = thread_info (thread_list[thread],
836 (thread_info_t) &thread_data,
838 if (status != KERN_SUCCESS)
840 syslog (LOG_ERR, "thread_info failed: %s\n",
841 mach_error_string (status));
842 if (task_list[task] != port_task_self)
843 mach_port_deallocate (port_task_self,
844 thread_list[thread]);
845 continue; /* with next thread_list */
848 switch (thread_data.run_state)
850 case TH_STATE_RUNNING:
853 case TH_STATE_STOPPED:
854 /* What exactly is `halted'? */
855 case TH_STATE_HALTED:
858 case TH_STATE_WAITING:
861 case TH_STATE_UNINTERRUPTIBLE:
864 /* There is no `zombie' case here,
865 * since there are no zombie-threads.
866 * There's only zombie tasks, which are
870 "Unknown thread status: %s",
871 thread_data.run_state);
873 } /* switch (thread_data.run_state) */
875 if (task_list[task] != port_task_self)
877 status = mach_port_deallocate (port_task_self,
878 thread_list[thread]);
879 if (status != KERN_SUCCESS)
880 syslog (LOG_ERR, "mach_port_deallocate failed: %s",
881 mach_error_string (status));
883 } /* for (thread_list) */
885 if ((status = vm_deallocate (port_task_self,
886 (vm_address_t) thread_list,
887 thread_list_len * sizeof (thread_act_t)))
890 syslog (LOG_ERR, "vm_deallocate failed: %s",
891 mach_error_string (status));
896 /* Only deallocate the task port, if it isn't our own.
897 * Don't know what would happen in that case, but this
898 * is what Apple's top does.. ;) */
899 if (task_list[task] != port_task_self)
901 status = mach_port_deallocate (port_task_self,
903 if (status != KERN_SUCCESS)
904 syslog (LOG_ERR, "mach_port_deallocate failed: %s",
905 mach_error_string (status));
907 } /* for (task_list) */
909 if ((status = vm_deallocate (port_task_self,
910 (vm_address_t) task_list,
911 task_list_len * sizeof (task_t))) != KERN_SUCCESS)
913 syslog (LOG_ERR, "vm_deallocate failed: %s",
914 mach_error_string (status));
919 if ((status = mach_port_deallocate (port_task_self, port_pset_priv))
922 syslog (LOG_ERR, "mach_port_deallocate failed: %s",
923 mach_error_string (status));
925 } /* for (pset_list) */
927 ps_submit (running, sleeping, zombies, stopped, -1, blocked);
928 /* #endif HAVE_THREAD_INFO */
944 procstat_entry_t pse;
949 running = sleeping = zombies = stopped = paging = blocked = 0;
952 if ((proc = opendir ("/proc")) == NULL)
954 syslog (LOG_ERR, "Cannot open `/proc': %s", strerror (errno));
958 while ((ent = readdir (proc)) != NULL)
960 if (!isdigit (ent->d_name[0]))
963 if ((pid = atoi (ent->d_name)) < 1)
966 status = ps_read_process (pid, &ps, &state);
969 DBG ("ps_read_process failed: %i", status);
976 pse.num_proc = ps.num_proc;
977 pse.num_lwp = ps.num_lwp;
978 pse.vmem_rss = ps.vmem_rss;
981 pse.vmem_minflt_counter = ps.vmem_minflt_counter;
983 pse.vmem_majflt_counter = ps.vmem_majflt_counter;
986 pse.cpu_user_counter = ps.cpu_user_counter;
988 pse.cpu_system_counter = ps.cpu_system_counter;
992 case 'R': running++; break;
993 case 'S': sleeping++; break;
994 case 'D': blocked++; break;
995 case 'Z': zombies++; break;
996 case 'T': stopped++; break;
997 case 'W': paging++; break;
1000 ps_list_add (ps.name, &pse);
1005 ps_submit (running, sleeping, zombies, stopped, paging, blocked);
1007 for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
1008 ps_submit_proc_list (ps_ptr);
1009 #endif /* KERNEL_LINUX */
1012 # define ps_read NULL
1013 #endif /* PROCESSES_HAVE_READ */
1015 void module_register (void)
1017 plugin_register (MODULE_NAME, ps_init, ps_read, ps_write);
1018 plugin_register ("ps_rss", NULL, NULL, ps_rss_write);
1019 plugin_register ("ps_cputime", NULL, NULL, ps_cputime_write);
1020 plugin_register ("ps_count", NULL, NULL, ps_count_write);
1021 plugin_register ("ps_pagefaults", NULL, NULL, ps_pagefaults_write);
1022 cf_register (MODULE_NAME, ps_config, config_keys, config_keys_num);