1. Issue commands on the server side to the client side in batches:
//在zabbix服务端批量向client发送命令查看agent的进程:
[root@localhost ~]# ansible zabbix -m shell -a " ps -ef |grep zabbix_agent"
[root@localhost ~]# ansible zabbix -m shell -a "/etc/init.d/zabbix_agentd start"
[root@localhost ~]# vim /etc/ansible/ansible.cfg 编辑配置文件。
command_warnings = False
host_key_checking = False
Two, zabbix-agent email alert
1. What are the necessary components, operations and steps for configuring email alarms:
The server that sends the email (SMTP):
发送邮件的发件件人
接收邮件的收件人
发送邮件的标题,内容信息
满足触发器才发送邮件(服务异常,宕机)
Configure E-mail email alert:
1>Configure outgoing server and sender
alert —> Alarm media type —> E-mail configuration (Figure 1)
图一
2>Configure recipient
configuration ——> User ——> Admin ——> Alarm media (Figure 2)
图二
3>Send the subject of the email, content information, and send the email only when the trigger is satisfied (service abnormality, downtime)
Configuration ——> Action ——> Trigger ——> Report problems to Zabbix administrators ——> Action (Figure 3) — —> Operation (Picture 4) ——> Recovery Operation (Picture 5)
图三
图四
故障{TRIGGER.STATUS},服务器:{HOSTNAME1}发生: {TRIGGER.NAME}故障!
告警主机:{HOSTNAME1}
告警时间:{EVENT.DATE} {EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目:{TRIGGER.KEY1}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}
事件ID:{EVENT.ID}
图五
告警主机:{HOSTNAME1}
告警时间:{EVENT.DATE} {EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目:{TRIGGER.KEY1}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}
事件ID:{EVENT.ID}
[root@localhost ~]# while sleep 1;do ab -c 1000 -n 10000 http://127.0.0.1/done //Perform pressure test on http server
3. Environment:
192.168.1.59 is zabbix_server server
192.168.1.80 is Run zabbix-agent-nginx under docker container
1. Define a script by yourself, configure triggers, and detect nginx services: monitoring keywords: so the website monitoring keywords prove that the webpage has not been tampered with.
//在docker容器下运行一个nginx服务:
[root@localhost ~]# docker run -tid --net=none --name=centos7-nginx
> --privileged=true centos7-ssh:zabbix-agent /sbin/init
[root@localhost ~]# pipework br0 centos7-nginx 192.168.1.80/[email protected]
[root@localhost ~]# docker exec -it centos7-nginx /bin/bash
//安装nginx:
[root@localhost ~]# yum install epel-release -y
[root@localhost ~]# ll /etc/yum.repos.d/|grep -aw epel
[root@localhost ~]# yum install -y nginx
[root@localhost ~]# curl 192.168.1.80 //在zabbix server服务端测试
[root@localhost ~]# curl 192.168.1.80 |grep -oi welcome //查看有没有welcome字段
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4057 100 4057 0 0 1190k 0 --:--:-- --:--:-- --:--:-- 1980k
Welcome
[root@localhost ~]# curl -s 192.168.1.80 |grep -oi welcome //静默模式,可以用-s给盖掉
Welcome
[root@localhost ~]# curl -s 192.168.1.80 |grep -oic "welcome"
//反馈值为1;表示nginx这个页面关键词有这个代码1个,是2表示有2个。
1 //监控关键词证明我们网站代码没有被篡改。
//在客户端配置zabbix_agent nginx监控字段:
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=192.168.1.59
ServerActive=192.168.1.59
Hostname=192.168.1.80
UserParameter=check_nginx_word,/usr/bin/curl -s 192.168.1.80 |grep -oic "welcome"
//后面的结果可以传递给key值
[root@557c120d5b48 ~]# /etc/init.d/zabbix_agentd restart
[root@localhost bin]# /usr/local/zabbix/bin/zabbix_get -s 192.168.1.80 -k check_nginx_word
1 //在服务端调用key值
Add hosts, monitoring items, and triggers on the front-web platform.
2. Configure ——> Host ——> Select 192.168.1.80 ——> Create monitoring item (Figure 1)
图一
3. There is no nginx graphic at the moment,
configuration -> host -> select 192.168.1.80 -> graphic -> create graphic (Figure 2) -> detect -> graphic -> you can see the nginx key Word monitoring (display data is 1)
图二:
You can change the number of welcome fields in this directory to test monitoring data.
[root@557c120d5b48 nginx]# vim /usr/share/nginx/html/index.html
4. There is still no alarm at this moment, we need to configure the trigger:
Configure ——> Host ——> Select 192.168.1.80 ——> Create trigger
When the value of welcome in nginx is 0, an alarm is triggered and an email is received.