标签:grafana
1、操作环境
CentOS release 6.4 (Final) Kernel \r on an \m [root@xo ~]# uname -r 2.6.32-358.el6.x86_64 [root@xo ~]# uname -m x86_64
2、下载grafana以及安装
[root@xo ~]# wget https://grafanarel.s3.amazonaws.com/builds/grafana-2.1.1-1.x86_64.rpm [root@xo ~]# yum install grafana-2.1.1-1.x86_64.rpm -y
3、下载zabbix的grafana插件,以及配置相关文件
[root@xo ~]# git clone https://github.com/linglong0820/grafana-zabbix [root@xo datasource]# cp -r grafana-zabbix/zabbix/ /usr/share/grafana/public/app/plugins/datasource
4、启动grafana
[root@xo ~]# /etc/init.d/grafana-server start Starting Grafana Server: .... OK
5、修改zabbix的api文件api_jsonrpc.php
[root@xo zabbix]# pwd /usr/share/zabbix [root@xo zabbix]# vim api_jsonrpc.php网上找的内容如下:
修改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命令测试:
[root@xo zabbix]# pwd /usr/share/grafana/public/app/plugins/datasource/zabbix [root@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命令测试
[root@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的配置图形,收工。
本文出自 “村里的男孩” 博客,请务必保留此出处http://noodle.blog.51cto.com/2925423/1768348
标签:grafana
原文地址:http://noodle.blog.51cto.com/2925423/1768348