Grafana 是纯Javascript开发的前端展示工具。后端数据源可以通过Graphite、InfluxDB、OpenTsDB等获取数据,或者通过插件的方式获取zabbix监控的数据。然后在前端通过Grafana展示数据,grafana可以自定义各种图表。
官方安装文档:http://docs.grafana.org/installation/rpm
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-grafana-to-plot-beautiful-graphs-from-zabbix-on-centos-7
---plugin:
https://grafana.com/plugins/alexanderzobnin-zabbix-app v3.9.0
https://grafana.com/plugins/grafana-clock-panel v0.0.9
https://grafana.com/plugins/grafana-piechart-panel v1.3.0
https://grafana.com/plugins/raintank-worldping-app v1.2.3
# 1. install grafana software and plugin
为便于本地安装,已经将所需要软件包下载至本地服务器
wget http://10.245.254.93/linux/soft/zabbix/grafana/grafana-5.1.0-1.x86_64.rpm
wget http://10.245.254.93/linux/soft/zabbix/grafana/alexanderzobnin-grafana-zabbix-v3.9.0-0-gf0a5e7d.zip
wget http://10.245.254.93/linux/soft/zabbix/grafana/grafana-clock-panel-c5b3c7f.zip
wget http://10.245.254.93/linux/soft/zabbix/grafana/grafana-piechart-panel-9448578.zip
yum -y localinstall grafana-5.1.0-1.x86_64.rpm
yum -y install unzip
unzip -d /var/lib/grafana/plugins alexanderzobnin-grafana-zabbix-v3.9.0-0-gf0a5e7d.zip
unzip -d /var/lib/grafana/plugins grafana-clock-panel-c5b3c7f.zip
unzip -d /var/lib/grafana/plugins grafana-piechart-panel-9448578.zip
systemctl enable grafana-server
systemctl start grafana-server
# 2. enable zabbix plugin on grafana web
- Configuration --> Plugins --> zabbix [enable]
# 3. add zabbix as Data sources
- Configuration --> Data Sources --> + Add data source
- Name : CQ191
- Type : Zabbix
- URL : http://zabbixcq.ecmms.ORG/zabbix/api_jsonrpc.php
- Access : proxy
- Username : zabbixCQ2
- Password : zzzzz
- Trends : v
# 4. 创建自己的dashboard
数据标准说明:
- data (ICE) 国际标准
- data (Metric) 公制
# 4.1 新增Dashboard : my zabbix dashboard
- Settings --> General
- Name : My Dashboard
# 4.2 新增3个变量
- settings --> Variables -->
- Variables > New :
- General -> Name : MyDS191
- General -> Type :Datasource
- Data source options -> Type : Zabbix
- Variables > New :
- General -> Name : Group
- General -> Type :Query
- Query Option -> Data source : $MyDS191
- Query Option -> Query : *
- Variables > New :
- General -> Name : Hosts
- General -> Type :Query
- Query Option -> Data source : $MyDS191
- Query Option -> Query : $Group.*
# 4.3 增加 CPU、Memory/HDD/NIC dashboard
- Add panel --> Graph --> Edit
cpu - General -> Info -> Title : CPU
- Metrics -> Data Source : $MyDS191
- A
Group : $Group
Host : $Host
Application : CPU
Item : /CPU (?!idle).* time/
- B Item : /Processor load/
- Axes -> Unit : percent (0-100)
mem - General -> Info -> Title : Memory
- Metrics -> Data Source : $MyDS191
- A
Group : $Group
Host : $Host
Application : Memory
Item : /Available memory/
- B Item : /Total memory/
- C Item : /Free memory/
- Axes -> Unit : (ICE)bytes
hdd - General -> Info -> Title : HDD
- Metrics -> Data Source : $MyDS191
- A
Group : $Group
Host : $Host
Application : Memory
Item : /(Free|Total) disk space on (C:|D:|E:|F:|/|/data|/home)$/
- Axes -> Unit : (ICE)bytes
nic - General -> Info -> Title : Network
- Metrics -> Data Source : $MyDS191
- A
Group : $Group
Host : $Host
Application : Network interfaces
Item : /(Incoming|Outgoing) network traffic on (en|eth|bond)/
- B Item : /(Incoming|Outgoing) network traffic on (HP|Intel|Microsoft|vmxnet3)/
# - C Item : /(Incoming|Outgoing) network traffic on (?!WAN).*/
- Axes -> Unit : (ICE)bytes
icmp - General -> Info -> Title : ICMP Ping
- Metrics -> Data Source : $MyDS191
- A
Group : $Group
Host : $Host
Application : /.*/
Item : /ICMP/
- Axes -> Unit : seconds (s)
- Add panel --> Singlestat --> Edit
uptime - General -> Info -> Title : System uptime
- Metrics -> Data Source : $MyDS191
- A
Group : $Group
Host : $Host
Application : /.*/
Item : /System uptime/
- Options -> Unit : seconds (s)
以上设定,调试完善后, 可将dashboard导出另存。
5. 可导入的dashboard json文件,快速完成 Dashboard 定义
6. 默认的Grafans服务端口是3000,可修改/etc/grafana/grafana.ini 文件内的 http_port,由3000到80。
因为Linux对非系统进程限制了使用1024以下端口, 对于2.6.24及更新的Kerner Linux,可运行下面命令,完成授权(give the Grafana binary permission):
# setcap 'cap_net_bind_service+ep' /usr/sbin/grafana-server
7. LDAP for Grafana 认证设定
- 官方文档: http://docs.grafana.org/installation/ldap/
- 下面仅涉及到修改过的参数;未提及内容保持默认设定
- Grafana 中的权限设定,有3种,分别是admin, editor, viewer。 作为对应, AD中分别新增3个域群组; 不同的域账号,依据权限分配,加到不同群组里,实现grafana登录授权。
- Grafana web UI里面,对于域账号的以上3种权限虽然可修改,但该最终权限,以域账号所属域群组为准,账号每次重新登录,会覆盖Web UI内的设定。
In [[servers.group_mappings]] you can map an LDAP group to a Grafana organization and role. These will be synced every time the user logs in, with LDAP being the authoritative source. So, if you change a user’s role in the Grafana Org. Users page, this change will be reset the next time the user logs in. If you change the LDAP groups of a user, the change will take effect the next time the user logs in.
7.1 修改grafana.ini文件,开启ldap认证功能。
Internet上的设定文件是 /usr/share/grafana/conf/defaults.ini, 但该设定文件中的ldap设定项,已经不适用于 Grafana v5.x版本。
v5.x版本中,开启ldap设定的配置文件、及设定项是:
/etc/grafana/grafana.ini
[auth.ldap]
enabled = true
config_file = /etc/grafana/ldap.toml
allow_sign_up = true
7.2 定义ldap各参数
/etc/grafana/ldap.toml
[[servers]]
host = "10.245.4.167 10.245.5.168"
bind_dn = "CN=zabbixCQ2,OU=CQ,OU=ServicesUsers,OU=ECMMSUsers,DC=ECMMS,DC=ORG"
bind_password = 'ORG123'
search_filter = "(sAMAccountName=%s)"
search_base_dns = ["OU=ECMMSUsers,DC=ECMMS,DC=ORG"]
[servers.attributes]
username = "sAMAccountName"
[[servers.group_mappings]]
group_dn = "CN=zabbixCQ-Grafana-A,OU=CQ,OU=ServicesUsers,OU=ECMMSUsers,DC=ECMMS,DC=ORG"
org_role = "Admin"
[[servers.group_mappings]]
group_dn = "CN=zabbixCQ-Grafana-E,OU=CQ,OU=ServicesUsers,OU=ECMMSUsers,DC=ECMMS,DC=ORG"
org_role = "Editor"
[[servers.group_mappings]]
group_dn = "CN=zabbixCQ-Grafana-V,OU=CQ,OU=ServicesUsers,OU=ECMMSUsers,DC=ECMMS,DC=ORG"
org_role = "Viewer"
来源:oschina
链接:https://my.oschina.net/u/3362827/blog/1806078