发布于 4年前

Zabbix前端插件zatree在Zabbix 2.2.1前端报错的解决方案

这个问题是我在写Zabbix书时候自己搭建zatree碰到的,今天正巧有人问,就把方案贴出来。这个问题发生概率不大,要正好是2.2.1才能发现,而且在2.2.2又恢复了。具体报错如下:

Call to undefined method CMacrosResolverHelper::resolveItemNames() in /var/www/html/zabbix/include/classes/api/CLineGraphDraw_Zabbix.php on line 107

请大家检查Zabbix的前端版本,因为这里需要resolveItemNames这个方法来获取Itemid。我的前端界面的版本为2.2.1,在安装zatree的时候就出了问题,具体报错就是找不到CMacrosResolverHelper模块的resolveItemNames方法,我grep后看了代码,发现2.2.1的代码中确实没有这个方法:

grep 'function resolve' /var/www/html/zabbix/include/classes/macros/CMacrosResolverHelper.php
public static function resolve(array $options) {
public static function resolveHttpTestName($hostId, $name) {
public static function resolveHostInterfaces(array $interfaces) {
public static function resolveTriggerName(array $trigger) {
public static function resolveTriggerNames(array $triggers) {
public static function resolveTriggerDescription(array $trigger) {
public static function resolveTriggerDescriptions(array $triggers) {
public static function resolveTriggerNameById($triggerId) {
public static function resolveTriggerNameByIds(array $triggerIds) {
public static function resolveTriggerReference($expression, $text) {
public static function resolveEventDescription(array $event) {
public static function resolveGraphName($name, $items) {
public static function resolveGraphNameByIds($data) {

这时我去下载了Zabbix 2.2.2版本,发现这个方法又有了,其中缘由无从而知,估计是Zabbix团队在重构前端代码时的一次修正,而58同城的工程师没有发现这个小版本的变动造成的。我们看Zabbix 2.2.2版本中的代码:

grep 'function resolve' ~/frankyao/zabbix-2.2.2/frontends/php/include/classes/macros/CMacrosResolverHelper.php 
public static function resolve(array $options) {
public static function resolveHttpTestName($hostId, $name) {
public static function resolveHostInterfaces(array $interfaces) {
public static function resolveTriggerName(array $trigger) {
public static function resolveTriggerNames(array $triggers) {
public static function resolveTriggerDescription(array $trigger) {
public static function resolveTriggerDescriptions(array $triggers) {
public static function resolveTriggerNameById($triggerId) {
public static function resolveTriggerNameByIds(array $triggerIds) {
public static function resolveTriggerReference($expression, $text) {
public static function resolveTriggerExpressionUserMacro(array $trigger) {
public static function resolveEventDescription(array $event) {
public static function resolveGraphName($name, array $items) {
public static function resolveGraphNameByIds(array $data) {
public static function resolveItemNames(array $items) {
public static function resolveItemKeys(array $items) {
public static function resolveFunctionParameters(array $data) {

在将前端升级为2.2.2后问题解决,和2.2.1没有兼容性问题。

PS:升级到2.2.3的前端也可以解决这个问题。

相关文章

©2020 edoou.com   京ICP备16001874号-3