[ZBXNEXT-928] "Template with application xxx already linked to host" Created: 2010 Aug 09  Updated: 2014 Jan 13  Resolved: 2013 Jun 04

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F), Server (S)
Affects Version/s: None
Fix Version/s: 2.1.0

Type: Change Request Priority: Major
Reporter: Bart Verwilst Assignee: Pavels Jelisejevs (Inactive)
Resolution: Fixed Votes: 58
Labels: applications, templates
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File zabbix-1.8.4-web-app.patch    
Issue Links:
Duplicate
is duplicated by ZBXNEXT-1370 Global level applications Closed
is duplicated by ZBXNEXT-1042 insufficient info in log: Can not lin... Closed
is duplicated by ZBX-6543 Template with application "xxxx" alre... Closed
is duplicated by ZBX-3444 Allow same application in several tem... Closed

 Description   

I have Template_A which has an application 'XXX' linked to a host. When I want to add Template_B, which also has an application 'XXX', i get the above error.. Multiple templates should be able to add their items in the same application, right? This worked in 1.6.x just fine..



 Comments   
Comment by Mischa Bachmann [ 2010 Aug 24 ]

This is something that should be allowed. In 1.8.2 there was a work around with commenting out some code in the host.inc.php file. Since 1.8.3 there seems to be a second check after linking the templates, when trying to save the host which gets me stuck.

I don't understand why this isn't' allowed? How should we be working with templates and applications?

This problem occurs in the final release of 1.8.3. I've read the post about it being implemented in 2.0 but that could take months when not years to be released and at the moment we can't use our entire Zabbix configuration any more which is based on linking templates to hosts and those templates share the same application name.

Comment by richlv [ 2010 Aug 24 ]

it is quite unfortunate, but allowing to link multiple templates with same application to same entity would break inheritance - how would you know which template the application comes from ?

so it should be redesigned. when there's some time for that

Comment by Greg Swift [ 2010 Aug 25 ]

I just spent quite a bit of time trying to properly implement distributed templates that can be used for linking that contained applications. Tried this two ways, and both broke. Now we have to go back to no applications. Seems pointless to have Applications if they can't Inherit duplicates.

Maybe its just me, but I think that Applications should be removed from the template/host level, and just exist as their own. This way there is no such thing as conflicting. You just select the appropriate Application for the item for the full list.

Comment by James Tiner [ 2010 Aug 25 ]

Greg's solution sounds reasonable and appropriate to me. The ability to have and manage applications globally and separately from the templates would be very nice and much easier to manage.

Comment by Walter Heck [ 2010 Oct 18 ]

Agreeing with Greg and James. Applications in their current form are useless, we end up having all our items without application because it just doesn't work properly in larger environments.

Comment by Edward Rudd [ 2011 Jan 05 ]

I have been running a custom patched version of zabbix frontend that allows duplicate applications (ie.. the commenting out of the check in hosts.inc.php) and now commenting out the block in api/classes/class.ctemplate.php. I've been doing this since this restriction was first added with no ill effects.. Though I don't have templates based on other templates.

With out the ability to have applications be re-used between templates it makes the application system useless. And in reply to richlv, why do I care which template the application came from? I only care where the item came from.

Applications should just be a global entity that items link to as I see no functionality in zabbix that make use of some special application to template binding to bring some kind of magic to my life.

Comment by Andy Shinn [ 2011 Feb 14 ]

I was running into this issue also and I think Greg's suggestion makes sense. I use applications as a sort of 'filter' for types of items and it would still make sense having them global.

Comment by Christian Lahti [ 2011 Mar 24 ]

Edward:

I do not intend to have inherited/distributed templates, so is there any instructions on which lines to comment out in hosts.inc.php and api/classes/class.ctemplate.php so I can add multiple templates to a host with matching Application names?

Thanks!

/Chris

Comment by Edward Rudd [ 2011 Mar 24 ]

Patch being applied to my local installations.

Comment by Eric Renfro [ 2011 Apr 11 ]

This patch definitely does not work as expected.

I tried to make a stacked template with an Application group "Services", removed from any other base OS/Distro base templates I had originally that other templates based off of. For example, I added a Services base template that all it did was add the Application called "Services", then I made a Service_SSH template that used the Services template, added in the SSH Item and Trigger. Also broke out the Zabix-Server template and ripped it out the same way so it was it's own template that used the Services sub-template, and tried to put them into a host, and no go. Refused it all completely.

Originally testing, I had the SSH service defined in my OS_Linux template under the Services application group and patched it, modified my Service_ZabbixServer template to define a "Services" application group and linked it to the template. What happened was, in the "Latest Data" view is it took SSH out of the "Services" application and put it into "- other -" which is basically the same as "None", but put ZabbixServer into the Services application group as expected otherwise.

I even tried testing with using the individual Service_SSH and Service_ZabbixServer defining the Services application, and still, failure IF it's linked to any hosts already. You have to unlink the templates first, do your changes, then re-link them back in and it works. There's still more checks going on. After this was done, everything was grouped together in the "Services" application group at the least. This is a good thing so far.

I agree with a lot of the people here though. "Applications" should be a global definition itself and not so much a per-template construct. Since the entire template construct itself is XML-based, melding them together if they DO define Applications should not be much of an issue in itself. I know PHP's XML functions are not always very simplistic or clean sometimes, but it's efficient enough to do stuff like this without too much hassle, massaging or what-not with the XML definition and utilizing information since this is all stored in a database in the end result anyway.

Comment by Edward Rudd [ 2011 Apr 11 ]

Eric,

I have found that sometimes zabbix will leave Old applications linked to a host, even after the template has been delinked.. You have to edit the applications direct on the host and remove the "Extra" ones and then try re-linking.

In my personal use I'm not using but one "stacked" template. Most of my templates just get linked directly to the host and DO repeat applications (like Processes, CPU, Disk) and those correctly merge with my patch. (which I've been using variations of that patch since zabbix 1.4?)..

I do hope that Zabbix does change the way applications are done, as the current way is extremely limited and provides no value in being limited this way. This and the Broken Jabber support (lack of doing DNS Service lookups, which I have provided a patch for.. for YEARS). are the only two things that frustrate me about zabbix. Maybe one day when I have free time I'll rework a proper patch for this issue that corrects the way applications are used.

Comment by Eric Renfro [ 2011 Apr 11 ]

Yeah, Edward. I noticed if I did it specific ways, applying the template, it did work, but you can't change it once it's linked. Have to delink and clear, edit, then re-link. There's another check being done somewhere during the editing you might want to look into for a patch revision.

You mentioned also the patch for Jabber? Is there a link for that because I could really use that myself. I had hacked in my own jabber CLI client last time I setup Zabbix and if there's a patch to fix the current one built-in to Zabbix that would be even better.

Comment by Eric Renfro [ 2011 Apr 11 ]

I did some analysis testing on the results of what happends when you use this patch and link templates with shared applications into it. So far consistancy-wise, it looks koshier too.

Each "Application" gets added per hostid, so there's some redundancy there for each host being added. This also seems to happen for every host with it's own set of applications as well. The default initial Zabbix Server host, and my second host I added afterwards, using my base template.

There is however a wierdness involved in the actual data. Not sure where it's specifically coming from. I have two hosts setup presently. Hostid 10001, and 10002 appear to be the Zabbix Server and the first host I added. I have another one, 10008, that I don't recognize as anything specific. That Hostid has Processes, Log Files, OS, Network, Performance, Services, but not any of the others that are common from my OS_Linux base template I've been using, which has Services, Filesystem, Network, Processes, Log files, CPU, Memory, Performance, Availability, General, and Integrity. Hostid 10002 lacks only Logfiles from that list.

Comment by Edward Rudd [ 2011 Apr 11 ]

The jabber patches are in issue ZBX-1029

Comment by Eric Renfro [ 2011 Apr 11 ]

Database analysis tests:

Zabbix itself is probably partially to blame for this as well, since I was looking at all the hostid's earlier, and they're not even in-use anymore apparently. There's been no cleanup at all. My hostid's are completely different.

Regardless though. I did a test. Added Service_SSH template which defines Service application, added Service_HTTP template after that. Checked the database for the hostid associated with that host, and found Services linked to the Service_SSH id number. Deleted Service_HTTP, database row remained. Deleted Service_SSH, row still remained.

Now, after this, I looked at the host's "Applications" template list, and saw it still had Service_SSH:Service as an Application, and it cannot be deleted due to and error: Cannot delete templated application

So there's other problems as well to take note of this specific issue. Along with why Zabbix itself isn't cleaning out old records of unassociated hostid's...

Comment by Wesley [ 2012 Jul 16 ]

I am still having this problem in latest version (2.0.1)...

Comment by Sergey Syreskin [ 2012 Aug 21 ]

Forum discussions on this problem:
http://www.zabbix.com/forum/showthread.php?t=17594
http://www.zabbix.com/forum/showthread.php?t=25377

Comment by Eli Stair [ 2012 Oct 17 ]

We see this all over the place as well. It appears to me to be a bug, not an enhancement/feature-improvement... why is this listed as a ZBXNEXT feature-request?

Comment by Greg Swift [ 2012 Oct 17 ]

My understanding is that its not a bug because they changed it to this behavior on purpose.

Design flaw != bug
Design flaw == enhancement/feature-improvement

Comment by Daniel Turner [ 2013 Mar 26 ]

Vote += 1

I would love to see this implemented or rather fixed. I have always worked around it in the past but, and I should mention that this is my first time using the 2.0 base, after defining a bucket load of templates for a complicated system, nesting said templates and then attempting to assign to a host only to be thwarted with a slap in the face was not welcome. I should have known really but it is quite confusing to allow the nesting of the template, which creates copies of the items anyway, but then forbid the host assignment.

Comment by Andris Zeila [ 2013 Apr 26 ]

Database upgrade patch added in development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-928

Comment by Andris Zeila [ 2013 Apr 29 ]

Server side support added in r35331

Comment by dimir [ 2013 Apr 30 ]

(1) [S] Host item linked to application is left without an application if you link and unlink a template with application with the same name.

Situation:

  • host H has application A
  • H has item I linked to A
  • template T has application with the same name A

Steps to reproduce:

  • link T to H
  • unlink T from H
  • observe host H and it's item I, they are left without application A

wiper RESOLVED in r35364

dimir Great, CLOSED

Comment by dimir [ 2013 Apr 30 ]

(2) [S] Possible execute query error when unlinking a template.

If there were no applications to delete SQL DELETE operation is still called with SELECT statement from previous usage.

RESOLVED in r35365, please review

wiper added another check to avoid executing DBselect on empty ids set, please review r35373

dimir CLOSED

Comment by dimir [ 2013 Apr 30 ]

DB patch successfully tested.

Comment by dimir [ 2013 May 02 ]

(3) [S] SQL error when unlinking a template without applications.

Proposed fix, RESOLVED in r35387.

wiper looks good, CLOSED

Comment by Christian Lahti [ 2013 May 02 ]

Is there an available patch, or at least a list of affected files? I am running 2.0.5

Comment by dimir [ 2013 May 02 ]

(4) [S] TODO. Test linking of templates that have linked templates. This should be possible when Frontend is ready.

sasha TESTED

dimir CLOSED

Comment by dimir [ 2013 May 02 ]

Server side basically tested.

Comment by richlv [ 2013 May 02 ]

Christian, this change won't be backported to 2.0

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 08 ]

Specification available here https://www.zabbix.org/wiki/Docs/specs/ZBXNEXT-928

Comment by Alexander Vladishev [ 2013 May 08 ]

(5) [G] Cannot compile agent only

In file included from ../../../include/db.h:25:0,
                 from misc.c:22:
../../../include/zbxdb.h:179:1: error: unknown type name ‘DB_RESULT’
../../../include/zbxdb.h:180:1: error: unknown type name ‘DB_RESULT’
../../../include/zbxdb.h:182:1: error: unknown type name ‘DB_ROW’
../../../include/zbxdb.h:182:22: error: unknown type name ‘DB_RESULT’
In file included from misc.c:22:0:
../../../include/db.h:474:1: error: unknown type name ‘DB_RESULT’
../../../include/db.h:475:1: error: unknown type name ‘DB_RESULT’
../../../include/db.h:477:1: error: unknown type name ‘DB_RESULT’
../../../include/db.h:478:1: error: unknown type name ‘DB_ROW’
../../../include/db.h:478:17: error: unknown type name ‘DB_RESULT’
../../../include/db.h:528:43: error: unknown type name ‘DB_ROW’
make[3]: *** [misc.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [install-recursive] Error 1
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1

#include "db.h" should be removed from misc.c module

wiper RESOLVED in r35507

sasha CLOSED

Comment by Alexander Vladishev [ 2013 May 09 ]

(6) [S] Broken database upgrade:

 11403:20130509:095800.858 query [txnlev:1] [create table dbversion (
mandatory integer default '0' not null,
optional integer default '0' not null,PRIMARY KEY()
)]
 11403:20130509:095800.859 [Z3005] query failed: [0] PGRES_FATAL_ERROR:ERROR:  syntax error at or near ")"
LINE 3: optional integer default '0' not null,PRIMARY KEY()
                                                          ^
 [create table dbversion (
mandatory integer default '0' not null,
optional integer default '0' not null,PRIMARY KEY()
)]
 11403:20130509:095800.859 query [create table dbversion (
mandatory integer default '0' not null,
optional integer default '0' not null,PRIMARY KEY()
)] failed, setting transaction as failed
 11403:20130509:095800.859 query [txnlev:1] [rollback;]

Support of primary keys was implemented in dev/ZBXNEXT-1633 branch. Please copy from here.

wiper RESOLVED in r35514

sasha CLOSED

Comment by Alexander Vladishev [ 2013 May 09 ]

(7) [S] DBpatch_02010071(): new table structure should be described in function.

For example:
dev/ZBXNEXT-1633/src/libs/zbxdbupgrade/dbupgrade.c: DBpatch_02010077()

wiper RESOLVED in r35516

sasha CLOSED

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 15 ]

Frontend ready for testing.

Comment by Eduards Samersovs (Inactive) [ 2013 May 21 ]

(12) Need to allow remove application which is used in web scenario. As we discussed.

jelisejev Frontend side resolved in r35829.
Eduards CLOSED

wiper After additional discussion was decided to not remove applications with items. So server side reverted to r35830. CLOSED

Comment by Eduards Samersovs (Inactive) [ 2013 May 24 ]

Frontend tested!

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

Available in 2.1.0 r35864.

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

(13) Docs.

jelisejev Updated:
API changelog - https://www.zabbix.com/documentation/2.2/manual/api/changes_2.0_-_2.2
application API reference - https://www.zabbix.com/documentation/2.2/manual/api/reference/application/object

martins-v Updated:
https://www.zabbix.com/documentation/2.2/manual/introduction/whatsnew220#linking_templates_with_the_same_application_name
https://www.zabbix.com/documentation/2.2/manual/config/templates/linking (text removed regarding inability to link if same-name applications present)

<richlv> i slightly changed whatsnew - please review

martins-v Reviewed.

sasha CLOSED

Comment by dimir [ 2013 May 30 ]

(14) [F] Regression in trunk: cannot unlink a template from host (PostgreSQL):

pg_query(): Query failed: ERROR: column "ht" of relation "httptest" does not exist
LINE 1: UPDATE httptest ht SET ht.applicationid=NULL WHERE ht.applic...
^ [hosts.php:462 → CAPIObject->update() → CAPIObject->__call() → czbxrpc::call() → czbxrpc::callAPI() → call_user_func() → CHost->update() → CHost->massUpdate() → CHost->massRemove() → CHostGeneral->massRemove() → CHostGeneral->unlink() → CApplication->delete() → CApplicationManager->delete() → DBexecute() → pg_query() in /home/vl/svn/zabbix/trunk/frontends/php/include/db.inc.php:512]
Error in query [UPDATE httptest ht SET ht.applicationid=NULL WHERE ht.applicationid BETWEEN '345' AND '355'] [ERROR: column "ht" of relation "httptest" does not exist
LINE 1: UPDATE httptest ht SET ht.applicationid=NULL WHERE ht.applic...
^]
pg_query(): Query failed: ERROR: current transaction is aborted, commands ignored until end of transaction block [hosts.php:462 → CAPIObject->update() → CAPIObject->__call() → czbxrpc::call() → czbxrpc::callAPI() → call_user_func() → CHost->update() → CHost->massUpdate() → CHost->massRemove() → CHostGeneral->massRemove() → CHostGeneral->unlink() → CApplication->delete() → CApplicationManager->delete() → CProfile::delete() → DBexecute() → pg_query() in /home/vl/svn/zabbix/trunk/frontends/php/include/db.inc.php:512]
Error in query [DELETE FROM profiles WHERE idx='web.latest.toggle' AND (idx2 IN ('345','346','347','348','349','350','351','352','353','354','355'))] [ERROR: current transaction is aborted, commands ignored until end of transaction block]
pg_query(): Query failed: ERROR: current transaction is aborted, commands ignored until end of transaction block [hosts.php:462 → CAPIObject->update() → CAPIObject->__call() → czbxrpc::call() → czbxrpc::callAPI() → call_user_func() → CHost->update() → CHost->massUpdate() → CHost->massRemove() → CHostGeneral->massRemove() → CHostGeneral->unlink() → CApplication->delete() → CApplicationManager->delete() → DB::delete() → DBexecute() → pg_query() in /home/vl/svn/zabbix/trunk/frontends/php/include/db.inc.php:512]
Error in query [DELETE FROM applications WHERE (applicationid IN ('345','346','347','348','349','350','351','352','353','354','355'))] [ERROR: current transaction is aborted, commands ignored until end of transaction block]
SQL statement execution has failed "DELETE FROM applications WHERE (applicationid IN ('345','346','347','348','349','350','351','352','353','354','355'))"

jelisejev Fixed directly in trunk r36002. CLOSED.

Comment by richlv [ 2013 May 31 ]

(15) had 3 templates with same application, linked all 3 to a single host. in the application list for the host, all 3 templates are listed as parents.
deleted application on one of the templates - it was also deleted on the host. should not be

jelisejev RESOLVED in svn://svn.zabbix.com/branches/dev/ZBXNEXT-928.
Eduards CLOSED

Comment by Pavels Jelisejevs (Inactive) [ 2013 Jun 04 ]

Fixed in 2.1.0 r36059.

CLOSED.

Generated at Fri Apr 26 02:29:10 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.