前言
zabbix是個非常強大的監控工具,可以監控linux和windows的伺服器數據,也可以透過自訂key來擴展預設的監控項,但是自帶的郵件警報提供的資訊卻不太友善。本文想透過自定腳本的方式,實現在警報郵件的同時發送對應的圖像和url連接。
步驟如下:
1、編輯zabbix_server.conf文件,修改AlertScriptsPath參數,此參數用於指定外部腳本的絕對路徑。
vim /etc/zabbix/zabbix_server.conf AlertScriptsPath=/usr/lib/zabbix/alertscripts
2、上傳新增py腳本至AlertScriptsPath參數指定的絕對路徑下,py檔案如下:
#! /usr/bin/env python # coding:utf-8 ''' [INFORMATION] Zabbix Send Email With Python AUTHOR : Wing GitHub : https://github.com/wing324 Email : wing324@126.com ''' from email import encoders from email.header import Header from email.mime.text import MIMEText from email.utils import parseaddr, formataddr import smtplib import sys def send_mail(_to_email,_subject,_message): # 定义邮件发送 smtp_host = 'smtp.xxx.xx' from_email = 'xxx@xxx.xx' passwd = 'xxxxxx' msg = MIMEText(_message,'plain','utf-8') msg['Subject'] = _subject smtp_server = smtplib.SMTP(smtp_host,25) smtp_server.login(from_email,passwd) smtp_server.sendmail(from_email,[_to_email],msg.as_string()) smtp_server.quit() if __name__ == '__main__': send_mail(sys.argv[1],sys.argv[2],sys.argv[3])
3、修改python腳本的權限
chown -R zabbix:zabbix zabbix_send_email.py chmod 755 zabbix_send_email.py
4、zabbix web配置types –> Create media type
建立一個測試使用者Administration –> Users –> Create user
為新建立的用戶指定
建立action實作郵件警報Configuration –> Actions –> Create action
5、zabbix 。再將其恢復,查看是否收到恢復後的郵件。如果一切如預期所想,那麼至此就完成了使用python腳本完成zabbix的警報郵件了。如果沒有如預期所想。
TIPS:
如果你用的zabbix3.0,請注意Administration –> Media types –> Create media type這一步的配置如下:
,希望本文的內容對大家的學習或工作能帶來一定的幫助,如果有疑問大家可以留言交流。
更多zabbix利用python腳本發送警報郵件的方法相關文章請關注PHP中文網!

pythonlistscanStoryDatatepe,ArrayModulearRaysStoreOneType,and numpyArraySareSareAraysareSareAraysareSareComputations.1)列出sareversArversAtileButlessMemory-Felide.2)arraymoduleareareMogeMogeNareSaremogeNormogeNoreSoustAta.3)

WhenyouattempttostoreavalueofthewrongdatatypeinaPythonarray,you'llencounteraTypeError.Thisisduetothearraymodule'sstricttypeenforcement,whichrequiresallelementstobeofthesametypeasspecifiedbythetypecode.Forperformancereasons,arraysaremoreefficientthanl

pythonlistsarepartofthestAndArdLibrary,herilearRaysarenot.listsarebuilt-In,多功能,和Rused ForStoringCollections,而EasaraySaraySaraySaraysaraySaraySaraysaraySaraysarrayModuleandleandleandlesscommonlyusedDduetolimitedFunctionalityFunctionalityFunctionality。

ThescriptisrunningwiththewrongPythonversionduetoincorrectdefaultinterpretersettings.Tofixthis:1)CheckthedefaultPythonversionusingpython--versionorpython3--version.2)Usevirtualenvironmentsbycreatingonewithpython3.9-mvenvmyenv,activatingit,andverifying

Pythonarrayssupportvariousoperations:1)Slicingextractssubsets,2)Appending/Extendingaddselements,3)Insertingplaceselementsatspecificpositions,4)Removingdeleteselements,5)Sorting/Reversingchangesorder,and6)Listcomprehensionscreatenewlistsbasedonexistin

NumPyarraysareessentialforapplicationsrequiringefficientnumericalcomputationsanddatamanipulation.Theyarecrucialindatascience,machinelearning,physics,engineering,andfinanceduetotheirabilitytohandlelarge-scaledataefficiently.Forexample,infinancialanaly

useanArray.ArarayoveralistinpythonwhendeAlingwithHomoGeneData,performance-Caliticalcode,orinterfacingwithccode.1)同質性data:arraysSaveMemorywithTypedElements.2)績效code-performance-calitialcode-calliginal-clitical-clitical-calligation-Critical-Code:Arraysofferferbetterperbetterperperformanceformanceformancefornallancefornalumericalical.3)

不,notalllistoperationsareSupportedByArrays,andviceversa.1)arraysdonotsupportdynamicoperationslikeappendorinsertwithoutresizing,wheremactsperformance.2)listssdonotguaranteeconecontanttanttanttanttanttanttanttanttanttimecomplecomecomplecomecomecomecomecomecomplecomectacccesslectaccesslecrectaccesslerikearraysodo。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

記事本++7.3.1
好用且免費的程式碼編輯器

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

SublimeText3漢化版
中文版,非常好用

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能