[ZBX-4658] Solaris 10 SPARC 64-bit, zabbix agent, boottime/uptime kstat return type mismatch Created: 2012 Feb 15  Updated: 2017 May 30  Resolved: 2013 Oct 04

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 1.8.10
Fix Version/s: 1.8.19rc1, 2.0.10rc1, 2.1.8

Type: Incident report Priority: Minor
Reporter: Janne Korkkula Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: agent, items, solaris
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Zabbix agent 1.8.10 compiled as a 64-bit binary on SPARC Solaris 10, with Sun C 5.11 SunOS_sparc 145354-05 2011/09/13 (Studio 12.2).
Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC, Generic_147440-05 sun4v


Issue Links:
Duplicate
is duplicated by ZBX-6988 Release 2.0.8: Solaris 10/SPARC syste... Closed

 Description   

src/libs/zbxsysinfo/solaris/boottime.c and uptime.c do not check the kstat return value type and assume an unsigned long, when the correct type is ui32. This results in system.boottime and system.uptime returning insane values.

If kn->value.ul is changed to kn->value.ui32, everything works just fine.



 Comments   
Comment by Aleksandrs Saveljevs [ 2013 Oct 03 ]

The problem seems to manifest depending on whether the agent is compiled as a 32-bit or a 64-bit binary:

$ CFLAGS="$CFLAGS -m32" ./configure --enable-agent ...
...
$ src/zabbix_agent/zabbix_agentd -t system.boottime
system.boottime                               [u|1372661428]
$ src/zabbix_agent/zabbix_agentd -t system.uptime
system.uptime                                 [u|8132082]

$ CFLAGS="$CFLAGS -m64" ./configure --enable-agent ...
...
$ src/zabbix_agent/zabbix_agentd -t system.boottime
system.boottime                               [u|5895535941740658688]
$ src/zabbix_agent/zabbix_agentd -t system.uptime
system.uptime                                 [u|12551208133349686272]

The bug seems to have been there since the very beginning in 2005 (see r2198). Although what ZBX-6988 is concerned, it only started to manifest on a regular basis after r37064:

$ svn log ^/ -c 37064
------------------------------------------------------------------------
r37064 | igors | 2013-07-17 14:25:07 +0300 (Wed, 17 Jul 2013) | 2 lines

....I..... [ZBX-6637] added -m64 compilation flag for solaris to be able to understand all attributes of 64-bit processes

------------------------------------------------------------------------
Comment by Aleksandrs Saveljevs [ 2013 Oct 04 ]

Fixed in development branches:

  • svn://svn.zabbix.com/branches/dev/ZBX-4658 (for 1.8)
  • svn://svn.zabbix.com/branches/dev/ZBX-4658-2.0 (for 2.0 and trunk)

Structure kstat_named_t has a member data_type (see http://www.manpages.spotlynx.com/solaris/man/kstat.3KSTAT), which describes the data type of the stored value. So it was decided to create a function, get_kstat_numeric_value(), which would return the value through the appropriate member of the union. Previously access to the union's value was hardcoded: not just for system.boottime and system.uptime, but in other places, too.

Comment by Andris Mednis [ 2013 Oct 10 ]

Branches 1.8 and 2.0 successfully tested.
Illumos source code was used for solution code review.
You can search Illumos source code online at http://src.illumos.org/source/s?path=usr/src&project=illumos-gate.
If you want to download all Illumos source follow instructions at http://wiki.illumos.org/display/illumos/How+To+Build+illumos.

Comment by Aleksandrs Saveljevs [ 2013 Oct 11 ]

Fixed in pre-1.8.19 r39228, pre-2.0.10 r39230 and pre-2.1.8 (trunk) r39231.

Generated at Thu Apr 25 14:25:35 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.