|
1、操作环境
1
2
3
4
5
6
| CentOS release 6.4 (Final)
Kernel \r on an \m
[iyunv@xo ~]# uname -r
2.6.32-358.el6.x86_64
[iyunv@xo ~]# uname -m
x86_64
|
2、下载grafana以及安装
3、下载zabbix的grafana插件,以及配置相关文件
4、启动grafana
1
2
| [iyunv@xo ~]# /etc/init.d/grafana-server start
Starting Grafana Server: .... OK
|
5、修改zabbix的api文件api_jsonrpc.php
1
2
3
| [iyunv@xo zabbix]# pwd
/usr/share/zabbix
[iyunv@xo zabbix]# vim api_jsonrpc.php
|
网上找的内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| 修改Zabbix的API文件,由于Zabbix2.2不支持跨域的问题,故添加以下配置:
#sudo vim /usr/share/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;
}
#在此之前添加
require_once dirname(__FILE__).'/include/func.inc.php';
require_once dirname(__FILE__).'/include/classes/class.chttp_request.php';
注意:如果是2.4以上版本,请忽略此配置(无需更改api_jsonrpc.php文件)
|
6、注意这里是Zabbix的WEB API用户和密码(不一定非得是Admin,普通用户即可,具有可读权限),假如你不能确定用户名密码是否对,用如下shell命令测试:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [iyunv@xo zabbix]# pwd
/usr/share/grafana/public/app/plugins/datasource/zabbix
[iyunv@xo zabbix]# cat plugin.json
{
"pluginType": "datasource",
"name": "Zabbix",
"type": "zabbix",
"serviceName": "ZabbixAPIDatasource",
"module": "plugins/datasource/zabbix/datasource",
"partials": {
"config": "app/plugins/datasource/zabbix/partials/config.html",
"query": "app/plugins/datasource/zabbix/partials/query.editor.html",
"annotations": "app/plugins/datasource/zabbix/partials/annotations.editor.html"
},
"username": "test",
"password": "test",
"trends": false,
"trendsFrom": "7d",
"limitmetrics": 100,
"metrics": true,
"annotations": true
}
|
shell命令测试
1
2
3
4
5
6
7
8
9
10
11
12
13
| [iyunv@xo zabbix]# curl -i -X POST -H 'Content-Type:application/json' -d '{"jsonrpc": "2.0","method":"user.authenticate","params":{"user":"test","password":"test"},"auth": null,"id":0}' http://127.0.0.1/zabbix/api_jsonrpc.php
HTTP/1.1 200 OK
Date: Tue, 26 Apr 2016 01:44:08 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 1000
Content-Length: 68
Connection: close
Content-Type: application/json
{"jsonrpc":"2.0","result":"8375dc88a89f08229b0feb1b50d4d843","id":0}
|
注:成功后就可以配置grafana了
7、配置grafana
默认的登录用户和密码是admin
8、添加grafana的图形
以上就是grafana的配置图形,收工。
|
|
|