[ZBX-3897] proc.num show incorrect data under FreeBSD Created: 2011 Jun 19  Updated: 2017 May 30  Resolved: 2012 May 09

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 1.8.5
Fix Version/s: 1.8.14rc1, 2.0.1rc1, 2.1.0

Type: Incident report Priority: Major
Reporter: gescheit Assignee: Unassigned
Resolution: Fixed Votes: 4
Labels: freebsd
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

FreeBSD


Attachments: Text File proc.c+vsz.patch     Text File proc.c.patch    
Issue Links:
Duplicate
is duplicated by ZBX-4704 proc.num shows threads under FreeBSD Closed

 Description   

proc.num show incorrect data under FreeBSD. Example:

ps ax|wc -l
59

zabbix_agentd -t proc.num[]
proc.num[] [u|127]



 Comments   
Comment by Oleksii Zagorskyi [ 2011 Jun 19 ]

Several users can confirm the same: http://www.zabbix.com/forum/showthread.php?t=22322
I'm too.

Comment by Alexander Vladishev [ 2011 Jun 20 ]

Confirmed in version pre1.8.6, r20279.

Comment by Ya Bo [ 2012 Feb 11 ]

FreeBSD 9.0, zabbix-agent-1.8.10,2

zabbix-1.8.10/src/libs/zbxsysinfo/freebsd/proc.c
#if(__FreeBSD_version > 500000)
if (proc[i].ki_flag & P_KTHREAD) /* skip a system thread */
continue;
#endif

не работает, в результате имеем +системные треды

Comment by Oleksii Zagorskyi [ 2012 Feb 28 ]

related issue ZBX-4704

Comment by Jim Riggs [ 2012 Mar 28 ]

Please try the attached patch. It correctly calls sysctl() for proc.num and proc.mem with KERN_PROC_PROC instead of KERN_PROC_ALL for FreeBSD 5 and later. (Is this check really necessary anymore? Is < v5 supported?)

This has fixed the issue in my environment.

Comment by Ya Bo [ 2012 Mar 29 ]

FreeBSD 8.3-PRERELEASE
zabbix-agent-1.8.10_1,2

confirm, patch is good

Comment by Pavel Timofeev [ 2012 Mar 29 ]

thanks to Jim! proc.num work on FreeBSD 9.0-RELEASE amd64.

But I can't decide about proc.mem. Which unit does proc.mem return? Kbytes, bytes, etc.? Documentation didn't help=(

Comment by richlv [ 2012 Mar 30 ]

regarding documentation, could you please open another issue (documentation component) ?
thanks

Comment by Pavel Timofeev [ 2012 Apr 03 ]

2 richlv: https://support.zabbix.com/browse/ZBX-4831

Comment by Pavel Timofeev [ 2012 Apr 03 ]

Jim, does proc.mem work for you?

Comment by Pavel Timofeev [ 2012 Apr 03 ]

Jim's patch applied
[root@octans ]# ps -axo vsz,rss,command | grep syslogd
12184 1340 /usr/sbin/syslogd -s
[root@octans ]# zabbix_get -s octans -I 192.168.2.6 -k 'proc.mem[syslogd]'
2232320

2232320 Bytes = 2180 KBytes but != 12184 KBytes or 1340 KBytes returned by ps

Comment by Jim Riggs [ 2012 Apr 25 ]

The "memory usage" of a process is a controversial and subjective topic. There are many different views about what actually constitutes a proc's memory usage.

Currently, the zabbix code is using text size + data size + stack size for proc.mem (ki_tsize + ki_dsize + ki_ssize), whereas `top' and `ps' display resident size (ki_rssize) and VM size (ki_size). This is why the values from zabbix vs. top and ps are different. I would think that to eliminate confusion and to make the zabbix value more "verifiable," we should probably switch to using ki_rssize.

Thoughts? What are other OSes doing? I haven't dug into the linux code, for example.

Comment by richlv [ 2012 Apr 26 ]

i suppose we will want to match some value(s) from standard tools like ps if only to reduce the confusion - as noted, there is no definite "used memory" value, it's all quite relative.

Comment by Jim Riggs [ 2012 Apr 26 ]

Attached is proc.c+rss.patch which includes the original patch plus a switch to using the resident size for proc.mem as discussed. This works for me in FreeBSD 8 and 9 for single and multiple processes.

It would be nice to get these issues fixed sooner rather than later, if possible. The proc.num issue, specifically, has been causing problems for quite some time.

Comment by Jim Riggs [ 2012 Apr 26 ]

I guess the question still remains, is resident size what people expect from proc.mem or VM size? Resident is closer to what the value was before, but VM size might give a better picture of actual memory footprint.

Hrm. Looking at the Linux agent, it is pulling the VM size (vsz). We should probably match. New patch coming...

Comment by Jim Riggs [ 2012 Apr 26 ]

OK, proc.c+vsz.patch should be good to go. Original patch to fix proc.num + vsize patch to "fix" proc.mem on FreeBSD. Tested on FreeBSD 8 and 9.

Comment by Oleksii Zagorskyi [ 2012 Apr 26 ]

Jim, I'm sorry, it's not related to proc.mem, but do you know about changes for agent 2.0 ?
http://blog.zabbix.com/when-alexei-isnt-looking/#vm.memory.size implemented here: ZBXNEXT-1024
Would be good to follow latest ideology

I think would be better to not mix here discussion about proc.num and proc.mem

Also see ZBXNEXT-1078 and ZBX-4532

Comment by Pavel Timofeev [ 2012 Apr 26 ]

Oleksiy Zagorskyi, ZBXNEXT-1024 is not relative feature/fix. ZBXNEXT-1024 is on a different plane.

Comment by Pavel Timofeev [ 2012 Apr 26 ]

> Jim Riggs added a comment - 2012 Apr 26 07:07
> OK, proc.c+vsz.patch should be good to go. Original patch to fix proc.num + vsize patch to "fix" proc.mem on FreeBSD. Tested on FreeBSD 8 and 9.

Excellent, Jim! Patch works fine on FreeBSD 9-RELEASE amd64. I hope this patch will be included in the nearest release.

Comment by Alexander Vladishev [ 2012 May 09 ]

Fixed in the development branch svn://svn.zabbix.com/branches/dev/ZBX-3897

Fixed incorrect processing of proc.num[] item.
proc.mem[] item will be fixed later under ZBXNEXT-1078 or ZBX-4532.

Comment by dimir [ 2012 May 14 ]

I wonder why do I get less processes with zabbix get on FreeBSD 7.3. I tried 1.8.5, latest 1.8 with and without the fix:

$ uname -a
FreeBSD freebsd73.zabbix.com 7.3-RELEASE FreeBSD 7.3-RELEASE #0: Sun Mar 21 06:15:01 UTC 2010 [email protected]:/usr/obj/usr/src/sys/GENERIC i386

$ ps ax|wc -l
81

$ bin/zabbix_get -s 127.0.0.1 -k agent.version
1.8.5
$ bin/zabbix_get -s 127.0.0.1 -k proc.num[]
39

$ bin/zabbix_get -s 127.0.0.1 -k agent.version
1.8.13rc1

  1. without the fix
    $ bin/zabbix_get -s 127.0.0.1 -k proc.num[]
    39
  2. with the fix
    $ bin/zabbix_get -s 127.0.0.1 -k proc.num[]
    39
Comment by dimir [ 2012 May 14 ]

It appeared to be a problem on my side, please ignore the comment above.

Comment by dimir [ 2012 May 14 ]

Successfully tested, now the number of processes is reported properly.

Comment by Alexander Vladishev [ 2012 May 15 ]

Fixed in versions pre-1.8.14 r27534, pre-2.0.1 r27689, pre-2.1.0 (beta) r27694

Generated at Fri Apr 19 08:32:17 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.