centos6 7 zabix grafana安装配置

centos6 7 zabix grafana安装配置一 安装 zabbix0 关闭 selinuxvim etc selinux configSELINU disabled 设置后需要重启才能生效 shell gt setenforce0 临时关闭 shell gt getenforce 检测 selinux 状态 1 Zabbix 在 CentOS 基本源里不可获得或者获得到的都是老版本的 因此必须配置 Zabbix 官方 r

一.安装zabbix

0.关闭selinux

vim /etc/selinux/config
SELINUX=disabled

设置后需要重启才能生效

shell > setenforce 0 #临时关闭 shell > getenforce 检测selinux状态

1.Zabbix在CentOS基本源里不可获得或者获得到的都是老版本的,因此必须配置Zabbix官方repository,可按官网步骤配置

https://www.zabbix.com/download?zabbix=4.0&os_distribution=centos&os_version=7&db=MySQL

rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

2.安装zabbix

yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

3.配置zabbix数据库

用于zabbix存储一些监测数据

mysql> create database zabbix character set utf8; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) mysql> grant all privileges on zabbix.* to 'zabbix'@'10.130.161.21(你服务器的IP)' identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

导入数据库

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

4.配置zabbix server配置

shell > vim /etc/zabbix/zabbix_server.conf

其中需修改数据库相关的配置

DBHost=10.130.161.21 DBName=zabbix DBUser=zabbix DBPassword=zabbix DBPort=3306

5.配置zabbix agent配置

被检测客户端配置

shell > vim /etc/zabbix/zabbix_agentd.conf

配置监测服务所在地址

Server=10.130.161.21 #zabbix-server服务器IP地址 ServerActive=10.130.161.21 #zabbix-server服务器IP地址 Hostname=Zabbix server #当前服务器显示名 

6.设置httpd时区

vim /etc/httpd/conf.d/zabbix.conf
Alias /zabbix /usr/share/zabbix <Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Require all granted <IfModule mod_php5.c> php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value max_input_vars 10000 php_value always_populate_raw_post_data -1 php_value date.timezone Asia/Shanghai </IfModule> </Directory> <Directory "/usr/share/zabbix/conf"> Require all denied </Directory> <Directory "/usr/share/zabbix/app"> Require all denied </Directory> <Directory "/usr/share/zabbix/include"> Require all denied </Directory> <Directory "/usr/share/zabbix/local"> Require all denied </Directory>

7.开启zabbix

启动zabbix server

shell > systemctl enable zabbix-server #将zabbix设为开机启动 shell > systemctl start zabbix-server #启动zabbix shell > systemctl status zabbix-server #查看zabbix是否运行

启动客户端

shell > systemctl enable zabbix-agent shell > systemctl start zabbix-agent shell > systemctl status zabbix-agent

centos 6上的客户端启动方式

/etc/init.d/zabbix-agent start

8.zabbix web配置

检查包的完整性和参数配置

centos6 7 zabix grafana安装配置

zabbix数据库配置

centos6 7 zabix grafana安装配置

server 相关配置

centos6 7 zabix grafana安装配置

预安装摘要

centos6 7 zabix grafana安装配置

完成配置

centos6 7 zabix grafana安装配置

9.配置zabbix监控

监控配置页面

centos6 7 zabix grafana安装配置

可以在这个地方更改为中文

centos6 7 zabix grafana安装配置

shell > mv graphfont.ttf graphfont.ttf.bak #把graphfont.ttf备份 shell > mv simkai.ttf graphfont.ttf #把simkai.ttf 改名为graphfont.ttf

然后刷新下网页就可以了

在配置->主机,添加要监控的主机

centos6 7 zabix grafana安装配置

在模板子类下配置规则,这里选择Template OS Linux和Template App Zabbix Server就会监控cpu,内存,硬盘,网络信息,选择完成后,点击添加,更新,才能完成

centos6 7 zabix grafana安装配置

在监测中->图形页面中选择要查看的机器、参数和时间,来查看具体的参数值

centos6 7 zabix grafana安装配置

二.安装Grafana

1.下载

shell > wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.4-1.x86_64.rpm shell > sudo yum -y localinstall grafana-5.2.4-1.x86_64.rpm

2.修改配置

vim /etc/grafana/grafana.ini

在文件底部加上

[dashboards.json] enabled = true path = /var/lib/grafana/dashboards

3.安装Percona仪表盘(本人安装后没有什么用,大家可以试一下)

shell > git clone https://github.com/percona/grafana-dashboards.git shell > cp -r grafana-dashboards/dashboards /var/lib/grafana shell > sed -i 's/expr=\(.\)\.replace(\(.\)\.expr,\(.\)\.scopedVars\(.*\)var \(.\)=\(.\)\.interval/expr=\1.replace(\2.expr,\3.scopedVars\4var \5=\1.replace(\6.interval, \3.scopedVars)/' /usr/share/grafana/public/app/plugins/datasource/prometheus/datasource.ts shell > sed -i 's/,range_input/.replace(\/"{\/g,"\\"").replace(\/}"\/g,"\\""),range_input/; s/step_input:""/step_input:this.target.step/' /usr/share/grafana/public/app/plugins/datasource/prometheus/query_ctrl.ts

 

4.启动grafana

centos7

shell > systemctl enable grafana-server shell > systemctl start grafana-server shell > systemctl status grafana-server

centos6

shell > service grafana-server start

5.访问grafana

可以通过http://你的IP:3000 访问grafana,默认用户名密码为:admin/admin

6.安装zabbix插件

centos6 7 zabix grafana安装配置

按插件中的提示安装插件

shell > grafana-cli plugins install alexanderzobnin-zabbix-app

7.配置zabbix数据源

在grafana侧边栏中找到datasource进行配置,具体配置信息如下:其中url那一栏是通用的(http://你的IP/zabbix/api_jsonrpc.php)

centos6 7 zabix grafana安装配置

centos6 7 zabix grafana安装配置

点击save & Test之后提示success表示成功

点击Settings旁边的Dashboards页签,看到两项都点击import

centos6 7 zabix grafana安装配置

8.添加具体监控

点击Dashboards页签上的Zabbix Template Linux Server,进入展示面板,里面的信息不全,我们需要通过点击Add Panel图标,来添加新的监控数据

centos6 7 zabix grafana安装配置

在添加好的panel中点击标题中的Edit进点编辑

centos6 7 zabix grafana安装配置

在Metrics页签中,数据源选Zabbix Server,Group选$group,Host选$host,这两项是为了自适应面板上多个服务器的监控数据,Application有下拉列表选技具体的监控项,Item里选具体的监控参数,Item里可以填正则表达式,例如:/memory/表示所有的带memory字段的监控参数;在General页签里设置标题,

centos6 7 zabix grafana安装配置

在Axes页签里设置x,y轴的参数,其中unit是设置显示的单位

centos6 7 zabix grafana安装配置

都设置好后,记得点击右上角的保存图标,就大功告成了

三、配置好看的仪表盘

centos6 7 zabix grafana安装配置

上图中的仪表盘主要是grafana中的singlestat控制板实现的

1.首先,添加singlestat面板,添加仪表板名称等

centos6 7 zabix grafana安装配置

2.配置数据源(此处数据源为zabbix中自定义的数据源,之后会讲到)

centos6 7 zabix grafana安装配置

3.配置图形显示

centos6 7 zabix grafana安装配置

3.文本映射

centos6 7 zabix grafana安装配置

值/范围到文本映射允许您将汇总数据的值转换为显式文本,此处基本上是默认的,不需要变更

仪表板配置参考网址:https://www.jianshu.com/p/a7a9f2d02a4b

 

四、zabbix自定义数据源

此处主要用于cpu使用率等zabbix中没有的数据,并且只能使用现有的zabbix中提供的数据源计算获得,以cpu使用率举例:

依次选择配置-》模板-》Template OS Linux-》监控项

centos6 7 zabix grafana安装配置

点击右上角创建监控项

centos6 7 zabix grafana安装配置

下面是具体配置项

centos6 7 zabix grafana安装配置

其中名称和键值就是最终在grafana数据源里选择的时候显示的名字,公式那一栏是根据其它监控项计算得出来的,例如:system.cpu.util[,idle]就是指cpu的空闲时间

centos6 7 zabix grafana安装配置

公式中,last是指相应key值最后一次的监控值,公式中不能有空格

最后点击更新即可

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233310.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • python decode函数的用法_decode函数的用法

    python decode函数的用法_decode函数的用法DECODE函数是ORACLEPL/SQL是功能强大的函数之一,目前还只有ORACLE公司的SQL提供了此函数,其他数据库厂商的SQL实现还没有此功能。DECODE有什么用途呢?先构造一个例子,假设我们想给智星职员加工资,其标准是:工资在8000元以下的将加20%;工资在8000元以上的加15%,通常的做法是,先选出记录中的工资字段值?selectsalaryintovar-salar…

    2022年7月25日
    8
  • sql 分页

    sql 分页//查询所有publicList<products>getAll(intpageNo,intcount){System.out.println(pageNo+";&qu

    2022年7月2日
    29
  • DB破解(暗黑破坏神辅助)使用方法「建议收藏」

    DB破解(暗黑破坏神辅助)使用方法「建议收藏」下载网址:http://www.mochafuzhu.com/forum.php?mod=forumdisplay&amp;fid=57开始请先在网站里下载运行环境并安装,然后下载辅助。(Q群:528411948)1、首先,一定要先 启动游戏,注意!辅助的路径千万不要有中文的目录,否则会造成辅助自动退出的问题。然后解压下载好辅助后,我们得到以下画面,以管理员身份运行打开。(如果不能打开请检…

    2022年5月5日
    68
  • opencv之打开摄像头、边缘检测

    按q退出if__name__==’__main__’:cap=cv2.VideoCapture(0)#设置摄像头0是默认的摄像头如果你有多个摄像头的话呢,可以设置1,2,3….whileTrue:#进入无限循环ret,frame=cap.read()#将摄像头拍到的图像作为frame值cv2….

    2022年4月7日
    46
  • Windows查看端口占用情况_windows关闭端口命令

    Windows查看端口占用情况_windows关闭端口命令步骤1.win+R快捷键启动运行,输入cmd命令,打开小黑窗口2.在命令窗口中输入“netstat-ano”命令,回车,就可看到系统当前所有端口的占用情况3.输入“netstat-ano|findstr“端口号””命令,回车,就可以看到指定端口的占用情况……

    2022年7月27日
    7
  • 开学几天了,还没有进入状态,继续努力

    开学几天了,还没有进入状态,继续努力

    2021年7月21日
    73

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号