您的位置:首页 > 其它

Zabbix:grafana-zabbix

2016-07-23 00:00 369 查看
摘要: 请大伙一起分享学习

参考链接(感谢分享):
http://docs.grafana.org/v2.0/installation/
https://github.com/alexanderzobnin/grafana-zabbix/wiki/Installation
http://itnihao.blog.51cto.com/1741976/1675178

需求:
· grafana版本要和grafana-zabbix版本对应,避免异常
· 更新时,需要两者同步更新

1. CentOS安装grafana(rpm)

# wget https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0-1.x86_64.rpm # rpm -ivh grafana-2.5.0-1.x86_64.rpm
#或者直接使用
# yum install https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0-1.x86_64.rpm[/code] · 环境变量:/etc/sysconfig/grafana-server
· 配置文件:/etc/grafana/grafana.ini
· 日志文件:/var/log/grafana/grafana.log
· systemd服务:grafana-server.service
· sqlite3数据库:/var/lib/grafana/grafana.db
· grafana安装目录:/usr/share/grafana
服务详情
· 启动用户:grafana
· 服务名称:grafana-server
· 默认端口:3000
· 账号:admin
· 密码:admin

1.1 yum安装

# vim /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packagecloud.io/grafana/stable/el/6/$basearch  #稳定版
#baseurl=https://packagecloud.io/grafana/testing/el/6/$basearch #最新版(beta)
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

启动服务/开机自启

C6# service grafana-server start
C6# chkconfig --add grafana-server
C6# chkconfig grafana-server on
C7# systemctl daemon-reload
C7# systemctl start grafana-server
C7# systemctl enable grafana-server.service

查看状态

C7# systemctl status grafana-server

1.2 升级

# yum install initscripts fontconfig
# rpm -Uvh grafana-3.1.0-1468321182.x86_64.rpm

2. 安装grafana-zabbix插件

# wget https://github.com/alexanderzobnin/grafana-zabbix/archive/v2.5.1.tar.gz # tar xzf v2.5.1.tar.gz
# cp -r grafana-zabbix-2.5.1/zabbix /usr/share/grafana/public/app/plugins/datasource/
# cd /usr/share/grafana/public/app/plugins/datasource/zabbix
# vim plugin.json
{
"pluginType": "datasource",
"name": "Zabbix",

"type": "zabbix",
"serviceName": "ZabbixAPIDatasource",

"module": "app/plugins/datasource/zabbix/datasource",

"partials": {
"config": "app/plugins/datasource/zabbix/partials/config.html"
},

# 追加"username"和"password"内容。用户并非一定是管理员,只要有可读权限即可。
"username": "Admin",
"password": "zabbix",

"metrics": true,
"annotations": true
}

测试用户/密码是否正确

# curl -i -X POST -H 'Content-Type:application/json' -d '{"jsonrpc": "2.0","method":"user.authenticate","params":{"user":"Admin","password":"zabbix"},"auth": null,"id":0}' http://127.0.0.1/api_jsonrpc.php[/code] 
修改Zabbix的API文件,由于Zabbix2.2不支持跨域的问题,故添加以下配置:(2.4以后无需配置)

require_once dirname(__FILE__).'/include/func.inc.php';
require_once dirname(__FILE__).'/include/classes/core/CHttpRequest.php';

在上面两行前新增

# vim <wwwroot>/zabbix/api_jsonrpc.php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Max-Age: 1000');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
return;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息