summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorhe <he@pkgsrc.org>2015-08-14 15:39:28 +0000
committerhe <he@pkgsrc.org>2015-08-14 15:39:28 +0000
commit595a1bf82def6c216e577cadb489377997ed5a60 (patch)
tree6ef2b638c3c7903b5017649a722a7f3280940834 /sysutils
parent88a1e9fa3547b5b60a6466834e5953ab82d53469 (diff)
downloadpkgsrc-595a1bf82def6c216e577cadb489377997ed5a60.tar.gz
Add a port of the processes plugin to NetBSD.
Bump PKGREVISION.
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/collectd/Makefile4
-rw-r--r--sysutils/collectd/distinfo7
-rw-r--r--sysutils/collectd/options.mk6
-rw-r--r--sysutils/collectd/patches/patch-configure7
-rw-r--r--sysutils/collectd/patches/patch-configure.ac7
-rw-r--r--sysutils/collectd/patches/patch-src_processes.c249
6 files changed, 266 insertions, 14 deletions
diff --git a/sysutils/collectd/Makefile b/sysutils/collectd/Makefile
index e5aa8cd6f3c..59387962c4a 100644
--- a/sysutils/collectd/Makefile
+++ b/sysutils/collectd/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.8 2015/08/11 14:15:00 he Exp $
+# $NetBSD: Makefile,v 1.9 2015/08/14 15:39:28 he Exp $
-PKGREVISION= 3
+PKGREVISION= 4
.include "../../sysutils/collectd/Makefile.common"
COMMENT= Statistics collection daemon base
diff --git a/sysutils/collectd/distinfo b/sysutils/collectd/distinfo
index 9047934e239..bcec54da9c8 100644
--- a/sysutils/collectd/distinfo
+++ b/sysutils/collectd/distinfo
@@ -1,11 +1,11 @@
-$NetBSD: distinfo,v 1.11 2015/08/14 12:59:04 he Exp $
+$NetBSD: distinfo,v 1.12 2015/08/14 15:39:28 he Exp $
SHA1 (collectd-5.5.0.tar.gz) = d24e284c1eae20c5e75b846c8b2612ab65bd5565
RMD160 (collectd-5.5.0.tar.gz) = 2197758942a5fe56e4eabda3786f09d4138e943a
Size (collectd-5.5.0.tar.gz) = 2244454 bytes
SHA1 (patch-Makefile.in) = 197307399312fa26c71ca168b92bbe41d31d556d
-SHA1 (patch-configure) = ca8949de66bd19c4d398223d182e9fbecdcf861a
-SHA1 (patch-configure.ac) = 48c0eedbd3de5e09a5593670017aff661744c7bc
+SHA1 (patch-configure) = 9157fc6e9924567a8cac0d75dccbba4c4383f641
+SHA1 (patch-configure.ac) = f22091c630bb84a9b24dbc94ed5fc66607ffc23a
SHA1 (patch-src_Makefile.in) = f94d046ee323fdb9251ad49cf383b3a61df5dcaa
SHA1 (patch-src_collectd-tg.c) = f9f41dfb0b1b55a62202128a165d5c9943faf5bc
SHA1 (patch-src_collectd.conf.in) = f0b35085cf0ddfd766e140b145177ab1f1326f5f
@@ -15,6 +15,7 @@ SHA1 (patch-src_disk.c) = 159862e8ca1e841e3c4013c03ba03f059fdbbab5
SHA1 (patch-src_entropy.c) = d9bfa1bd4d045f2218105eaadf2dda90b7fc4646
SHA1 (patch-src_libcollectclient_network__buffer.c) = e07d403d299613fa0885a0e7285849eb85510253
SHA1 (patch-src_memory.c) = 7bbf24481e2ad6bb8b11a5e6bddd8145e1b2a6ef
+SHA1 (patch-src_processes.c) = 32ca0414efaf57cb0b95b51d98b904008b5fe306
SHA1 (patch-src_swap.c) = e7602eb83eed6b90752b8293b9666b94bdd42493
SHA1 (patch-src_tcpconns.c) = 712af1b821d62217283df884dd283d5b1218ab7c
SHA1 (patch-src_utils__dns.c) = c3782dc9127f42da30e3142b853aa2cb2259af94
diff --git a/sysutils/collectd/options.mk b/sysutils/collectd/options.mk
index a76c8eee029..f02a13ed61a 100644
--- a/sysutils/collectd/options.mk
+++ b/sysutils/collectd/options.mk
@@ -1,12 +1,12 @@
-# $NetBSD: options.mk,v 1.3 2015/08/11 13:19:21 he Exp $
+# $NetBSD: options.mk,v 1.4 2015/08/14 15:39:28 he Exp $
PKG_OPTIONS_VAR= PKG_OPTIONS.collectd
PKG_SUPPORTED_OPTIONS= cpu df interface load memory syslog uptime
PKG_SUGGESTED_OPTIONS+= cpu df interface load memory syslog uptime
.if ${OPSYS} == "NetBSD"
-PKG_SUPPORTED_OPTIONS+= contextswitch disk entropy pf swap tcpconns users
-PKG_SUGGESTED_OPTIONS+= contextswitch disk entropy pf swap tcpconns users
+PKG_SUPPORTED_OPTIONS+= contextswitch disk entropy pf processes swap tcpconns users
+PKG_SUGGESTED_OPTIONS+= contextswitch disk entropy pf processes swap tcpconns users
.endif
.if ${OPSYS} == "FreeBSD"
diff --git a/sysutils/collectd/patches/patch-configure b/sysutils/collectd/patches/patch-configure
index 1805d3ac3ed..89a8582ff81 100644
--- a/sysutils/collectd/patches/patch-configure
+++ b/sysutils/collectd/patches/patch-configure
@@ -1,4 +1,4 @@
-$NetBSD: patch-configure,v 1.4 2015/08/14 12:59:04 he Exp $
+$NetBSD: patch-configure,v 1.5 2015/08/14 15:39:28 he Exp $
Regen from configure.ac.
@@ -147,20 +147,21 @@ Regen from configure.ac.
ac_fn_c_check_member "$LINENO" "struct udphdr" "uh_dport" "ac_cv_member_struct_udphdr_uh_dport" "#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#if HAVE_STDINT_H
-@@ -27648,6 +27725,12 @@ then
+@@ -27648,6 +27725,13 @@ then
plugin_tcpconns="yes"
fi
+if test "x$ac_system" = "xNetBSD"
+then
+ plugin_entropy="yes"
++ plugin_processes="yes"
+ plugin_disk="yes"
+fi
+
# Mac OS X devices
if test "x$with_libiokit" = "xyes"
then
-@@ -27890,6 +27973,11 @@ then
+@@ -27890,6 +27974,11 @@ then
plugin_swap="yes"
fi
diff --git a/sysutils/collectd/patches/patch-configure.ac b/sysutils/collectd/patches/patch-configure.ac
index e026c5cc727..3337912fc5d 100644
--- a/sysutils/collectd/patches/patch-configure.ac
+++ b/sysutils/collectd/patches/patch-configure.ac
@@ -1,4 +1,4 @@
-$NetBSD: patch-configure.ac,v 1.2 2015/08/14 12:59:04 he Exp $
+$NetBSD: patch-configure.ac,v 1.3 2015/08/14 15:39:28 he Exp $
Add KERNEL_NETBSD, add entry and disk plugins for NetBSD,
and also do swap for "have_swapctl_three_args" (as for NetBSD).
@@ -58,20 +58,21 @@ Also, the start of process support, but that's not yet finished.
AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
[#define _BSD_SOURCE
#define _DEFAULT_SOURCE
-@@ -5244,6 +5275,12 @@ then
+@@ -5244,6 +5275,13 @@ then
plugin_tcpconns="yes"
fi
+if test "x$ac_system" = "xNetBSD"
+then
+ plugin_entropy="yes"
++ plugin_processes="yes"
+ plugin_disk="yes"
+fi
+
# Mac OS X devices
if test "x$with_libiokit" = "xyes"
then
-@@ -5482,6 +5519,11 @@ then
+@@ -5482,6 +5520,11 @@ then
plugin_swap="yes"
fi
diff --git a/sysutils/collectd/patches/patch-src_processes.c b/sysutils/collectd/patches/patch-src_processes.c
new file mode 100644
index 00000000000..85b48401eb1
--- /dev/null
+++ b/sysutils/collectd/patches/patch-src_processes.c
@@ -0,0 +1,249 @@
+$NetBSD: patch-src_processes.c,v 1.1 2015/08/14 15:39:28 he Exp $
+
+Add a port to NetBSD.
+
+--- src/processes.c.orig 2015-05-20 12:04:47.000000000 +0000
++++ src/processes.c
+@@ -94,13 +94,13 @@
+ # endif
+ /* #endif KERNEL_LINUX */
+
+-#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC_NETBSD)
+ # include <kvm.h>
+ # include <sys/param.h>
+ # include <sys/sysctl.h>
+ # include <sys/user.h>
+ # include <sys/proc.h>
+-/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC_NETBSD) */
+
+ #elif HAVE_PROCINFO_H
+ # include <procinfo.h>
+@@ -229,9 +229,14 @@ static mach_msg_type_number_t pset_l
+ static long pagesize_g;
+ /* #endif KERNEL_LINUX */
+
+-#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC_NETBSD)
+ static int pagesize;
+-/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++
++#if KERNEL_NETBSD
++int maxslp;
++#endif
++
++/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC_NETBSD) */
+
+ #elif HAVE_PROCINFO_H
+ static struct procentry64 procentry[MAXPROCENTRY];
+@@ -638,9 +643,20 @@ static int ps_init (void)
+ pagesize_g, CONFIG_HZ);
+ /* #endif KERNEL_LINUX */
+
+-#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC_NETBSD)
++#if KERNEL_NETBSD
++ int mib[2];
++ size_t size;
++
++ mib[0] = CTL_VM;
++ mib[1] = VM_MAXSLP;
++ size = sizeof(maxslp);
++ if (sysctl(mib, 2, &maxslp, &size, NULL, 0) == -1)
++ maxslp = 20; /* reasonable default? */
++#endif
++
+ pagesize = getpagesize();
+-/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC_NETBSD) */
+
+ #elif HAVE_PROCINFO_H
+ pagesize = getpagesize();
+@@ -1940,6 +1956,186 @@ static int ps_read (void)
+ ps_submit_proc_list (ps_ptr);
+ /* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+
++#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_NETBSD
++ int running = 0;
++ int sleeping = 0;
++ int zombies = 0;
++ int stopped = 0;
++ int blocked = 0;
++ int idle = 0;
++ int wait = 0;
++
++ kvm_t *kd;
++ char errbuf[_POSIX2_LINE_MAX];
++ struct kinfo_proc2 *procs; /* array of processes */
++ struct kinfo_proc2 *proc_ptr = NULL;
++ struct kinfo_proc2 *p;
++ int count; /* returns number of processes */
++ int i;
++ int l, nlwps;
++ struct kinfo_lwp *kl;
++
++ procstat_t *ps_ptr;
++ procstat_entry_t pse;
++
++ ps_list_reset ();
++
++ /* Open the kvm interface, get a descriptor */
++ kd = kvm_openfiles (NULL, NULL, NULL, KVM_NO_FILES, errbuf);
++ if (kd == NULL)
++ {
++ ERROR ("processes plugin: Cannot open kvm interface: %s",
++ errbuf);
++ return (0);
++ }
++
++ /* Get the list of processes. */
++ procs = kvm_getproc2(kd, KERN_PROC_ALL, 0,
++ sizeof(struct kinfo_proc2), &count);
++ if (procs == NULL)
++ {
++ ERROR ("processes plugin: Cannot get kvm processes list: %s",
++ kvm_geterr(kd));
++ kvm_close (kd);
++ return (0);
++ }
++
++ /* Iterate through the processes in kinfo_proc */
++ for (i = 0; i < count; i++)
++ {
++ /* Create only one process list entry per _process_, i.e.
++ * filter out threads (duplicate PID entries). */
++ if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid))
++ {
++ char cmdline[CMDLINE_BUFFER_SIZE] = "";
++ _Bool have_cmdline = 0;
++
++ proc_ptr = &(procs[i]);
++ /* Don't probe system processes and processes without arguments */
++ if (((procs[i].p_flag & P_SYSTEM) == 0)
++ && (procs[i].p_comm[0] != 0))
++ {
++ char **argv;
++ int argc;
++ int status;
++
++ /* retrieve the arguments */
++ argv = kvm_getargv2 (kd, proc_ptr, 0);
++ argc = 0;
++ if ((argv != NULL) && (argv[0] != NULL))
++ {
++ while (argv[argc] != NULL)
++ argc++;
++
++ status = strjoin (cmdline, sizeof (cmdline), argv, argc, " ");
++ if (status < 0)
++ WARNING ("processes plugin: Command line did not fit into buffer.");
++ else
++ have_cmdline = 1;
++ }
++ } /* if (process has argument list) */
++
++ pse.id = procs[i].p_pid;
++ pse.age = 0;
++
++ pse.num_proc = 1;
++ pse.num_lwp = procs[i].p_nlwps;
++
++ pse.vmem_size = procs[i].p_uru_maxrss * pagesize;
++ pse.vmem_rss = procs[i].p_vm_rssize * pagesize;
++ pse.vmem_data = procs[i].p_vm_dsize * pagesize;
++ pse.vmem_code = procs[i].p_vm_tsize * pagesize;
++ pse.stack_size = procs[i].p_vm_ssize * pagesize;
++ pse.vmem_minflt = 0;
++ pse.vmem_minflt_counter = procs[i].p_uru_minflt;
++ pse.vmem_majflt = 0;
++ pse.vmem_majflt_counter = procs[i].p_uru_majflt;
++
++ pse.cpu_user = 0;
++ pse.cpu_system = 0;
++ pse.cpu_user_counter = 0;
++ pse.cpu_system_counter = 0;
++ /*
++ * The u-area might be swapped out, and we can't get
++ * at it because we have a crashdump and no swap.
++ * If it's here fill in these fields, otherwise, just
++ * leave them 0.
++ */
++ if (procs[i].p_flag & P_INMEM)
++ {
++ pse.cpu_user_counter = procs[i].p_uutime_usec
++ + (1000000lu * procs[i].p_uutime_sec);
++ pse.cpu_system_counter = procs[i].p_ustime_usec
++ + (1000000lu * procs[i].p_ustime_sec);
++ }
++
++ /* no I/O data */
++ pse.io_rchar = -1;
++ pse.io_wchar = -1;
++ pse.io_syscr = procs[i].p_uru_inblock;
++ pse.io_syscw = procs[i].p_uru_oublock;
++
++ ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse);
++ } /* if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid)) */
++
++ /* system processes' LWPs end up in "running" state */
++ if ((procs[i].p_flag & P_SYSTEM) != 0)
++ continue;
++
++ switch (procs[i].p_realstat)
++ {
++ case SSTOP:
++ case SACTIVE:
++ case SIDL:
++ p = &(procs[i]);
++ /* get info about LWPs */
++ kl = kvm_getlwps(kd, p->p_pid, (u_long)p->p_paddr,
++ sizeof(struct kinfo_lwp), &nlwps);
++
++ for (l = 0; l < nlwps; l++) {
++ switch (kl[l].l_stat) {
++ case LSONPROC:
++ case LSRUN:
++ running++;
++ break;
++ case LSSLEEP:
++ if (kl[l].l_flag & L_SINTR) {
++ if (kl[l].l_slptime > maxslp)
++ idle++;
++ else
++ sleeping++;
++ } else
++ blocked++;
++ break;
++ case LSSTOP:
++ stopped++; break;
++ case LSIDL:
++ idle++; break;
++ }
++ }
++ break;
++ case SZOMB:
++ case SDYING:
++ case SDEAD:
++ zombies++; break;
++
++ }
++ }
++
++ kvm_close(kd);
++
++ ps_submit_state ("running", running);
++ ps_submit_state ("sleeping", sleeping);
++ ps_submit_state ("zombies", zombies);
++ ps_submit_state ("stopped", stopped);
++ ps_submit_state ("blocked", blocked);
++ ps_submit_state ("idle", idle);
++ ps_submit_state ("wait", wait);
++
++ for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
++ ps_submit_proc_list (ps_ptr);
++/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_NETBSD */
++
+ #elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_OPENBSD
+ int running = 0;
+ int sleeping = 0;