Zabbix


Zabbix

环境

Zabbix server: Centos7 192.168.106.201

被监控端:Win7 192.168.106.3 Centos 192.168.106.2

监控服务端

脚本

#!/bin/bash

#安装zabbix源、aliyun YUM源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

#安装zabbix 
yum install -y zabbix-server-mysql zabbix-web-mysql

#安装启动 mariadb数据库
yum install -y  mariadb-server
systemctl start mariadb.service

#创建数据库
mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";'

#导入数据
zcat /usr/share/doc/zabbix-server-mysql-3.0.13/create.sql.gz|mysql -uzabbix -pzabbix zabbix

#配置zabbixserver连接mysql
sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf

#添加时区
sed -i.ori '18a php_value date.timezone  Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf

#解决中文乱码
yum -y install wqy-microhei-fonts
\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

#启动服务
systemctl start zabbix-server
systemctl start httpd

#写入开机自启动
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start mariadb.service
systemctl start httpd
systemctl start zabbix-server
EOF

#输出信息
echo "浏览器访问 http://`hostname -I|awk '&#123;print $1&#125;'`/zabbix"

若80端口被占用 修改/etc/httpd/conf/httpd.conf

注意SElinux和firewalld关闭状态

yum install zabbix-agent -y

systemctl start zabbix-agent监控服务端

zabbix is not running报错是因为selinux没关闭

setenforce 0或/etc/selinux/config修改SELINUX=”disabled”

被监控端Win17

打通虚拟机和主机的网络:route add 192.168.106.0 mask 255.255.255.0 192.168.106.1

官网跳转 下载相应版本Zip

修改conf文本

LogFile=D:\zabbix_agentd.log
Server=192.168.106.201                                            //zabbix服务端的ip地址
ServerActive=192.168.106.201
Hostname=192.168.106.3                                           //windows客户机的ip地址
D:\zabbix\bin\zabbix_agentd.exe -c D:\zabbix\conf\zabbix_agentd.conf -i  //安装
D:\zabbix\bin\zabbix_agentd.exe -c D:\zabbix\conf\zabbix_agentd.conf -s  //启动,-d是卸载

关闭防火墙

在服务端测试连通性zabbix_get -s 192.168.106.3 -p 10050 -k “system.cpu.load[all,avg1]

被监控端Centos

rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

yum install zabbix-agent

vi /etc/zabbix/zabbix_agentd.conf修改

Server=192.168.106.201     //安装zabbix服务端的机器的IP
ServerActive=192.168.106.201 //安装zabbix服务端的机器的IP
Hostname=Centos          //主机名

开启服务systemctl start zabbix-agent


文章作者: Ricechips
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Ricechips !
 上一篇
Centos7.7-minimal-kvm Centos7.7-minimal-kvm
Centos的图形化界面确实容易崩溃,操作一快就直接卡死,行吧,只能放弃平易近人的桌面,完全用黑乎乎的命令行操作了。环境 host机:centos7.7(minimal) kvm虚拟化 虚机:win7 u盘安装centos 这一步跟我
2020-08-20 Ricechips
下一篇 
Linux Linux
Linux查找vi内固定行ctrl + g 显示行数 命令模式 :n (n)为想要跳转的行数 系统加载进度条消失之术 静态ip网络配置/etc/sysconfig/network-scripts/ 找到网卡 编辑 dhcp->st
2020-08-20 Ricechips
  目录