参考:http://fengxiaoli.blog.51cto.com/12104465/1954649

      http://fengxiaoli.blog.51cto.com/12104465/1954654


1.Zabbix客户端配置

[root@linux-node1 ~]# cat /tmp/user.sh

#!/bin/bash

uptime |awk '{print $4}'

[root@linux-node1 ~]# vim /etc/zabbix/zabbix_agentd.conf

UserParameter=login-user,/bin/bash /tmp/user.sh(可以跟脚本,可以跟命令,这里的login-uesrkey值,可以自己命名,不要和已有key冲突)

2.Zabbix服务端测试

[root@zabbix-server ~]#yum install -y zabbix-get

[root@zabbix-server ~]# zabbix_get -s 192.168.10.128 -k login-user

2


3.创建Items(监控的项)

wKiom1mJ3RmRlZeqAACd75t3Kf0633.png


wKioL1mJ3RqyQ8Q3AAFOS4uK2U8734.png


wKioL1mJ3RuTF_uyAACvm6mmSTY443.png

wKiom1mJ3Rzg499kAABPUkmJpiI462.png



4.创建Graphs

wKiom1mJ3o-gcIPLAACbi07colI283.png


wKioL1mJ3pDxnm0yAADCVkLKyz4386.png


wKiom1mJ3pCyXXeoAABCC2I4sbU811.png


wKiom1mJ3pGQJvbRAAB75IU9-gw484.png


5.创建触发器triggers(网页报警)

wKioL1mJ3zDTql-TAADaUGv4pYs726.png


wKioL1mJ3zGQCjpLAAGjxdvW6TE531.png


wKiom1mJ3zGiaZRKAABRXsSO12s105.png


wKioL1mJ3zKAWbFMAAAyneyzDm8959.png



6.邮件报警设置:action


wKiom1mJ37GSr9LpAACktyJ46dE980.png


wKiom1mJ37Gj9oLSAACXHJxCX_o811.png


wKioL1mJ37LjqsO-AAB9o_jZPSc493.png


wKiom1mJ37PwVcN7AAB_jbUqdgM767.png


wKioL1mJ37OAvyihAABxnflb3v4783.png



设置通过脚本发邮件

设置报警脚本路径

[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf

AlertScriptsPath=/usr/lib/zabbix/alertscripts

[root@zabbix-server ~]# cd /usr/lib/zabbix/alertscripts

[root@zabbix-server alertscripts]# cat sendmail.sh    实际这里应该写发送邮件脚本,这里进测试

echo "$1 $2 $3" >> /tmp/test如果/tmp/test出现内容则发送成功









wKiom1mJ4HSgF9uJAAC0Nnd4T7Q789.png


wKioL1mJ4HXwYi-1AABsMuB1YAA598.png


wKiom1mJ4HWQSMu-AADV49ktMn8416.png


wKioL1mJ4HbQwbzcAABHyvHYZ5g680.png


wKioL1mJ4HbQTcSRAABuJ3d0w0c969.png


wKiom1mJ4IehRhopAAA1cqdJr3M918.png


wKioL1mJ4Iiy-iiQAABscwHErps244.png


发送成功

[root@zabbix-server alertscripts]# cat /tmp/test

 Original event ID: 400*:*UNKNOWN*): *UNKNOWN* loginuser>2