一、zatree简介
zatree 是来自国内58同城开发的监控软件zabbix的一个插件,主要功能是提供host group的树形展示和在item里指定关键字查询及数据排序。
二、安装zatree
1、下载文件[root@zabbix ~]# yum -y install git
[root@zabbix ~]# git clone https://github.com/spide4k/zatree.git zatree
2、复制相关文件[root@zabbix ~]# cp -rf zatree/zabbix-2.0.x /var/www/html/zabbix/zatree
[root@zabbix ~]# cd /var/www/html/zabbix/zatree/addfile/
[root@zabbix addfile]# cp class.cchart_zabbix.php class.cgraphdraw_zabbix.php class.cp_w_picpathtexttable_zabbix.php /var/www/html/zabbix/include/classes/
[root@zabbix addfile]# cp zabbix.php zabbix_chart.php /var/www/html/zabbix/
[root@zabbix addfile]# cp CItemValue.php /var/www/html/zabbix/api/classes/
3、支持web interface,修改配置文件[root@zabbix ~]# cat /var/www/html/zabbix/zatree/zabbix_config.php
global $zabbix_api_config;
$zabbix_api_config=array(
'api_url'=>'api_jsonrpc.php',
'user'=>'Admin', //web登陆的用户名
'passowrd'=>'zabbix', //web登陆的密码
'graph_url'=>'zabbix_chart.php',
);
?>
4:导航增加Zatree入口,修改menu.inc.php,main.js[root@zabbix ~]# vim /var/www/html/zabbix/include/menu.inc.php +283
#在283行后也就是284行后加如下信息,切勿重复
'zatree'=>array(
'label' => _('Zatree'),
'user_type' => USER_TYPE_ZABBIX_USER,
'default_page_id' => 0,
'force_disable_all_nodes' => true,
'pages' =>array(
array('url' => 'zabbix.php','label' => _('Zatree'),)
)
),
'login' => array(
'label' => _('Login'),
'user_type' => 0,
'default_page_id' => 0,[root@zabbix ~]# vim /var/www/html/zabbix/js/main.js +106
#替换106行
menus: {'empty': 0, 'view': 0, 'cm': 0, 'reports': 0, 'config': 0, 'admin': 0, 'zatree':0},
5、增加封装的api类[root@zabbix ~]# vim /var/www/html/zabbix/include/classes/api/API.php +74
#添加一行参数
'usermedia' => 'CUserMedia',
'itemvalue'=>'CItemValue',
'webcheck' => 'CWebCheck'
);
6、登陆zabbix,在导航里可以看到一个Zatree的菜单,使用方法是傻瓜的
7、 如果你的主机名都是ip,并且向排序显示,解决方法: 编辑zabbix_ajax.php 43行代码注释44打开,不支持ip排序,43行代码打开44行注释,支持ip排序 43 $new_list[ip2long($each_host->host)]=$each_host; 44 //$new_list[] = $each_host;
学习来源:
https://github.com/spide4k/zatree/tree/master/zabbix-2.0.x