zabbix deployment server may refer to: https://blog.51cto.com/14227204/2474670
NOTE: This is based on the link
First, install Zabbix agent end
where I started as a 192.168.171.134 IP server to act as agent for the end
[root@agent /]# mkdir /zabbix # 个人习惯,可忽略
[root@agent /]# cd /zabbix/
[root@agent /]# rz
[root@agent zabbix]# tar zxf zabbix-3.2.1.tar.gz
[root@agent zabbix]# cd zabbix-3.2.1/
[root@agent zabbix-3.2.1]# useradd -M -s /sbin/nologin zabbix
[root@agent zabbix-3.2.1]# ./configure --prefix=/usr/local/zabbix --enable-agent && make && make install
[root@agent zabbix-3.2.1]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@agent /]# sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
[root@agent /]# sed -i 's/PIDFILE=\/tmp\/$BINARY_NAME.pid/PIDFILE=$BASEDIR\/logs\/$BINARY_NAME.pid/g' /etc/init.d/zabbix_agentd
[root@agent /]# chmod +x /etc/init.d/zabbix_agentd
[root@agent /]# sed -i 's/# PidFile=\/tmp\/zabbix_agentd.pid/PidFile=\/usr\/local\/zabbix\/logs\/zabbix_agentd.pid/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/LogFile=\/tmp\/zabbix_agentd.log/LogFile=\/usr\/local\/zabbix\/logs\/zabbix_agentd.log/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/Server=127.0.0.1/Server=192.168.171.133/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/# ListenPort=10050/ListenPort=10050/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.171.133/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/Hostname=Zabbix server/Hostname=192.168.171.134/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/# Timeout=3/Timeout=15/g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# sed -i 's/# Include=\/usr\/local\/etc\/zabbix_agentd.conf.d\//Include=\/usr\/local\/zabbix\/etc\/zabbix_agentd.conf.d\//g' /usr/local/zabbix/etc/zabbix_agentd.conf
[root@agent /]# egrep -v '^$|^#' /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Server=192.168.171.133
ListenPort=10050
ServerActive=192.168.171.133
Hostname=192.168.171.134
Timeout=15
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
[root@agent /]# mkdir -p /usr/local/zabbix/logs # 创建日志存放路径
[root@agent /]# chown -R zabbix:zabbix /usr/local/zabbix/ # 赋予权限
[root@agent /]# /etc/init.d/zabbix_agentd start # 启动agent
Reloading systemd: [ OK ]
Starting zabbix_agentd (via systemctl): [ OK ]
Second, the login web interface add the host agent
Log on to Zabbix server end the following operations, monitor the configured agent just end
three, Zabbix monitoring MySQL database
following operations can be carried out at the end of the new agent configuration
#复制Zabbix提供的MySQL监控脚本
[root@agent /]# cd /zabbix/zabbix-3.2.1/conf/zabbix_agentd/
[root@agent zabbix_agentd]# cp userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/
[root@agent zabbix_agentd]# cd /usr/local/zabbix/etc/
[root@agent etc]# cat > .my.cnf << EOF
> [client]
> host=192.168.171.134
> user=test
> password=123.com
> socket=/usr/local/mysql/mysql.sock
> EOF
[root@agent etc]# cd /usr/local/zabbix/etc/zabbix_agentd.conf.d/
[root@agent zabbix_agentd.conf.d]# sed -i 's/mysql -N/\/usr\/local\/bin\/mysql -N/g' userparameter_mysql.conf
[root@agent zabbix_agentd.conf.d]# sed -i 's/mysql -V/\/usr\/local\/bin\/mysql -V/g' userparameter_mysql.conf
[root@agent zabbix_agentd.conf.d]# sed -i 's/mysqladmin ping/\/usr\/local\/bin\/mysqladmin ping/g' userparameter_mysql.conf
[root@agent zabbix_agentd.conf.d]# sed -i 's/HOME=\/var\/lib\/zabbix/HOME=\/usr\/local\/zabbix\/etc\//g' userparameter_mysql.conf
[root@agent zabbix_agentd.conf.d]# /etc/init.d/zabbix_agentd restart
Restarting zabbix_agentd (via systemctl): [ OK ]
[root@agent /]# mysql -u root -p123
mysql> grant all on *.* to test@'192.168.171.%' identified by '123.com';
Zabbix-servre test whether the end state can be collected MySQL agent terminal:
[root@zabbix /]# zabbix_get -s 192.168.171.134 -p 10050 -k "mysql.status[Uptime]"
643
#在server端执行上述命令可以看到的数字,就是数据库相关的状态
Zabbix back to the web page, add the MySQL database monitoring template
Fourth, configure mail alert
all of the following operations need to be configured in Zabbix server end
[root@zabbix /]# yum -y install perl-Net-SSLeay perl-IO-Socket-SSL
[root@zabbix ~]# tar zxf /zabbix/sendEmail-v1.56.tar.gz -C /usr/src/
[root@zabbix ~]# cp /usr/src/sendEmail-v1.56/sendEmail /usr/local/bin/
[root@zabbix ~]# chown zabbix:zabbix /usr/local/bin/sendEmail
[root@zabbix ~]# vim /usr/local/bin/sendEmail
if (! IO::Socket::SSL->start_SSL($SERVER)) {
#切到1906行,修改为上述所示
The next step is to configure the mail:
generating an authorization code, there are secret security comrades he will let you send a text message for identification
#在zabbix-server端上配置
[root@zabbix /]# cd /usr/local/zabbix/share/zabbix/alertscripts/
[root@zabbix alertscripts]# vim SendEmail.sh
#!/bin/bash
to=$1
subject=$2
body=$3
/usr/local/bin/sendEmail -o tls=auto -f [email protected] -t "$to" -s smtp.qq.com -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu [email protected] -xp wrsxyidhdokobdah -m "$body"
#各项解释如下:
# /usr/local/bin/sendEmail:命令主程序;
# -f [email protected] :发件人邮箱
# -t [email protected] :收件人邮箱
# -s smtp.126.com :发件人邮箱的 smtp 服务器
# -u "我是邮件主题" :邮件的标题
#-o message-content-type=html:邮件内容的格式,html 表示它是 html 格式
# -o message-charset=utf8:邮件内容编码
# -xu [email protected]:发件人邮箱的用户名
# -xp WEE78@12l$ #发件人邮箱授权码(就是我刚刚生成的那个授权码)
# -m "我是邮件内容" :邮件的具体内容
#测试是否可以成功发送邮件
[root@zabbix alertscripts]# sh SendEmail.sh [email protected] test 123456
Mar 06 18:04:11 zabbix sendEmail[4604]: Email was sent successfully!
Back to the web interface, adding media alarm
will alert the user to associate the media
to create a trigger action
configuration triggers
alarm test:
The zabbix_agent end server agent process is closed, it means that the mailbox can receive mail is configured correctly.
#在agent服务器进行以下操作
[root@agent ~]# /etc/init.d/zabbix_agentd stop #关闭agent进程
Here we can see that a mailbox has received an alarm message:
5, configuration enterprise micro-channel alarm
1, to create applications:
Once the application is successfully created, the application will display the information as follows:
the focus of this record in the above application and Agent Secret, so that later used in the configuration.
View company ID, sector ID, user account information:
Enterprise ID:
department ID:
user:
the information above to view, one would have to use
[root@zabbix /]# cd /usr/local/zabbix/share/zabbix/alertscripts/
[root@zabbix alertscripts]# wget https://www.ixdba.net/zabbix/weixin_linux_amd64
[root@zabbix alertscripts]# mv weixin_linux_amd64 weixin
[root@zabbix alertscripts]# chmod 755 weixin #赋予执行权限
[root@zabbix alertscripts]# echo "AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts" >> /usr/local/zabbix/etc/zabbix_server.conf
#向Zabbix主配置文件中追加上述内容
#测试这个脚本是否可用,执行下面的命令(需要修改相应的值):
./weixin --corpid=ww4b98220b16519a8d --corpsecret=oXQVxXF3TzBK1DyJuKHRJb90MIkiCcpVvF7WfaaCx0g --msg="微.告警测试"--user=ZhangYaZhuang --agentid=1000003
{"errcode":0,"errmsg":"ok","invaliduser":""}
#需要修改的内容如下:
# corpid=企业号里面的企业ID;
# corpsecret:这里就是我们自建应用里面的Secret的ID;
# agentid:我们自建应用里面的AgentId;
# msg:要发送的消息内容;
# user:我们接受消息的用户账号,注意是在微信企业号里面成员详情页的账号;
After machining, no error, then we can receive the signal on the micro-enterprise alarms this command, the following:
Log in to the web interface, create a micro-channel alarm media
related to Zabbix user management:
Note that the above set of recipients, the recipient is in the micro-letter Enterprise background, the following members of the address book to see details of the account, must not wrong
configuration actions
服务器:{HOST.NAME}发生:{TRIGGER.NAME}故障
告警主机:{HOST.NAME}
告警地址:{HOST.IP}
监控项目:{ITEM.NAME}
监控取值:{ITEM.LASTVALUE}
告警等级:{TRIGGER.SEVERITY}
当前状态:{TRIGGER.STATUS}
告警信息:{TRIGGER.NAME}
告警时间:{EVENT.DATE} {EVENT.TIME}
事件ID:{EVENT.ID}
After the addition is as follows:
configure the recovery operation:
the test micro-channel alarm functions:
#在agent进行以下操作,以便模拟故障
[root@agent ~]# /etc/init.d/zabbix_agentd stop
After closing agent, and later in the micro-enterprise communication terminal (also receive mail) to receive the following message:
Next, start the agent, and test restore operations: