给Zabbix一件华丽的衣服Grafana插件

来源:互联网 发布:生物多样性监测网络 编辑:程序博客网 时间:2024/05/17 04:45

Grafana插件:

Grafana是一个用Javascript写的开源的、功能丰富的Dashboard和图像编辑器,界面还是比较叼的,喜欢的可以试试。

一、下载Grafana插件

wget https://grafanarel.s3.amazonaws.com/builds/grafana-2.0.2-1.x86_64.rpm rpm -ivh grafana-2.0.2-1.x86_64.rpmyum -y install git         #用于下载grafana插件的php文档git clone  https://github.com/alexanderzobnin/grafana-zabbix/cp -rf grafana-zabbix/zabbix/ /usr/share/grafana/public/app/plugins/datasource/zabbix

二、编辑plugin.json
注:下面修改的username和password不仅有对Zabbix_Server数据库的读权限,并且有对Zabbix Web页面的读权限

  • 修改username
  • 修改password
vim /usr/share/grafana/public/app/plugins/datasource/zabbix/plugin.json{  "username": "show",  "password": "show",}

三、Mysql赋权用户和在Zabbix Web界面创建用户show
(1)、对Zabbix数据库用户赋权

mysql> grant all privileges on zabbix.* to 'show'@'localhost' identified by 'show';mysql> grant all privileges on zabbix.* to 'show'@'192.168.0.216' identified by 'show';mysql> flush privileges;

(2)、在Zabbix Web界面中添加用户show

单击Administrator,选择Users,Create User由于这边是测试环境,你可以选择将Show用户添加到Administrator如果想谨慎点,那么就创建一个group,并且给该group赋予read权限,再把User添加到group里面例如:下面我把show用户添加到了Group show里面usershowpass:show

这里写图片描述
这里写图片描述

四、验证Zabbix json配置档api_jsonrpc.php

至少在当前zabbix 2.5.0环境中,确保当前的这些信息已经存在vim /usr/local/zabbix/php/api_jsonrpc.phpheader( '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';

五、启动Grafana服务并且配置Grafana页面

Grafana默认port为3000service grafana-server starthttp://your_ip:3000
我们看到已经打开Grafana Web页面啦Default AccountUser:adminPass:admin

这里写图片描述

OK,你已经登录成功了? 好吧恭喜你!!这个时候我们要做什么呢? 

六、为Grafana添加数据库

进去之后点击左上角的Data Sources-->Add new下面总共有三处设置
  • Add data source (添加数据库名称及类型)
  • Http settings (设置zabbix api_json页面,不验证)
  • Zabbix API detail (可以读取这些信息的Users)

这里写图片描述


七、创建Dashboards

单击左侧Dashboards--->选择Home--->左下角new(新添加一个Dashboards)

这里写图片描述

设置Dashboards的描述信息我在这里命名为Zabbix_Server_Monitoring点击settings左边的按钮保存即可

这里写图片描述

这里写图片描述


8、为Zabbix_Server_Monitoring添加Graphs

单击Zabbix_Server_Monitoring点击左上角暗绿色的按钮Add PanelGraph

这里写图片描述

这时候界面中会出现 no database单击'no title' 会弹出一个框,选择edit

这里写图片描述

好,现在我们先点击General,设置基本信息标题为 :Memoey_INFOSpan6 

这里写图片描述

标题设置完了,我们来设置需要监控什么吧!单击Metrics,把该监控的都填进去注意了,这里选择需要通过Application,以前添加东西没习惯添加到Application的童鞋注意了,你会被坑到的~

这里写图片描述

ok!!!,我在这边随便添加了几项信息,步骤和这个一样。不过由于是测试环境,做的比较粗糙啦~

这里写图片描述

0 0
原创粉丝点击