日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

zabbix邮件报警配合logging模块排错的python脚本

發(fā)布時(shí)間:2025/3/17 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 zabbix邮件报警配合logging模块排错的python脚本 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

代碼如下:記錄排錯(cuò)日志:

#?!/usr/bin/env?python #?-*-?coding=utf-8?-*- import?smtplib from?email.mime.text?import?MIMEText import?sys import?logging import?timesender?=?'shiyiguo@yijiaoyuan.net' smtp_server?=?'smtp.exmail.qq.com' username?=?sender[:] password?=?'Yjy@yunwei123' log_format?=?time.strftime("%Y%m%d") time_format?=?time.strftime("%Y-%m-%d?%H:%M:%S")if?__name__?==?'__main__':logging.basicConfig(level=logging.DEBUG,?filename?=?'/tmp/smail'?+?log_format?+?'.log')logging.info(time_format?+?':?starting?sendmail?record')try:receiver?=?sys.argv[1]except?Exception,?e:print?efinally:logging.debug('receiver:\n\r\t'?+?receiver)try:subject?=?sys.argv[2]except?Exception,?e:print?efinally:logging.debug('subject:\n\r\t'?+?subject)try:content?=?sys.argv[3]except?Exception,?e:print?efinally:logging.debug('content:\n\r\t'?+?content)msg?=?MIMEText(content,?'plain',?'utf-8')smtp?=?smtplib.SMTP()smtp.connect(smtp_server)msg['Subject']?=?subjecttry:smtp.login(username,?password)try:print?receiver,sender,subject,msgsmtp.sendmail(sender,?receiver?,?msg.as_string())except?Exception,?e:print?elogging.debug(time_format?+?":\t"?+?str(e))except?Exception,?e:print?elogging.info(time_format?+?'\terror?message:\t'?+?str(e))logging.debug("\rending?logging?record.......\r\n")smtp.quit()


轉(zhuǎn)載于:https://blog.51cto.com/shiyiguo/1853808

總結(jié)

以上是生活随笔為你收集整理的zabbix邮件报警配合logging模块排错的python脚本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。