Zabbix前端插件zatree在Zabbix 2.2.1前端報錯的解決方案

這個問題是我在寫Zabbix書時候本身搭建zatree碰到的,今天正巧有人問,就把方案貼出來。這個問題發生機率不大,要正好是2.2.1才能發現,並且在2.2.2又恢復了。具體報錯以下:php

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的代碼中確實沒有這個方法:html

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沒有兼容性問題。express

PS:升級到2.2.3的前端也能夠解決這個問題。api

相關文章
相關標籤/搜索