191145685 发表于 2019-1-17 12:26:48

grafana

  grafana-zabbix安装
  作者:itnihao
  版本:v1.0
  时间:2015-07-13
  

  零、安装包下载
  
https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0-1.x86_64.rpm
https://github.com/alexanderzobnin/grafana-zabbix/archive/v2.5.1.tar.gz
链接: http://pan.baidu.com/s/1bnFkkFH 密码: qkpg
  温馨提示:
     grafana的版本和grafana-zabbix的版本必须匹配,否则会出现异常。
     本文以grafana2.5版本为例讲解,如果后面grafana和grafana-zabbix更新,需要将2个版本匹配即可。
  一、安装grafana
  什么是grafana,参考http://www.oschina.net/p/grafana
  安装参考文档      http://docs.grafana.org/v2.0/installation/
  grafana演示站点http://play.grafana.org/
  shell#sudo yum installhttps://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0-1.x86_64.rpm【如被墙,请移步到百度网盘下载】
  安装包详情
  

  二进制文件   /usr/sbin/grafana-server
  启动脚本         /etc/init.d/grafana-server
  环境变量         /etc/sysconfig/grafana-server
  配置文件         /etc/grafana/grafana.ini
  systemd服务grafana-server.service
  日志               /var/log/grafana/grafana.log
  sqlite3数据库/var/lib/grafana/grafana.db
  启动服务
  shell#sudo service grafana-server start
  服务详情
  启动用户 grafana
  服务名称 grafana-server
   默认端口 3000
  账号      admin
  密码      admin
  服务自启动
  shell#sudo /sbin/chkconfig --add grafana-server
  ####CentOS7####
  shell#sudo systemctl daemon-reload
  shell#sudo systemctl start grafana-server
  shell#sudo systemctl status grafana-server
  shell#sudo systemctl enable grafana-server.service
  http://s5.运维网.com/wyfs02/M01/76/68/wKiom1ZSvo_TOqaSAAE-kyhz5ug672.png
  二、安装grafana-zabbix插件
  项目地址
         https://github.com/alexanderzobnin/grafana-zabbix
  
  shell#wgethttps://github.com/alexanderzobnin/grafana-zabbix/archive/v2.5.1.tar.gz
  shell#sudo cp -r grafana-zabbix/zabbix//usr/share/grafana/public/app/plugins/datasource/
  shell#ls/usr/share/grafana/public/app/plugins/datasource/
  http://s4.运维网.com/wyfs02/M00/76/67/wKioL1ZSv02ihmLUAAIlxnrVK2g951.png
  http://s4.运维网.com/wyfs02/M02/76/67/wKioL1ZSv5OQADkOAABjlIMStMQ767.pnghttp://s4.运维网.com/wyfs02/M01/76/68/wKiom1ZSv2mxr5NMAAGoUHpuuOI989.png
  注意这里是Zabbix的WEB API用户和密码(不一定非得是Admin,普通用户即可,具有可读权限),假如你不能确定用户名密码是否对,用如下shell命令测试:
shell#curl -i -X POST -H 'Content-Type:application/json' -d '{"jsonrpc": "2.0","method":"user.authenticate","params":{"user":"Admin","passwor
d":"zabbix"},"auth": null,"id":0}' http://127.0.0.1/api_jsonrpc.phphttp://s3.运维网.com/wyfs02/M02/76/67/wKioL1ZSwNrgCL3fAAEMVfymmlE810.png
  Zabbix的用户如下
http://s1.运维网.com/wyfs02/M02/76/68/wKiom1ZSwcLT4rTlAAIWzntKErM256.png
  http://s5.运维网.com/wyfs02/M00/76/67/wKioL1ZSwA2zdq4GAABWBLyzuws079.png
  http://s4.运维网.com/wyfs02/M02/76/50/wKiom1ZO30mS8n8PAAGHVDmIV_Q446.jpg
  

  

  
重启服务
shell#sudo service grafana-server restart
  修改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/core/CHttpRequest.php';
  注意:如果是2.4以上版本,请忽略此配置(无需更改api_jsonrpc.php文件)
  http://s2.运维网.com/wyfs02/M01/76/50/wKiom1ZO32_zUV7wAAMpGt9mlQI757.jpg
  三、配置grafana
http://ww4.sinaimg.cn/large/65b71c64gw1eu15jymbzqj213e0lbwg9.jpg 配置 Datasource
http://ww1.sinaimg.cn/large/65b71c64gw1eu15jzdh6vj213e0kgmz1.jpg 配置zabbix的用户,密码,注意账号在Zabbix中存在且有只读权限(即上面所说的Zabbix用户,我这里用户是Admin,你可以用非Admin用户即可)
http://s5.运维网.com/wyfs02/M00/76/68/wKiom1ZSw2bDyf4CAAFB3N9BApk728.png
  好了,安装到此完毕

  现在添加grafana图形,参考https://github.com/alexanderzobnin/grafana-zabbix/wiki/Usage,具体图形使用不再详解,参考grafana使用温度
  如果在添加图形的时候无法出现Group分组的选项,说明你的Zabbix插件配置存在问题,请检查在继续,可开浏览器调试模式看console log
http://ww1.sinaimg.cn/large/65b71c64gw1eu15k1f236j21080hqad3.jpg
  添加好的模板如下
http://ww1.sinaimg.cn/large/65b71c64gw1eu15k261v8j211t0madn1.jpg
http://s3.运维网.com/wyfs02/M01/6F/BD/wKiom1WnCjrj_ziRAAasU2fZcDo584.jpg
  

http://s3.运维网.com/wyfs02/M00/6F/BD/wKiom1WnC6WB_rDkAAbmrf8p-80625.jpg
  如有问题,请多参考官方文档。
  如果遇到问题,请打开浏览器调试模式(不用问我浏览器调试模式怎么打开,自己百度)
http://s2.运维网.com/wyfs02/M02/76/67/wKioL1ZSxMHRYQLwAAHoUUqCM_o270.png
  

http://s1.运维网.com/wyfs02/M00/76/68/wKiom1ZSxOLiDZ3FAAGnGMnFNjE281.png
http://s2.运维网.com/wyfs02/M00/76/67/wKioL1ZSxT2S9A47AAEIuPyZ6pM258.png
  注意上面有一个url无法访问,但不影响使用,可忽略



页: [1]
查看完整版本: grafana