X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fprocesses.c;h=257f5bb75ab24b53af80b0410489df74d53b3f34;hb=148e8732e45435a051df1c3673cad0d5dc77492f;hp=c0d667d38ab14a15369a6b7e2469f81e72e164ba;hpb=ce140b198884909f060dcdf5bfb7fac8799f50ea;p=collectd.git diff --git a/src/processes.c b/src/processes.c index c0d667d3..257f5bb7 100644 --- a/src/processes.c +++ b/src/processes.c @@ -84,14 +84,14 @@ # endif /* #endif KERNEL_LINUX */ -#elif HAVE_KVM_H +#elif HAVE_LIBKVM_GETPROCS # include # include # include # if HAVE_SYS_SYSCTL_H # include # endif -/* #endif HAVE_KVM_H */ +/* #endif HAVE_LIBKVM_GETPROCS */ #else # error "No applicable input method." @@ -167,7 +167,11 @@ static mach_msg_type_number_t pset_list_len; #elif KERNEL_LINUX static long pagesize_g; -#endif /* KERNEL_LINUX */ +/* #endif KERNEL_LINUX */ + +#elif HAVE_LIBKVM_GETPROCS +/* no global variables */ +#endif /* HAVE_LIBKVM_GETPROCS */ /* put name of process from config to list_head_g tree list_head_g is a list of 'procstat_t' structs with @@ -508,7 +512,11 @@ static int ps_init (void) pagesize_g = sysconf(_SC_PAGESIZE); DEBUG ("pagesize_g = %li; CONFIG_HZ = %i;", pagesize_g, CONFIG_HZ); -#endif /* KERNEL_LINUX */ +/* #endif KERNEL_LINUX */ + +#elif HAVE_LIBKVM_GETPROCS +/* no initialization */ +#endif /* HAVE_LIBKVM_GETPROCS */ return (0); } /* int ps_init */ @@ -524,10 +532,10 @@ 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, ""); - strcpy (vl.type, "ps_state"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "processes", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); + sstrncpy (vl.type, "ps_state", sizeof (vl.type)); sstrncpy (vl.type_instance, state, sizeof (vl.type_instance)); plugin_dispatch_values (&vl); @@ -542,28 +550,28 @@ 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)); sstrncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance)); - strcpy (vl.type, "ps_rss"); + sstrncpy (vl.type, "ps_rss", sizeof (vl.type)); vl.values[0].gauge = ps->vmem_rss; vl.values_len = 1; plugin_dispatch_values (&vl); - strcpy (vl.type, "ps_cputime"); + sstrncpy (vl.type, "ps_cputime", sizeof (vl.type)); vl.values[0].counter = ps->cpu_user_counter; vl.values[1].counter = ps->cpu_system_counter; vl.values_len = 2; plugin_dispatch_values (&vl); - strcpy (vl.type, "ps_count"); + sstrncpy (vl.type, "ps_count", sizeof (vl.type)); vl.values[0].gauge = ps->num_proc; vl.values[1].gauge = ps->num_lwp; vl.values_len = 2; plugin_dispatch_values (&vl); - strcpy (vl.type, "ps_pagefaults"); + sstrncpy (vl.type, "ps_pagefaults", sizeof (vl.type)); vl.values[0].counter = ps->vmem_minflt_counter; vl.values[1].counter = ps->vmem_majflt_counter; vl.values_len = 2; @@ -1131,7 +1139,7 @@ static int ps_read (void) ps_submit_proc_list (ps_ptr); /* #endif KERNEL_LINUX */ -#elif HAVE_LIBKVM +#elif HAVE_LIBKVM_GETPROCS int running = 0; int sleeping = 0; int zombies = 0; @@ -1251,7 +1259,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 */ +#endif /* HAVE_LIBKVM_GETPROCS */ return (0); } /* int ps_read */