Date: Sun, 25 Sep 2005 22:42:08 -0400 (EDT) From: wollman@csail.mit.edu To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/86572: net-snmp doesn't know how to fill in hrSWRunType Message-ID: <200509260242.j8Q2g8p6088099@wollman-random-testing.csail.mit.edu> Resent-Message-ID: <200509260250.j8Q2oFXb058236@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 86572 >Category: ports >Synopsis: net-snmp doesn't know how to fill in hrSWRunType >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Sep 26 02:50:15 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Garrett Wollman >Release: FreeBSD 6.0-BETA5 i386 >Organization: MIT CSAIL >Environment: System: FreeBSD wollman-random-testing.csail.mit.edu 6.0-BETA5 FreeBSD 6.0-BETA5 #0: Fri Sep 23 13:22:35 EDT 2005 root@wollman-random-testing.csail.mit.edu:/usr/obj/usr/src/sys/XYZ i386 >Description: hrSWRunType is an enumeration, which can be unknown (1), operatingSystem (2), deviceDriver (3), or application (4). Right now, net-snmp fills in every process as "application", which is clearly wrong. It should probably be saying "unknown". The enclosed patch gets the correct values; it is a replacement for files/patch-hr_swrun.c in the port. It has also been submitted to the net-snmp project as patch #1304400. I have arbitrarily decided that ithreads should map to deviceDriver and all other system processes should map to operatingSystem. >How-To-Repeat: snmpget hrSWRunType.0 >Fix: --- ../../work.orig/net-snmp-5.2.1.2/agent/mibgroup/host/hr_swrun.c Tue Jun 8 16:56:03 2004 +++ agent/mibgroup/host/hr_swrun.c Sun Sep 25 22:02:35 2005 @@ -585,7 +585,7 @@ string[ sizeof(string)-1 ] = 0; #endif #elif HAVE_KVM_GETPROCS - #if defined(freebsd5) + #if defined(freebsd5) && __FreeBSD_version >= 500014 strcpy(string, proc_table[LowProcIndex].ki_comm); #else strcpy(string, proc_table[LowProcIndex].kp_proc.p_comm); @@ -694,7 +694,7 @@ *cp1 = 0; #endif #elif HAVE_KVM_GETPROCS - #if defined(freebsd5) + #if defined(freebsd5) && __FreeBSD_version >= 500014 strcpy(string, proc_table[LowProcIndex].ki_comm); #else strcpy(string, proc_table[LowProcIndex].kp_proc.p_comm); @@ -857,8 +857,25 @@ if (pid < PID_MAXSYS) long_return = 2; /* operatingSystem */ else -#endif long_return = 4; /* application */ +#elif HAVE_KVM_GETPROCS + #if defined(freebsd5) && __FreeBSD_version >= 500014 + if (proc_table[LowProcIndex].ki_flag & P_SYSTEM) { + if (proc_table[LowProcIndex].ki_pri.pri_class == PRI_ITHD) + long_return = 3;/* deviceDriver */ + else + long_return = 2;/* operatingSystem */ + } else + long_return = 4; /* application */ + #else + if (proc_table[LowProcIndex].kp_proc.p_flag & P_SYSTEM) + long_return = 2; /* operatingSystem */ + else + long_return = 4; /* application */ + #endif +#else + long_return = 4; /* application */ +#endif return (u_char *) & long_return; case HRSWRUN_STATUS: #if defined(cygwin) @@ -889,7 +906,7 @@ } #else #if HAVE_KVM_GETPROCS - #if defined(freebsd5) + #if defined(freebsd5) && __FreeBSD_version >= 500014 switch (proc_table[LowProcIndex].ki_stat) { #else switch (proc_table[LowProcIndex].kp_proc.p_stat) { @@ -988,7 +1005,13 @@ long_return = proc_buf->p_utime * 100 + proc_buf->p_stime * 100; #endif #elif HAVE_KVM_GETPROCS - #if defined(freebsd5) + #if defined(freebsd5) && __FreeBSD_version >= 500014 + /* XXX: Accessing ki_paddr causes sig10 ... + long_return = proc_table[LowProcIndex].ki_paddr->p_uticks + + proc_table[LowProcIndex].ki_paddr->p_sticks + + proc_table[LowProcIndex].ki_paddr->p_iticks; */ + long_return = 0; + #elif defined(freebsd5) long_return = proc_table[LowProcIndex].ki_runtime / 100000; #else long_return = proc_table[LowProcIndex].kp_proc.p_uticks + @@ -1063,7 +1086,14 @@ long_return = proc_buf->p_swrss; #endif #elif HAVE_KVM_GETPROCS -#if defined(freebsd3) && !defined(darwin) +#if defined(freebsd5) && __FreeBSD_version >= 500014 + /* XXX + long_return = proc_table[LowProcIndex].ki_vmspace->vm_tsize + + proc_table[LowProcIndex].ki_vmspace->vm_ssize + + proc_table[LowProcIndex].ki_vmspace->vm_dsize; + long_return = long_return * (getpagesize() / 1024); */ + long_return = 0; +#elif defined(freebsd3) && !defined(darwin) long_return = #if defined(freebsd5) proc_table[LowProcIndex].ki_size / 1024; @@ -1349,7 +1379,7 @@ #elif defined(solaris2) return proc_table[current_proc_entry++]; #elif HAVE_KVM_GETPROCS - #if defined(freebsd5) + #if defined(freebsd5) && __FreeBSD_version >= 500014 if (proc_table[current_proc_entry].ki_stat != 0) return proc_table[current_proc_entry++].ki_pid; #else >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509260242.j8Q2g8p6088099>