zabbix安装使用

  • 命令行查看系统:内存,磁盘
内存使用查看(tot, use, free):  	free -k |awk '/Mem/{print $2,$3,$4}'
磁盘使用(tot,use,free ):		df -kP |awk '/^\/dev/ {tot+=$2; use+=$3; free+=$4}END{print tot","use","free}'

#yum -y install sysstat: /usr/bin/sar, /usr/bin/iostat
cpu使用率:						sar -u 1 1 |awk '/Average/{print 100-$NF}'
磁盘读写:(read, write):		iostat -dk |awk '/^[hs]d[a-z]/{read+=$3; write+=$4; count+=1} END{print read/count,write/count}'

1,安装zabbix

a, CentOS7

# 1,准备lamp环境
yum -y install httpd mariadb-server php php-mysql php-gd php-ldap php-mbstring 
# 2,按照指南,安装zabbix
rpm -Uvh https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

# 3,配置mysql数据库: root用户连接maraidb默认没有密码
systemctl start httpd mariadb
mysql -e "create database zabbix character set utf8"
mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'"
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix 
# 4,修改配置文件: 
#/etc/zabbix/zabbix_server.conf  = => DBPassword=zabbix
#/etc/httpd/conf.d/zabbix.conf   = => php_value date.timezone=Asia/Shanghai

# 5,启动服务
systemctl restart httpd zabbix-server zabbix-agent 
systemctl enable  httpd zabbix-server zabbix-agent mariadb

# 6,访问zabbix web页面: http://server_ip_or_name/zabbix , 用户名密码:admin/zabbix

b, CentOS6

[root@test-c6 ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-deprecated]
name=Zabbix Official Repository deprecated - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/6/$basearch/deprecated
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[root@test-c6 ~]# cat /etc/yum.repos.d/webtatic.repo
[webtatic]
name=Webtatic Repository EL6 - $basearch
#baseurl=https://repo.webtatic.com/yum/el6/$basearch/
mirrorlist=https://mirror.webtatic.com/yum/el6/$basearch/mirrorlist
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el6

#安装php5.5+: https://blog.csdn.net/eyeofeagle/article/details/104472216
[root@test-c6 ~]# tail /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time= 300
post_max_size = 32M
max_input_time = 300
memory_limit = 128M
mbstring.func_overload =2
mbstring.func_overload = 1

2,zabbix配置主机监控

a, 添加cent6主机

Configuration --> Hosts --> 右上角:Create Host–> 填写参数,点击最后的Add按钮
在这里插入图片描述

b, 添加该主机的监控项:application, item, trigger

回到Configuration --> Hosts 页面,在该主机展示栏目中添加application, item
在这里插入图片描述

回到Configuration --> Hosts 页面,在该主机展示栏目中添加trigger
在这里插入图片描述

c, 添加该主机的action:发送邮件

I, 邮箱设置: 生成授权码,开启smtp服务

设置–> 客户端授权密码: (手机发送短信),设置第三方客户端的用户密码(如: 123123)
在这里插入图片描述

II, 添加action, 发送邮件

回到Administration --> Media types 页面–> 右上角:Create media type
(注:此处输入的邮箱密码是 --刚才邮箱设置的 ‘客户端授权密码’ )
在这里插入图片描述
回到Configuration --> Actions 页面— > 右上角:New Action
(设置action名称: 比如packets to much >5)
(Conditions 项:关联到哪个 item)
(Operations项: 关联发送邮箱)
在这里插入图片描述
在这里插入图片描述

3,测试

说明:在zabbix-server端(192.168.56.77) 发送ping 报文给被监控主机192.168.56.66

[root@c7 ~]# ping -c 10000 -i 0.01 192.168.56.66
64 bytes from 192.168.56.66: icmp_seq=6199 ttl=64 time=0.350 ms
.....

a, 观察zabbix事件

在这里插入图片描述
在这里插入图片描述

b, 查看邮件内容

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

根哥的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值