[ZBX-5273] Frontend does not allow to edit hosts Created: 2012 Jul 05  Updated: 2017 May 30  Resolved: 2012 Jul 11

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.0.1
Fix Version/s: 2.0.2rc1, 2.1.0

Type: Incident report Priority: Major
Reporter: Aristarkh Zagorodnikov Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: hostinterfaces, hosts, sqlite
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

IE 9, Firefox 13


Attachments: PNG File zabbix-1.png    

 Description   

This is entirely a client-side problem. When you attempt to edit an existing host, the "Unknown host interface type." is thrown. This is due to getDomIdForRowInsert function (include/views/js/configuration.host.edit.js.php) being passed an integer instead of a string (this happens on initial form load only when editing existing host, because interface table is populated with numbers, and not their string representations), which leads to switch-based compare to a string representation of host interface numeric type (a result of getHostInterfaceNumericType function call).
A quick fix is forcing hostInterfaceType to be a string (I just concatenate it with an empty string): switch (hostInterfaceType + '').
A proper solution would be either populating the initial object with string representations of numeric interface types (seems easy) or moving to numeric representations everywhere (seems unnecessarily hard and prone to errors).



 Comments   
Comment by Pavels Jelisejevs (Inactive) [ 2012 Jul 05 ]

I cannot reproduce this problem. Does it happen with all of the hosts, or only some of them?

Comment by Aristarkh Zagorodnikov [ 2012 Jul 05 ]

Clean installation from sources (2.0.1 from official site).
./configure --with-sqlite3 --with-openipmi --with-net-snmp --with-ssh2 --with-libcurl --enable-server --prefix=/opt/zabbix && make install
mkdir -p /var/lib/zabbix
sqlite3 /var/lib/zabbix/zabbix.db < /opt/zabbix/share/zabbix/sqlite3/schema.sql
sqlite3 /var/lib/zabbix/zabbix.db < /opt/zabbix/share/zabbix/sqlite3/images.sql
sqlite3 /var/lib/zabbix/zabbix.db < /opt/zabbix/share/zabbix/sqlite3/data.sql
chown -R zabbix:zabbix /var/lib/zabbix

Skipping configuration of server itself, zabbix frontend and Apache.

Now operating on empty default database.
Going in web browser to Configuration->Hosts and then selecting the preexisting "Zabbix server" host – see screenshot zabbix-1.png.

Comment by Aristarkh Zagorodnikov [ 2012 Jul 05 ]

I would like to note JavaScript switches do not behave as equality operators.
While the value of expression (1 == '1') is true, the value of (function() { switch (1) { case '1': return true; default: return false; }}()) is false.

Comment by Aristarkh Zagorodnikov [ 2012 Jul 05 ]

It also occured to me that this might be the sqlite-specific problem – it may be that hostInterfaceType is string in all other drivers, but a number when read from sqlite.

The callstack is as follows:
getDomIdForRowInsert
renderHostInterfaceRow
add
Anonymous Function
...

The anonymous function (that actually populates hosts) contains the following data:
hostInterfacesManager.add({"2":{"items":0,"interfaceid":2,"hostid":10085,"main":1,"type":1,"useip":1,"ip":"10.3.253.10","dns":"","port":"10050","locked":0}});

Here the "type" field is a number 1, not string "1". I believe that here lies the problem.

Comment by Pavels Jelisejevs (Inactive) [ 2012 Jul 10 ]

Thank you for the information. It is indeed an SQLite specific problem.

Comment by Pavels Jelisejevs (Inactive) [ 2012 Jul 10 ]

RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-5273.

Comment by Toms (Inactive) [ 2012 Jul 10 ]

(1) typo - unset($value) instead of unset($values);

<pavels> RESOLVED.

<Toms> CLOSED

Comment by Toms (Inactive) [ 2012 Jul 11 ]

TESTED

Comment by Pavels Jelisejevs (Inactive) [ 2012 Jul 13 ]

Fixed in 2.0.2rc1 r28839 and 2.1.0 r28840.

CLOSED.

Generated at Fri Apr 19 19:16:04 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.