X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fprocesses.c;h=c8376812445fce298cd37bd21ed2afad3a2d5e3d;hb=a019b6c8144745db63c599680bd693ac02f11666;hp=954cd0df9d4a4b901a46a11bc8273bbd5ef0cc64;hpb=2b6176cab4f092354177473bbc74c5cdc2eaa2ec;p=collectd.git diff --git a/src/processes.c b/src/processes.c index 954cd0df..c8376812 100644 --- a/src/processes.c +++ b/src/processes.c @@ -80,27 +80,20 @@ # ifndef CONFIG_HZ # define CONFIG_HZ 100 # endif -#endif /* KERNEL_LINUX */ - -#define MODULE_NAME "processes" +/* #endif KERNEL_LINUX */ -#if HAVE_THREAD_INFO || KERNEL_LINUX -# define PROCESSES_HAVE_READ 1 #else -# define PROCESSES_HAVE_READ 0 +# error "No applicable input method." #endif #define BUFSIZE 256 -#if PROCESSES_HAVE_READ -#if HAVE_THREAD_INFO | KERNEL_LINUX static const char *config_keys[] = { "Process", NULL }; static int config_keys_num = 1; -#endif typedef struct procstat_entry_s { @@ -143,9 +136,7 @@ typedef struct procstat struct procstat_entry_s *instances; } procstat_t; -#if HAVE_THREAD_INFO | KERNEL_LINUX static procstat_t *list_head_g = NULL; -#endif #if HAVE_THREAD_INFO static mach_port_t port_host_self; @@ -159,7 +150,6 @@ static mach_msg_type_number_t pset_list_len; static long pagesize_g; #endif /* KERNEL_LINUX */ -#if HAVE_THREAD_INFO | KERNEL_LINUX static void ps_list_register (const char *name) { procstat_t *new; @@ -370,7 +360,6 @@ static int ps_config (const char *key, const char *value) return (0); } -#endif /* HAVE_THREAD_INFO | KERNEL_LINUX */ static int ps_init (void) { @@ -420,9 +409,9 @@ static void ps_submit_state (const char *state, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "processes"); - strcpy (vl.plugin_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "processes", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); strncpy (vl.type_instance, state, sizeof (vl.type_instance)); plugin_dispatch_values ("ps_state", &vl); @@ -436,8 +425,8 @@ static void ps_submit_proc_list (procstat_t *ps) vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "processes"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "processes", sizeof (vl.plugin)); strncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance)); vl.values[0].gauge = ps->vmem_rss; @@ -614,8 +603,8 @@ int ps_read_process (int pid, procstat_t *ps, char *state) /* Leave the rest at zero if this is only a zombi */ if (ps->num_proc == 0) { - DEBUG ("This is only a zombi: pid = %i; name = %s;", - pid, ps->name); + DEBUG ("processes plugin: This is only a zombi: pid = %i; " + "name = %s;", pid, ps->name); return (0); } @@ -861,7 +850,7 @@ static int ps_read (void) * There's only zombie tasks, which are * handled above. */ default: - WARNING ("Unknown thread status: %s", + WARNING ("Unknown thread status: %i", thread_data.run_state); break; } /* switch (thread_data.run_state) */ @@ -1021,16 +1010,11 @@ static int ps_read (void) return (0); } /* int ps_read */ -#endif /* PROCESSES_HAVE_READ */ void module_register (void) { -#if PROCESSES_HAVE_READ -#if HAVE_THREAD_INFO | KERNEL_LINUX plugin_register_config ("processes", ps_config, config_keys, config_keys_num); -#endif plugin_register_init ("processes", ps_init); plugin_register_read ("processes", ps_read); -#endif /* PROCESSES_HAVE_READ */ } /* void module_register */