Hi,

Sorry for creating a new thread, it could be argued that this should belong 
under my previous
thread. It is related, but is also a different query. My home machine pops off 
my mail (due to some
mail probs) and I don't have access to the thread here in the office.

I posted the following patch to the users list (it was intended for the coders 
list). It solves the
behaviour of collecting the used memory of 64 bit applications when the agent 
is compiled as 32 bit
binary.

>>>>>>>START PATCH
--- hr_swrun_old.c      2008-12-05 09:49:08.760274490 +0100
+++ hr_swrun.c  2008-12-08 10:53:11.578470205 +0100
@@ -84,6 +84,11 @@
  #include <net-snmp/agent/auto_nlist.h>
  #include "kernel.h"
  #ifdef solaris2
+#if _SLASH_PROC_METHOD_ && defined _ILP32
+#include <net-snmp/agent/cache_handler.h>
+#include <net-snmp/agent/hardware/memory.h>
+#endif
+
  #include "kernel_sunos5.h"
  #endif
  #if defined(aix4) || defined(aix5) || defined(aix6)
@@ -1151,7 +1156,30 @@
          long_return = (lowpsinfo.pr_rssize * MMU_PAGESIZE) / 1024;
  #elif defined(solaris2)
  #if _SLASH_PROC_METHOD_
+#ifdef _ILP32
+        if(0 == proc_buf->pr_rssize)
+        { /* Odds on that we are looking with a 32 bit app at a 64 bit 
psinfo.*/
+            netsnmp_memory_info *mem;
+            mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_PHYSMEM, 0 );
+            if (!mem)
+            {
+                long_return = 0;/* Tried my best, giving up.*/
+            }
+            else
+            {/* 0x8000 is the maximum range of pr_pctmem. devision of 1024 is 
to go from B to kB*/
+                uint32_t pct_unit = (mem->size/0x8000) * (mem->units/1024);
+                long_return = proc_buf ? proc_buf->pr_pctmem * pct_unit : 0;
+            }
+        }
+        else
+        {
+            long_return = proc_buf ? proc_buf->pr_rssize : 0;
+
+        }
+#else /*_LP64*/
          long_return = proc_buf ? proc_buf->pr_rssize : 0;
+#endif /*_LP64*/
+
  #else
          long_return = proc_buf->p_swrss;
  #endif
>>>>>>>END PATCH

The problem is that for the sparc,
+            mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_PHYSMEM, 0 );
gives correct values, but for the amd/intel machines it gives 0 values

for the sparc,
+            mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_PHYSMEM, 1 );
returns zero values and returns correct values for amd/intel

I can add an #ifdef _sparc, but solving the problem might require a more 
fundamental change. Is
there someone that can give me advice on how to use this function correctly?

Best regards,

Frans Grotepass


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to