$OpenBSD: patch-platform_OpenBSD_sm_proc_c,v 1.3 2012/01/08 20:38:12 sthen Exp $
--- platform/OpenBSD/sm_proc.c.orig	Mon Jun 14 15:47:29 2010
+++ platform/OpenBSD/sm_proc.c	Sun Jan  8 20:33:43 2012
@@ -54,9 +54,17 @@
 /* Globals for this module start with proc_ */
 #ifdef HAS_KERN_PROC2
 static struct kinfo_proc2 *proc_ps = NULL;
+#define KINFO_NEWAPI
+#define KINFO_MIB KERN_PROC2
+#define KINFO_STRUCT kinfo_proc2
 #else
 static struct kinfo_proc *proc_ps = NULL;
+#if OpenBSD >= 201111
+#define KINFO_NEWAPI
+#define KINFO_MIB KERN_PROC
+#define KINFO_STRUCT kinfo_proc
 #endif
+#endif
 static int proc_max = 0;
 static int proc_cur = 0;
 static int proc_stathz = 0;
@@ -84,39 +92,39 @@ gets_proc()
               __FILE__, __LINE__);
     }
 
-#ifdef HAS_KERN_PROC2
+#ifdef KINFO_NEWAPI
     /* increase buffers if necessary */
     if (procs > proc_max) {
         proc_max = (procs * 5) / 4;
 
         if (proc_max > SYMON_MAX_DOBJECTS) {
-            fatal("%s:%d: dynamic object limit (%d) exceeded for kinfo_proc2 structures",
+            fatal("%s:%d: dynamic object limit (%d) exceeded for kinfo_proc structures",
                   __FILE__, __LINE__, SYMON_MAX_DOBJECTS);
         }
 
-        proc_ps = xrealloc(proc_ps, proc_max * sizeof(struct kinfo_proc2));
+        proc_ps = xrealloc(proc_ps, proc_max * sizeof(struct KINFO_STRUCT));
     }
 
     /* read data in anger */
     mib[0] = CTL_KERN;
-    mib[1] = KERN_PROC2;
+    mib[1] = KINFO_MIB;
     mib[2] = KERN_PROC_KTHREAD;
     mib[3] = 0;
-    mib[4] = sizeof(struct kinfo_proc2);
+    mib[4] = sizeof(struct KINFO_STRUCT);
     mib[5] = proc_max;
-    size = proc_max * sizeof(struct kinfo_proc2);
+    size = proc_max * sizeof(struct KINFO_STRUCT);
     if (sysctl(mib, 6, proc_ps, &size, NULL, 0) < 0) {
         warning("proc probe cannot get processes");
         proc_cur = 0;
         return;
     }
 
-    if (size % sizeof(struct kinfo_proc2) != 0) {
-        warning("proc size mismatch: got %d bytes, not dividable by sizeof(kinfo_proc2) %d",
-                size, sizeof(struct kinfo_proc2));
+    if (size % sizeof(struct KINFO_STRUCT) != 0) {
+        warning("proc size mismatch: got %d bytes, not dividable by sizeof(kinfo_proc) %d",
+                size, sizeof(struct KINFO_STRUCT));
         proc_cur = 0;
     } else {
-        proc_cur = size / sizeof(struct kinfo_proc2);
+        proc_cur = size / sizeof(struct KINFO_STRUCT);
     }
 #else
     /* increase buffers if necessary */
@@ -204,7 +212,7 @@ get_proc(char *symon_buf, int maxlen, struct stream *s
     int n = 0;
 
     for (pp = proc_ps, i = 0; i < proc_cur; pp++, i++) {
-#ifdef HAS_KERN_PROC2
+#ifdef KINFO_NEWAPI
          if (strncmp(st->arg, pp->p_comm, strlen(st->arg)) == 0) {
              /* cpu time - accumulated */
              cpu_uticks += pp->p_uticks;  /* user */
