0

i am trying to comile net-snmp 5.7.1 at openBSD5.1. theerror in compile is

structure has no member named kp_proc' structure has no member namedkp_eproc'

can anyone help me about this ??

and how to do python binding at openBSD ??

1 Answer 1

1

ok this may be a long post, as we will try to port your software on OpenBSD.
You see OpenBSD doesn't have this eproc field on it's k_proc struct. check the declaration: proc@OpenBSD

grepping the problem in the latest source:

./agent/mibgroup/host/data_access/swrun_kinfo.c:        entry->hrSWRunPerfCPU  =     proc_table[i].kp_eproc.e_uticks;
./agent/mibgroup/host/data_access/swrun_kinfo.c:        entry->hrSWRunPerfCPU += proc_table[i].kp_eproc.e_sticks;
./agent/mibgroup/host/data_access/swrun_kinfo.c:        entry->hrSWRunPerfCPU +=   proc_table[i].kp_eproc.e_iticks;
./agent/mibgroup/host/data_access/swrun_kinfo.c:        entry->hrSWRunPerfMem  = proc_table[i].kp_eproc.e_vm.vm_tsize;
./agent/mibgroup/host/data_access/swrun_kinfo.c:        entry->hrSWRunPerfMem += proc_table[i].kp_eproc.e_vm.vm_ssize;
./agent/mibgroup/host/data_access/swrun_kinfo.c:        entry->hrSWRunPerfMem += proc_table[i].kp_eproc.e_vm.vm_dsize;
./agent/mibgroup/host/hr_swrun.c:        long_return = proc_table[LowProcIndex].kp_eproc.e_uticks +
./agent/mibgroup/host/hr_swrun.c:            proc_table[LowProcIndex].kp_eproc.e_sticks +
./agent/mibgroup/host/hr_swrun.c:            proc_table[LowProcIndex].kp_eproc.e_iticks;
./agent/mibgroup/host/hr_swrun.c:            proc_table[LowProcIndex].kp_eproc.e_vm.vm_map.size / 1024;
./agent/mibgroup/host/hr_swrun.c:        long_return = proc_table[LowProcIndex].kp_eproc.e_vm.vm_tsize +
./agent/mibgroup/host/hr_swrun.c:            proc_table[LowProcIndex].kp_eproc.e_vm.vm_ssize +
./agent/mibgroup/host/hr_swrun.c:            proc_table[LowProcIndex].kp_eproc.e_vm.vm_dsize;
./agent/mibgroup/ucd-snmp/proc.c:#define EP(pp, field) ((pp)->kp_eproc . field)
./agent/mibgroup/ucd-snmp/proc.c:#define VP(pp, field) ((pp)->kp_eproc.e_vm . field)

aha! so we need to take care also of these vm structs... our corrensponding decleration is : p_vmspace@OpenBSD

ok so in general changing on these .kp_eproc.e_thing to .p_thing
and .kp_eproc.e_vm.thing to .p_vmspace->thing (it's a pointer) should work.

The macros need some care and i think i got them right, but since i'm still compiling these changes on a pretty slow sparc64 it's going to take some time to get you the tested diff.

but that should be the general idea.

If your whole process works OK , you can add this patch to your ports/ tree along with an easy to craft Makefile and have your OpenBSD package administered with pkg_* tools,but more in future edits.

cheers!

DsP

Edit: Here is a first diff that will compile , the second macro is wrong though . please test.

diff -ur net-snmp-5.7.1/agent/mibgroup/host/data_access/swrun_kinfo.c mynet-    snmp-5.7.1/agent/mibgroup/host/data_access/swrun_kinfo.c
--- net-snmp-5.7.1/agent/mibgroup/host/data_access/swrun_kinfo.c        Wed Sep 28 07:53:47 2011
+++ mynet-snmp-5.7.1/agent/mibgroup/host/data_access/swrun_kinfo.c      Wed Sep  5 04:26:54 2012
@@ -85,10 +85,10 @@
  * early FreeBSD, NetBSD, OpenBSD kinfo_proc field names
  */
 #define SWRUN_TABLE    kinfo_proc
 -#define SWRUN_K_STAT   kp_proc.p_stat
 -#define SWRUN_K_PID    kp_proc.p_pid
 -#define SWRUN_K_COMM   kp_proc.p_comm
 -#define SWRUN_K_FLAG   kp_proc.p_flag
 +#define SWRUN_K_STAT   p_stat
 +#define SWRUN_K_PID    p_pid
 +#define SWRUN_K_COMM   p_comm
 +#define SWRUN_K_FLAG   p_flag
 /*      SWRUN_K_CLASS  not defined     */
 #endif

@@ -159,7 +159,8 @@
 #if HAVE_KVM_GETPROC2
     proc_table = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), &nprocs );
 #else
-    proc_table = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nprocs );
+    proc_table = kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc), &nprocs );
+    //proc_table = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nprocs );
 #endif
     for ( i=0 ; i<nprocs; i++ ) {
         if ( 0 == proc_table[i].SWRUN_K_STAT )
@@ -304,21 +305,22 @@
        entry->hrSWRunPerfCPU += proc_table[i].kp_lwp.kl_iticks;
        entry->hrSWRunPerfMem  = proc_table[i].kp_vm_map_size / 1024;
 #elif defined(dragonfly)
-       entry->hrSWRunPerfCPU  = proc_table[i].kp_eproc.e_uticks;
-       entry->hrSWRunPerfCPU += proc_table[i].kp_eproc.e_sticks;
-       entry->hrSWRunPerfCPU += proc_table[i].kp_eproc.e_iticks;
+       entry->hrSWRunPerfCPU  = proc_table[i].p_uticks;
+       entry->hrSWRunPerfCPU += proc_table[i].p_sticks;
+       entry->hrSWRunPerfCPU += proc_table[i].p_iticks;
        entry->hrSWRunPerfMem  = proc_table[i].kp_vm_map_size / 1024;

 #else
         /*
          * early FreeBSD, NetBSD, OpenBSD
          */
-        entry->hrSWRunPerfCPU  = proc_table[i].kp_proc.p_uticks;
-        entry->hrSWRunPerfCPU += proc_table[i].kp_proc.p_sticks;
-        entry->hrSWRunPerfCPU += proc_table[i].kp_proc.p_iticks;
-        entry->hrSWRunPerfMem  = proc_table[i].kp_eproc.e_vm.vm_tsize;
-        entry->hrSWRunPerfMem += proc_table[i].kp_eproc.e_vm.vm_ssize;
-        entry->hrSWRunPerfMem += proc_table[i].kp_eproc.e_vm.vm_dsize;
+        entry->hrSWRunPerfCPU  = proc_table[i].p_uticks;
+        entry->hrSWRunPerfCPU += proc_table[i].p_sticks;
+        entry->hrSWRunPerfCPU += proc_table[i].p_iticks;
+        struct vmspace *l = proc_table[i].p_vmspace;
+        entry->hrSWRunPerfMem  = l->vm_tsize;
+        entry->hrSWRunPerfMem += l->vm_ssize;
+        entry->hrSWRunPerfMem += l->vm_dsize;
         entry->hrSWRunPerfMem *= (getpagesize() / 1024);
 #endif
     }

of course this diff sucks like the vacuum , and i will improve it tommorow ;)

1
  • can you mark the question as solved?
    – ramrunner
    Sep 5, 2012 at 10:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.