Skip to content

install

遇见王斌 edited this page May 4, 2019 · 9 revisions

安装及配置

1 安装

1.1 git 下载

#git clone https://github.com/meetbill/zabbix_manager.git
#cd zabbix_manager
#sh start.sh

常见问题 git clone 失败

[root@localhost ~]# git clone https://github.com/meetbill/zabbix_manager.git
Initialized empty Git repository in /root/zabbix_manager/.git/
error:  while accessing https://github.com/meetbill/Vim.git/info/refs
fatal: HTTP request failed

解决方法

#git config --global http.sslVerify false

1.2 curl 下载

#curl -o zabbix_manager.zip https://codeload.github.com/meetbill/zabbix_manager/zip/master
#unzip zabbix_manager.zip

2 配置

2.1 配置文件位置

  • /etc/zabbix_tool/zabbix_config.ini(连接 zabbix server 服务配置)
  • /etc/zabbix_tool/zabbix_setting.ini(额外配置)

2.2 配置连接 zabbix server

配置文件:/etc/zabbix_tool/zabbix_config.ini

注意,配置时将配置配置在 [zabbixserver] 字段下

[zabbixserver]---------------------- 默认连接(可通过 --profile 选择连接的 zabbix)
server = 127.0.0.1------------------zabbix server IP
port = 80---------------------------zabbix web 端口
user = admin------------------------zabbix web 管理员账号
password = zabbix-------------------zabbix web 管理员密码

################################# 
# zabbix_api 可以进行管理多台 zabbix server 只需要在配置文件中增加如下配置即可,加入要对 [bendi] 的机器进行管理,在命令行后跟 --profile bendi 即可
#[bendi]
#server = 192.168.199.128
#port = 80
#user = admin
#password = zabbix
################################# 

2.3 额外配置

搭建 zabbix server 时使用的lnmp(即前端使用的 nginx 时则不需要进行以下操作),前端使用的apache时需要进行操作

配置文件:/etc/zabbix_tool/zabbix_setting.ini

修改如下

apache=True

3 测试

zabbix_api hostgroup_get --table

3.1 404 错误

3.1.1 错误提示

...
w_lib.zabbix_api_lib.ZabbixAPIException: urllib2.URLError - Not Found

3.1.2 解决方法

#curl -sL -w "%{http_code}\n" http://IP: 端口 /api_jsonrpc.php
如果返回 412 则 zabbix_setting.ini 中 apache=False

curl -sL -w "%{http_code}\n" http://IP: 端口 /zabbix/api_jsonrpc.php
如果返回 412 则 zabbix_setting.ini 中 apache=True

3.2 密码错误

3.2.1 错误提示

...
w_lib.zabbix_api_lib.ZabbixAPIException: (u'Error -32602: Invalid params., Login name or password is incorrect. while sending {"params": {"password": "XXXXXXX", "user": "admin"}, "jsonrpc": "2.0", "method": "user.login", "id": 0}', -32602)

3.2.2 解决方法

检查用户名及密码,并修改配置文件