PDA

View Full Version : Updating template items via import in 1.8.2 not working


limo
11-04-2010, 20:24
Hi to all,

we use automatic script to get SNMP oids, portnames etc, which automaticaly generates xml suitable for zabbix import. This works fine.

We linked our ciscos to templates, which are automaticaly generated by this script. Again, no problem.

Now, we are expecting, that when we import updated templates definitions, all items, triggers and graphs will be updated on ciscos.

But when we want to do this, we get this error during importing XML:

Fatal error: Undefined class constant 'resetErrors' in /var/www/zabbix/include/export.inc.php on line 859

Please, is our scenario OK? Does it should work as we expected? We want to achieve every day automatic import of actualised templates (due to port name changes and link changes) and all graphs, item descriptions and triggers should update autmaticaly.

Thank you very much,
Lukas

richlv
16-04-2010, 21:24
interesting. php version, distro ?
if you view "reports -> status of zabbix" as superadmin, does it complain about anything ?

limo
17-04-2010, 08:18
Report is Ok, does not complain about anything.

Distro is debian lenny.

PHP version is 5.2.6.dfsg.1-1+lenny8

Looking into sources, it seems that ResetErrors() is method, but it is called as constant at this line (without () ). Maybe this could be problem..

Thank you

richlv
19-04-2010, 08:00
not sure about details. maybe you can figure out the exact item/trigger that is causing the message and attach a testcase template here ?

limo
19-04-2010, 08:23
Hi,

here is template which is causing problem. But many of them are doing same error. But when it was imported first time, everything is OK. We found, that fist import of template with name 'Template_xxx' is OK, but any subsequent import of same template (which would update items and triggers for all linked hosts too), ends with this error. Unfortunatelly, I cannot say, which trigger or item does this problem because error is fatal and not handled..

pikmaster
19-04-2010, 10:14
Hi. I think it's not related to the particular template, but the fact, that you need to use parenthesis when invoking class method. Change those two lines

zabbix-1.8.2/frontends/php/include/export.inc.php:859
throw new APIException(1, CTemplate::resetErrors);

to
throw new APIException(1, CTemplate::resetErrors());


and zabbix-1.8.2/frontends/php/include/export.inc.php:873
throw new APIException(1, CHost::resetErrors);

to
throw new APIException(1, CHost::resetErrors());

Unfortunatelly, it produces more errors, when importing:

* Undefined variable: template[/usr/src/zabbix-1.8.2/frontends/php/api/classes/class.ctemplate.php:1010]
* Invalid argument supplied for foreach()[/usr/src/zabbix-1.8.2/frontends/php/api/classes/class.ctemplate.php:1183]
* reset() [<a href='function.reset'>function.reset</a>]: Passed variable is not an array or object[/usr/src/zabbix-1.8.2/frontends/php/api/classes/class.ctemplate.php:1206]
* Template [ cisco4948 ] already exists
* Failed to update template

The problem seems to be this line zabbix-1.8.2/frontends/php/api/classes/class.ctemplate.php:1010

$template['templates'] = $template;

Which seems to be resolved by changing it to:
$template['templates'] = (array)$template;

OK, the patch is submitted http://www.zabbix.com/forum/showthread.php?t=16753

richlv
02-06-2010, 16:48
so, does importing work as expected in 1.8 svn head ?

simonc
12-07-2010, 15:32
Hi all !

Any news about this problem ? Is it fixed in the next version ?
I had the same problem on 1.8.2 and i applied the pikmaster's patches to operate properly.

Br
Simon

zabbix_zen
16-06-2011, 16:21
Hi.

This issue is still present in 1.8.5
If php-xml isn't installed, instead of a blank message an error message should be shown after the failed import.