{"id":584,"date":"2022-09-17T13:41:37","date_gmt":"2022-09-17T05:41:37","guid":{"rendered":"https:\/\/www.jchj.top\/?p=584"},"modified":"2025-09-26T11:27:01","modified_gmt":"2025-09-26T03:27:01","slug":"zabbix%e9%82%ae%e4%bb%b6%e6%8a%a5%e8%ad%a6","status":"publish","type":"post","link":"https:\/\/www.jchj.top\/?p=584","title":{"rendered":"zabbix\u90ae\u4ef6\u62a5\u8b66"},"content":{"rendered":"\n<p><strong>\u5b9a\u4e49\u95ee\u9898\u6545\u969c\u89e6\u53d1\u5668<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2238\" height=\"1611\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/1-12.png\" alt=\"\" class=\"wp-image-585\"\/><\/figure>\n\n\n\n<p><strong>\u4e00:web\u7aef\u8bbe\u7f6e\u62a5\u8b66<\/strong><\/p>\n\n\n\n<p>\u00a01: \u00a0\u8bbe\u7f6e\u62a5\u8b66\u63a5\u6536\u90ae\u7bb1<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2237\" height=\"1344\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/2-12.png\" alt=\"\" class=\"wp-image-586\"\/><\/figure>\n\n\n\n<p>2\uff1a\u914d\u7f6e\u62a5\u8b66\u53d1\u9001\u90ae\u7bb1<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/3-12.png\" alt=\"\" class=\"wp-image-587\" width=\"840\" height=\"395\"\/><\/figure>\n\n\n\n<p>3\uff1a\u914d\u7f6e\u62a5\u8b66\u5185\u5bb9\u53ca\u64cd\u4f5c\u7ec6\u8282<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2242\" height=\"1599\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/4-12.png\" alt=\"\" class=\"wp-image-588\"\/><\/figure>\n\n\n\n<p>4\uff1a\u90ae\u4ef6\u62a5\u8b66\u6d88\u606f\u5185\u5bb9\u53ca\u8868\u7684\u8868\u8fbe\u5f0f\u3002<\/p>\n\n\n\n<p><strong>\u6545\u969c{TRIGGER.STATUS},\u670d\u52a1\u5668\u540d:{HOSTNAME1}\u53d1\u751f: {TRIGGER.NAME}\u6545\u969c!<\/strong><\/p>\n\n\n\n<p>\u544a\u8b66\u4e3b\u673a:{HOSTNAME}<\/p>\n\n\n\n<p>\u544a\u8b66\u4e3b\u673aIP\u5730\u5740:{HOST.IP}<\/p>\n\n\n\n<p>\u544a\u8b66\u65f6\u95f4:{EVENT.DATE} {EVENT.TIME}<\/p>\n\n\n\n<p>\u544a\u8b66\u7b49\u7ea7:{TRIGGER.SEVERITY}<\/p>\n\n\n\n<p>\u544a\u8b66\u4fe1\u606f: {TRIGGER.NAME}<\/p>\n\n\n\n<p>\u544a\u8b66\u9879\u76ee:{TRIGGER.KEY1}<\/p>\n\n\n\n<p>\u95ee\u9898\u8be6\u60c5:{ITEM.NAME}:{ITEM.VALUE}<\/p>\n\n\n\n<p>\u5f53\u524d\u72b6\u6001:{TRIGGER.STATUS}:{ITEM.VALUE1}<\/p>\n\n\n\n<p><strong>\u6062\u590d{TRIGGER.STATUS}, \u670d\u52a1\u5668\u540d:{HOSTNAME1}: {TRIGGER.NAME}\u5df2\u6062\u590d!<\/strong><\/p>\n\n\n\n<p>\u544a\u8b66\u4e3b\u673a:{HOSTNAME}<\/p>\n\n\n\n<p>\u544a\u8b66\u4e3b\u673aIP\u5730\u5740:{HOST.IP}<\/p>\n\n\n\n<p>\u544a\u8b66\u65f6\u95f4:{EVENT.DATE} {EVENT.TIME}<\/p>\n\n\n\n<p>\u544a\u8b66\u7b49\u7ea7:{TRIGGER.SEVERITY}<\/p>\n\n\n\n<p>\u544a\u8b66\u4fe1\u606f: {TRIGGER.NAME}<\/p>\n\n\n\n<p>\u544a\u8b66\u9879\u76ee:{TRIGGER.KEY1}<\/p>\n\n\n\n<p>\u95ee\u9898\u8be6\u60c5:{ITEM.NAME}:{ITEM.VALUE}<\/p>\n\n\n\n<p>\u5f53\u524d\u72b6\u6001:{TRIGGER.STATUS}:{ITEM.VALUE1}<\/p>\n\n\n\n<p><strong>\u544a\u8b66\u4e3b\u673a:{HOST.NAME}<\/strong><\/p>\n\n\n\n<p>\u544a\u8b66\u5730\u5740:{HOST.IP}<\/p>\n\n\n\n<p>\u76d1\u63a7\u9879\u76ee:{ITEM.NAME}<\/p>\n\n\n\n<p>\u76d1\u63a7\u53d6\u503c:{ITEM.LASTVALUE}<\/p>\n\n\n\n<p>\u544a\u8b66\u7b49\u7ea7: {TRIGGER.SEVERITY}<\/p>\n\n\n\n<p>\u5f53\u524d\u72b6\u6001:{TRIGGER.STATUS}<\/p>\n\n\n\n<p>\u544a\u8b66\u4fe1\u606f:{TRIGGER.NAME}<\/p>\n\n\n\n<p>\u544a\u8b66\u65f6\u95f4:{EVENT.DATE} &#8211; &nbsp;{EVENT.TIME}<\/p>\n\n\n\n<p>\u6062\u590d\u65f6\u95f4:{EVENT.RECOVERY.DATE} &#8211; {EVENT.RECOVERY.TIME}<\/p>\n\n\n\n<p>\u6301\u7eed\u65f6\u95f4:{EVENT.AGE}<\/p>\n\n\n\n<p>\u4e8b\u4ef6ID:{EVENT.ID}<\/p>\n\n\n\n<p><strong>\u4e8c:\u4f7f\u7528\u90ae\u4ef6\u811a\u672c\u62a5\u8b66<\/strong><\/p>\n\n\n\n<p>1\uff1a\u73af\u5883\u53ca\u8f6f\u4ef6\u7248\u672c<\/p>\n\n\n\n<p>&nbsp;centos 7.6 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mailx-12.5-19.el7.x86_64<\/p>\n\n\n\n<p>[root@localhost ~]# yum list |grep mailx<\/p>\n\n\n\n<p>[root@localhost \/]# yum -y install sendmail<\/p>\n\n\n\n<p>[root@localhost \/]# yum install mailx -y<\/p>\n\n\n\n<p>[root@localhost \/]# vim \/etc\/mail.rc \u7f16\u8f91\u6587\u4ef6\u5728\u6700\u540e\u4e00\u884c\u6dfb\u52a0\u5982\u6b64\u51e0\u4e2a\u8bbe\u7f6e<\/p>\n\n\n\n<p>set from=<a href=\"mailto:whjchkj@163.com\">xxxxx@163.com<\/a><\/p>\n\n\n\n<p>set smtp=smtps:\/\/smtp.163.com<\/p>\n\n\n\n<p>set smtp-auth-user=<a href=\"mailto:whjchkj@163.com\">xxxxx@163.com<\/a><\/p>\n\n\n\n<p>set smtp-auth-password=UXKJFQDIVJAFHUAT<\/p>\n\n\n\n<p>set smtp-auth=login<\/p>\n\n\n\n<p>\u6d4b\u8bd5\u90ae\u4ef6\u62a5\u5982\u4e0b\u9519<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"668\" height=\"85\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/5-12.png\" alt=\"\" class=\"wp-image-589\"\/><\/figure>\n\n\n\n<p>\u914d\u7f6e\u90ae\u4ef6\u670d\u52a1\u5668\uff0c\u56e0\u4e3a25\u7aef\u53e3(\u90ae\u4ef6\u9ed8\u8ba4\u53d1\u9001\u7aef\u53e3)\u7ba1\u63a7\u6bd4\u8f83\u4e25\u683c\uff0c\u6240\u4ee5\u76f4\u63a5\u4f7f\u7528465\u7aef\u53e3<\/p>\n\n\n\n<p>\u751f\u6210SSL\u81ea\u7b7e\u540d\u8bc1\u4e66<\/p>\n\n\n\n<p>[root@localhost \/]# mkdir -p \/root\/.zabbix_163 &nbsp;&nbsp;&nbsp;&nbsp;\u521b\u5efa\u8bc1\u4e66\u76ee\u5f55<\/p>\n\n\n\n<p>[root@localhost \/]# echo -n|openssl s_client -connect smtp.163.com:465|sed -ne &#8216;\/-BEGIN CERTIFICATE-\/,\/-END CERTIFICATE-\/p&#8217; > ~\/.zabbix_163\/163.crt \u00a0\u00a0\u00a0\u00a0\u751f\u6210\u8bc1\u4e66<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1495\" height=\"166\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/6-11.png\" alt=\"\" class=\"wp-image-590\"\/><\/figure>\n\n\n\n<p>[root@localhost \/]# certutil -A -n &#8220;GeoTrust SSL CA&#8221; -t &#8220;C,,&#8221; -d ~\/.zabbix_163 -i ~\/.zabbix_163\/163.crt &nbsp;&nbsp;&nbsp;\u6dfb\u52a0\u8bc1\u4e66\u81f3SSL\u8bc1\u4e66\u5e93\u4e2d<\/p>\n\n\n\n<p>[root@localhost \/]# certutil -A -n &#8220;GeoTrust Global CA&#8221; -t &#8220;C,,&#8221; -d ~\/.zabbix_163 -i ~\/.zabbix_163\/163.crt \u00a0\u00a0\u00a0\u6dfb\u52a0\u8bc1\u4e66\u81f3Global \u8bc1\u4e66\u5e93\u4e2d<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/7-11.png\" alt=\"\" class=\"wp-image-591\" width=\"840\" height=\"34\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/8-11.png\" alt=\"\" class=\"wp-image-592\" width=\"584\" height=\"168\"\/><\/figure>\n\n\n\n<p>#\u4f7f\u8bc1\u4e66\u5f97\u5230\u8ba4\u53ef\uff0c\u907f\u514d\u53d1\u90ae\u4ef6\u540e\u62a5\u9519\uff1a<\/p>\n\n\n\n<p>Error in certificate: Peer&#8217;s certificate issuer is not recognized<\/p>\n\n\n\n<p>cd \/root\/.zabbix_163 &nbsp;&nbsp;(\u4e00\u5b9a\u8981\u8fdb\u5165\u5230\u8bc1\u4e66\u6240\u5728\u76ee\u5f55\u624d\u884c)<\/p>\n\n\n\n<p>certutil -A -n &#8220;GeoTrust SSL CA &#8211; G3&#8221; -t &#8220;Pu,Pu,Pu&#8221; &nbsp;-d .\/ -i .\/163.crt &nbsp;&nbsp;&nbsp;\u6216 &nbsp;&nbsp;certutil -A -n &#8220;GeoTrust SSL CA &#8211; G3&#8221; -t &#8220;Pu,Pu,Pu&#8221; &nbsp;-d .\/ -i 63.crt &nbsp;&nbsp;&nbsp;\u6709\u7684\u7248\u672c\u4f1a\u51fa\u9519\u6682\u65f6\u8fd8\u672a\u6709\u89e3\u51b3\u65b9\u6cd5\uff08\u4e0d\u5f71\u54cd\u6d4b\u8bd5\u63a5\u6536\u90ae\u4ef6\uff09<\/p>\n\n\n\n<p>[root@localhost .zabbix_163]# certutil -L -d \/root\/.zabbix_163\/ \u00a0\u00a0\u00a0\u00a0\u00a0\u5c55\u793a\u8bc1\u4e66\u5217\u8868<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"863\" height=\"124\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/9-9.png\" alt=\"\" class=\"wp-image-593\"\/><\/figure>\n\n\n\n<p>\u518d\u6b21\u7f16\u8f91 [root@localhost \/]# vim \/etc\/mail.rc<\/p>\n\n\n\n<p>set bsdcompat<\/p>\n\n\n\n<p>set from=<a href=\"mailto:whjchkj@163.com\">xxxxx@163.com<\/a><\/p>\n\n\n\n<p>set smtp=smtps:\/\/smtp.163.com:465<\/p>\n\n\n\n<p>set ssl-verify=ignore<\/p>\n\n\n\n<p>set nss-config-dir=\/root\/.zabbix_163<\/p>\n\n\n\n<p>set smtp-auth-user=<a href=\"mailto:whjchkj@163.com\">xxxxx@163.com<\/a><\/p>\n\n\n\n<p>set smtp-auth-password= UXKJFQDIVJAFHUAT<\/p>\n\n\n\n<p>set smtp-auth=login<\/p>\n\n\n\n<p>&nbsp;\u91cd\u542f\u670d\u52a1\u6d4b\u8bd5<\/p>\n\n\n\n<p>[root@localhost \/]# systemctl start sendmail<\/p>\n\n\n\n<p>[root@localhost \/]# echo hello | mail -s &#8220;TEST&#8221; <a href=\"mailto:731978638@qq.com\">xxxxxx@qq.com<\/a><\/p>\n\n\n\n<p>2\uff1a\u7f16\u5199\u53d1\u90ae\u4ef6\u811a\u672c(\u4ee5\u4e0b\u90ae\u4ef6\u811a\u672c\u672a\u914d\u7f6e\u9a8c\u8bc1\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u53ef\u641c\u7d22\u5176\u5b83\u7c7b\u4f3c\u811a\u672c\u53c2\u8003\u5e94\u7528\uff09<\/p>\n\n\n\n<p>[root@zabbix alertscripts]# cd \/usr\/lib\/zabbix\/alertscripts<\/p>\n\n\n\n<p>[root@zabbix alertscripts]# vi mailx.sh<\/p>\n\n\n\n<p>#!\/bin\/bash<\/p>\n\n\n\n<p>#send mail<\/p>\n\n\n\n<p>messages=echo $3 | tr &#8216;\\r\\n&#8217; &#8216;\\n&#8217;<\/p>\n\n\n\n<p>subject=echo $2 | tr &#8216;\\r\\n&#8217; &#8216;\\n&#8217;<\/p>\n\n\n\n<p><strong>echo \u201c{messages}&#8221; | mail -s &#8220;messages&#8221;\u2223mail\u2212s&#8221;{subject}\u201d $1 &gt;&gt;\/tmp\/mailx.log 2&gt;&amp;1<\/strong><strong><\/strong><\/p>\n\n\n\n<p>\u4fee\u6539\u6743\u9650<\/p>\n\n\n\n<p>touch \/tmp\/mailx.log<\/p>\n\n\n\n<p>chown -R zabbix.zabbix \/tmp\/mailx.log<\/p>\n\n\n\n<p>chmod +x \/usr\/lib\/zabbix\/alertscripts\/mailx.sh<\/p>\n\n\n\n<p>chown -R zabbix.zabbix \/usr\/lib\/zabbix\/<\/p>\n\n\n\n<p>\u6d4b\u8bd5\u811a\u672c\u53d1\u9001\u90ae\u4ef6<\/p>\n\n\n\n<p>[root@zabbix alertscripts]# echo \u201chello world\u201d | mail -s \u201ctestmail\u201d \u4f60\u7684\u90ae\u7bb1<\/p>\n\n\n\n<p>\u6dfb\u52a0\u4e09\u4e2a\u811a\u672c\u53c2\u6570<\/p>\n\n\n\n<p>{ALERT.SENDTO}<\/p>\n\n\n\n<p>{ALERT.SUBJECT}<\/p>\n\n\n\n<p>{ALERT.MESSAGE}<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1551\" height=\"781\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2022\/09\/10-8.png\" alt=\"\" class=\"wp-image-594\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9a\u4e49\u95ee\u9898\u6545\u969c\u89e6\u53d1\u5668 \u4e00:web\u7aef\u8bbe\u7f6e\u62a5\u8b66 \u00a01: &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,7,1],"tags":[],"class_list":["post-584","post","type-post","status-publish","format-standard","hentry","category-linux","category-7","category-1"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts\/584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=584"}],"version-history":[{"count":1,"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions"}],"predecessor-version":[{"id":595,"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions\/595"}],"wp:attachment":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}