View Full Version : Linux available memory calculation
I modified the agent code for Linux to add a "vm.memory.size[available]" key, which is (free + cache + buffer). This is the amount of memory that will be available if processes need it. Alternatively, a similar calculation of (used - cache - buffer) would yield the amount of memory actually being used by the OS and processes to run, which is what I graph in MRTG. I find both measures to be more generally useful than the standard "free" and "used" values, and I can't define an item that calculates either one because the field isn't long enough.
The patch has had minimal testing, but Zabbix appears to return the correct data on my test system (RHEL4).
Almost forgot, the patch is against 1.1beta7.
mdasilva
28-03-2006, 23:31
excellent patch.
how about getting a patch for timed averages for interfaces?
net.if.in[eth0,avg15]
;)
Nice idea for a patch. I solved this particular problem with a couple of UserParameters:
mem.available,free | grep buffers\/cache | cut --delimiter=' ' -f12
mem.used,free | grep buffers\/cache | cut --delimiter=' ' -f7
Of course, this has such general usage, that it's a pain to setup. I put these on every one of our servers.
Sure would be nice if it were possible to create UserParameters server-side and put them into Templates.
hi guys,
is there a particular reason why this patch has not been added
to CVS yet?
Lunarnexus
05-11-2007, 17:19
So, here's the patch for v1.1, but I don't see this code in the source for 1.4.2-2. Did this patch ever get integrated into the code base?
Right now, I'm using a UserParameter in zabbix_agentd.conf
UserParameter=up.vm.memory.inactive,grep Inactive: /proc/meminfo | perl -p -e "s/\s+/ /g" | cut -f2 -d " "
But, as you can see it opens at least 2 shells to get the job done, hence isn't very efficient.
Yes, the patch will be integrated into ZABBIX soon.
I think the 1.4 packages created by Debian and Ubuntu include an updated version of the patch.
I included support of 'available' memory into ZABBIX code.
cronosii
30-11-2007, 01:18
Hi
I'm seeing something very weird:
Host-A# md5sum /opt/zabbix/sbin/zabbix_agent
36dfffaea515b996fac59590c1155a7a /opt/zabbix/sbin/zabbix_agent
Host-A# /etc/init.d/zabbix-agent stop
Stopping Zabbix agent daemon: zabbix_agentd
Host-A# ps aux | grep zabbix_agent | grep -v grep | wc -l
0
Host-A# /etc/init.d/zabbix-agent start
Starting Zabbix agent daemon: zabbix_agentd
Host-A# ps aux | grep zabbix_agent | grep -v grep | wc -l
4
Host-A# telnet localhost 10050
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
vm.memory.size[available]
ZBXD 184832000Connection closed by foreign host.
Host-A#
Host-B# md5sum /opt/zabbix/sbin/zabbix_agent
36dfffaea515b996fac59590c1155a7a /opt/zabbix/sbin/zabbix_agent
Host-B# /etc/init.d/zabbix-agent stop
Stopping Zabbix agent daemon: zabbix_agentd
Host-B# ps aux | grep zabbix_agent | grep -v grep | wc -l
0
Host-B# /etc/init.d/zabbix-agent start
Starting Zabbix agent daemon: zabbix_agentd
Host-B# ps aux | grep zabbix_agent | grep -v grep | wc -l
6
Host-B# telnet localhost 10050
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
vm.memory.size[available]
ZBXDZBX_NOTSUPPORTEDConnection closed by foreign host.
Host-B#
Even though is the same agent, available works on A but not on B. I built the agent in A. Why can this be happening?
This happens both built as shared or static
Thanks
cronosii
30-11-2007, 02:27
Ok, I found it... I was looking at /opt/zabbix/sbin/zabbix_agent instead of /opt/zabbix/sbin/zabbix_agentd... man, this took me a lot of time, the clue came when I launched gdb and the lines didn't match...
jroberson
09-03-2009, 22:08
Just came across this thread and noticed that vm.memory.size[available] isn't documented in the Zabbix Manual, but it does still seem to exists as I can create an item and get data from it. :)
I guess the vm.memory.size[used] was never implemented as I get an "unsupported" message.:(