-Coders,
this patch fixes the new mem HAL code for IRIX to report figures that actually
make sense and match those reported by the "top" utility.
As memory figures are among the ones most often monitored, reporting bad values
really sucks, IMHO, so please consider voting for inclusion in 5.4.
The patch will only affect IRIX by nature, cannot cause regression over 5.3.x
(memory values are reported as all zeros for IRIX by 5.3.x) and has been tested
successfully on my IRIX 6.5.x test machine. It now reports:
UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 131072
UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 131072
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 393216
UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 354064
UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 464720
while top says:
Memory: 384M max, 346M avail, 276M free, 128M swap, 128M free swap
Cheers,
Thomas
--
Thomas Anders (thomas.anders at blue-cable.de)
Index: agent/mibgroup/hardware/memory/memory_irix.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/hardware/memory/memory_irix.c,v
retrieving revision 1.2
diff -u -r1.2 memory_irix.c
--- agent/mibgroup/hardware/memory/memory_irix.c 18 Sep 2006 14:19:22 -0000 1.2
+++ agent/mibgroup/hardware/memory/memory_irix.c 27 Oct 2006 23:44:02 -0000
@@ -3,6 +3,10 @@
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/agent/hardware/memory.h>
+#if HAVE_SYS_SWAP_H
+#include <sys/swap.h>
+#endif
+
#if HAVE_SYS_SYSGET_H
#include <sys/sysget.h>
#endif
@@ -19,6 +23,7 @@
netsnmp_memory_info *mem;
struct rminfo meminfo; /* struct for getting memory info, see sys/sysmp.h */
int pagesz, rminfosz;
+ off_t swaptotal, swapfree;
/*
* Retrieve the memory information from the underlying O/S...
@@ -32,6 +37,8 @@
snmp_log(LOG_ERR, "memory_irix: sysmp failed!\n");
return -1;
}
+ swapctl(SC_GETSWAPTOT, &swaptotal);
+ swapctl(SC_GETFREESWAP, &swapfree);
/*
* ... and save this in a standard form.
@@ -55,8 +62,8 @@
} else {
if (!mem->descr)
mem->descr = strdup("Virtual memory");
- mem->units = pagesz;
- mem->size = meminfo.availsmem + (meminfo.physmem - meminfo.availrmem);
+ mem->units = pagesz; /* swaptotal is in blocks, so adjust below */
+ mem->size = meminfo.physmem + (swaptotal*512/pagesz);
mem->free = meminfo.availsmem;
mem->other = -1;
DEBUGMSGTL(("hardware/memory/memory_irix", "Virtual memory: size %u, free %u\n", mem->size, mem->free));
@@ -68,10 +75,11 @@
} else {
if (!mem->descr)
mem->descr = strdup("Swap space");
- mem->units = pagesz;
- mem->size = meminfo.availsmem - meminfo.availrmem;
- mem->free = meminfo.availsmem - meminfo.availrmem;
+ mem->units = 1024;
+ mem->size = swaptotal/2; /* blocks to KB */
+ mem->free = swapfree/2; /* blocks to KB */
mem->other = -1;
+ DEBUGMSGTL(("hardware/memory/memory_irix", "Swap: size %u, free %u\n", mem->size, mem->free));
}
return 0;
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders