xymon freebsd memory calculations
Hi people,
I was just trying to track down why the memory used was showing 0% on my FreeBSD systems and have found an interesting bug.
The logic in xymond/client/freebsd.c is a little funny with fall back positions depending on what is supplied from the client, but essentially if there is no vmtotal section in the client data (old client) then the figure is used from meminfo which has been pretty good (but perhaps not perfect). If there is a section Free Memory Pages in the vmtoal section then that number is used in preference.
Problems:
The number is in K bytes so must be adjusted for use.
The offset to the end of the searched for string is 19 not 18 (must count the leading newline).
We arent calculating memphyused if we use the vmtotal method.
The string Free Memory Pages: changes to Free Memory: with revision 234134 by eadler, Wed Apr 11 14:18:18 2012 UTC to /head/sbin/sysctl/sysctl.c (http://svnweb.freebsd.org/base/head/sbin/sysctl/sysctl.c?r1=234133&r2=234134...).
My suggested fix is to change the logic at line 82 onwards in xymond/client/freebsd.c to read as follows:
if (vmtotalstr) { p = strstr(vmtotalstr, "\nFree Memory Pages:"); if (p) { memphysfree = atol(p + 19)/1024; memphysused = memphystotal - memphysfree; found++; } else { p = strstr(vmtotalstr, "\nFree Memory:"); if (p) { memphysfree = atol(p + 13)/1024; memphysused = memphystotal - memphysfree; found++; } } }
Regards,
Brian Scott
P.S. I have CCd the FreeBSD port maintainer for xymon but offcourse this fix is needed on any server if any monitored client is running FreeBSD.
Brian Scott <Brian.Scott at ...> writes:
Hi people,
I was just trying to track down why the memory used was showing 0% on my FreeBSD systems and have found an interesting bug.
The logic in xymond/client/freebsd.c is a little funny with fall back positions depending on what is supplied from the client, but essentially if there is no vmtotal section in the client data (old client) then the figure is used from meminfo which has been pretty good (but perhaps not perfect). If there is a section Free Memory Pages in the vmtoal section then that number is used in preference.
I was unable to get your patch to work on my freebsd machines, I found it easier to simply comment out the vm lines in the xymonclient-freebsd.sh file and my memory functions came back to life.
/www/xymon/client/bin/xymonclient-freebsd.sh #echo "[vmtotal]" #sysctl vm.vmtotal
I use a mofified freebsd-meminfo taken from Ralf S. Engelschall freebsd-memory perl script.
I can provide the script as needed just email me.
This is a good work around because of the fall back. The same will happen if you update your FreeBSD system to 9-STABLE because of the message text change.
The only reason to use the vm.total sysctl is that it will be a more accurate measure (5 second average rather than point in time snapshot). This only matters if memory is very tight on your system (as they are on one of mine).
-----Original Message----- From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Kris Persson Sent: Saturday, 5 May 2012 5:31 AM To: xymon at xymon.com Subject: Re: [Xymon] xymon freebsd memory calculations
Brian Scott <Brian.Scott at ...> writes:
Hi people,
I was just trying to track down why the memory used was showing 0% on my FreeBSD systems and have found an interesting bug.
The logic in xymond/client/freebsd.c is a little funny with fall back positions depending on what is supplied from the client, but essentially if there is no vmtotal section in the client data (old client) then the figure is used from meminfo which has been pretty good (but perhaps not perfect). If there is a section Free Memory Pages in the vmtoal section then that number is used in preference.
I was unable to get your patch to work on my freebsd machines, I found it easier to simply comment out the vm lines in the xymonclient-freebsd.sh file and my memory functions came back to life.
/www/xymon/client/bin/xymonclient-freebsd.sh #echo "[vmtotal]" #sysctl vm.vmtotal
I use a mofified freebsd-meminfo taken from Ralf S. Engelschall freebsd-memory perl script.
I can provide the script as needed just email me.
This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender.
participants (3)
-
brian.scott4@det.nsw.edu.au
-
Brian.Scott@tafensw.edu.au
-
kpersson@clarkebroadcasting.com