准备做一个每周自动的巡检报告,数据来源于zabbix,通过python读取zabbix数据库获取数据并制作成excel表格,

本来打算直接邮件发送到指定邮箱,但是都被SMTP过滤掉了,试过126和QQ的,其他的不知道。

操作系统:Cenos 6.7

python版本: python3.5

以下代码是亲测并生产环境使用的:

#!/usr/local/python/bin/python3.5
import pymysql
import time, datetime
import smtplib
import os
from email.mime.text import MIMEText
from email.header import Header
# zabbix数据库信息 zdbhost = 'zabbix服务器ip'
zdbuser = 'zabbix数据库用户名'
zdbpass = 'zabbix数据库密码'
zdbport = 3306
zdbname = 'zabbix' d = datetime.datetime.now()
day = datetime.date.today()
keys = {
'trends_uint': [
'net.if.in[eth0]',
'net.if.out[eth0]',
'vfs.fs.size[/,used]',
'vm.memory.size[available]',
],
'trends': [
'system.cpu.load[percpu,avg5]',
'system.cpu.util[,idle]',
],
}
class ReportForm: def __init__(self):
self.conn = pymysql.connect(host=zdbhost, user=zdbuser, passwd=zdbpass, port=zdbport, db=zdbname)
self.cursor = self.conn.cursor()
self.groupname = 'Linux servers'
self.IpInfoList = self.__getHostList()
# return self.IpInfoList def __getHostList(self):
sql = '''select groupid from groups where name = '%s' ''' % self.groupname
self.cursor.execute(sql)
groupid = self.cursor.fetchone()[0]
print(groupid) sql = '''select hostid from hosts_groups where groupid = %s''' % groupid
self.cursor.execute(sql)
hostlist = self.cursor.fetchall() IpInfoList = {}
for i in hostlist:
hostid = i[0]
sql = '''select host from hosts where status = 0 and hostid = %s''' % hostid
ret = self.cursor.execute(sql)
if ret:
IpInfoList[self.cursor.fetchone()[0]] = {'hostid': hostid}
return IpInfoList def __getItemid(self, hostid, itemname):
sql = '''select itemid from items where hostid = %s and key_ = '%s' ''' % (hostid, itemname)
if self.cursor.execute(sql):
itemid = self.cursor.fetchone()[0]
else:
itemid = None
return itemid def getTrendsValue(self, itemid, start_time, stop_time):
resultlist = {}
for type in ['min', 'max', 'avg']:
sql = '''select %s(value_%s) as result from trends where itemid = %s
and clock >= %s and clock <= %s''' % (type, type, itemid, start_time, stop_time)
self.cursor.execute(sql)
result = self.cursor.fetchone()[0]
if result == None:
result = 0
resultlist[type] = result
return resultlist def getTrends_uintValue(self, itemid, start_time, stop_time):
resultlist = {}
for type in ['min', 'max', 'avg']:
sql = '''select %s(value_%s) as result from trends_uint where itemid = %s
and clock >= %s and clock <= %s''' % (type, type, itemid, start_time, stop_time)
self.cursor.execute(sql)
result = self.cursor.fetchone()[0]
if result:
resultlist[type] = int(result)
else:
resultlist[type] = 0
return resultlist def get_week(self, d):
dayscount = datetime.timedelta(days=d.isoweekday())
dayto = d - dayscount
sixdays = datetime.timedelta(days=6)
dayfrom = dayto - sixdays
date_from = datetime.datetime(dayfrom.year, dayfrom.month, dayfrom.day, 0, 0, 0)
date_to = datetime.datetime(dayto.year, dayto.month, dayto.day, 23, 59, 59)
ts_first = int(time.mktime(datetime.datetime(dayfrom.year, dayfrom.month, dayfrom.day, 0, 0, 0).timetuple()))
ts_last = int(time.mktime(datetime.datetime(dayto.year, dayto.month, dayto.day, 23, 59, 59).timetuple()))
return ts_first, ts_last def getLastMonthData(self, hostid, table, itemname):
ts_first = self.get_week(d)[0]
ts_last = self.get_week(d)[1]
itemid = self.__getItemid(hostid, itemname)
# function = getattr(self, 'get %s Value' % table.capitalize())
function = getattr(self, 'get%sValue' % table.capitalize())
return function(itemid, ts_first, ts_last) def getinfo(self):
for ip, resultdict in zabbix.IpInfoList.items():
print("正在查询 IP:%-15s hostid:%5d 的信息!" % (ip, resultdict['hostid']))
for table, keylists in keys.items():
for key in keylists:
print("\t正在统计 key_:%s" % key)
data = zabbix.getLastMonthData(resultdict['hostid'], table, key)
zabbix.IpInfoList[ip][key] = data def writeToXls(self):
dayscount = datetime.timedelta(days=d.isoweekday())
dayto = d - dayscount
sixdays = datetime.timedelta(days=6)
dayfrom = dayto - sixdays
date_from = datetime.date(dayfrom.year, dayfrom.month, dayfrom.day)
date_to = datetime.date(dayto.year, dayto.month, dayto.day)
'''生成xls文件'''
try:
import xlsxwriter
# 创建文件
workbook = xlsxwriter.Workbook('/usr/monitor/week/%s_%s巡检报告.xlsx' % (date_from, date_to))
# 创建工作薄
worksheet = workbook.add_worksheet()
# 写入标题(第一行)
i = 0
for value in ["主机", "CPU平均空闲值", "CPU最小空闲值", "可用平均内存(单位M)", "可用最小内存(单位M)", "CPU5分钟负载", "进入最大流量(单位Kbps)",
"进入平均流量(单位Kbps)", "出去最大流量(单位Kbps)", "出去平均流量(单位Kbps)"]:
worksheet.write(0, i, value)
i = i + 1
# 写入内容:
j = 1
for ip, value in self.IpInfoList.items():
worksheet.write(j, 0, ip)
worksheet.write(j, 1, '%.2f' % value['system.cpu.util[,idle]']['avg'])
worksheet.write(j, 2, '%.2f' % value['system.cpu.util[,idle]']['min'])
worksheet.write(j, 3, '%dM' % int(value['vm.memory.size[available]']['avg'] / 1024 / 1024))
worksheet.write(j, 4, '%dM' % int(value['vm.memory.size[available]']['min'] / 1024 / 1024))
worksheet.write(j, 5, '%.2f' % value['system.cpu.load[percpu,avg5]']['avg'])
worksheet.write(j, 6, value['net.if.in[eth0]']['max'] / 1000)
worksheet.write(j, 7, value['net.if.in[eth0]']['avg'] / 1000)
worksheet.write(j, 8, value['net.if.out[eth0]']['max'] / 1000)
worksheet.write(j, 9, value['net.if.out[eth0]']['avg'] / 1000)
j = j + 1
workbook.close()
except Exception as e:
print(e)
def __del__(self):
'''关闭数据库连接'''
self.cursor.close()
self.conn.close() def sendmail(self):
sender = '发送者邮箱'
receiver = ['接收者1', '接收者2', '接收者3']
subject = '上周巡检报告'
smtpserver = 'smtp.126.com'
username = '发送者邮箱'
password = 'smtp认证密码' msg = MIMEText('上周巡检报告已生成,请检查。\n报告目录:/usr/monitor\n由于邮件无法发送excel文档,请使用ftp登录'
'查看。\nftp地址:xxx:端口\nftp用户名:xxx\n', 'plain', 'utf-8') # 中文需参数‘utf-8',单字节字符不需要
msg['Subject'] = Header(subject, 'utf-8')
msg['From'] = 'Robot<发送者邮箱>'
msg['To'] = "接收者名字"
smtp = smtplib.SMTP()
smtp.connect('smtp.126.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
print('发送成功!')
smtp.quit() if __name__ == "__main__":
zabbix = ReportForm()
zabbix.getinfo()
zabbix.writeToXls()
zabbix.sendmail()

  说明: 由于邮件无法发送附件为excel,所以我这里写了一个发送通知邮件的方法,需要通过ftp登录并下载。

附上生成execl部分截图:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA2QAAABUCAIAAABiGGOvAAAUgElEQVR4nO2dO49rSRHHz7fxN3BoyZ+EgICAgICAgICVCAiInfpjOAeBQCAsI4QGrVY8Fma1XJZl1/tID8Fcec50d1VX9fvx/6l05dOnT5/qep2y545n+e/922ZldzwYUl0lr5wv1+o6BNi2uj683E/7b//480nEcE11fQrL/bSvHm/FpMcSl1DarJYdOaVNA7YsXbi1QTlfrsu7L75pWXbHA3PYoJwv1+o6jGfV+2n/7e1n88jueHC+nkHup331eCsp3SVjQmm2WvbilGYN2KZs/disT9uU8+W6fPr51y3L7nhgDhuU8+VaXQeVSbuw6v20/+b603lkdzwwh2PL/bSvHm8l5ZF97adhcmm2WvbilGYN2KB010s0JefLdfnks69alt3x4HzdrJwv1+o6yE3ai9xP+2/+8JN5ZHc8MIdjy/20rx5vJeWRjz0mZqQ0Wy17cUqzBmxQGndl43K+XJd/vvuyZdn+D4PqykjkfLlW18Fr0uo6aOV+2n/9+x/PI7vjgTkcW+6nffV4KyndlbiE0my17MUpzRqwQWnclY3L+XJd/vHpFy3L7nhwvm5WzpdrdR3kJu1F7qf917/70TyyOx6Yw7HlftpXj7eS8sjHHhMzUpqtlr04pVkDNiiNu7JxOV+uy98++V/LsjsemMMG5Xy5VtdBZdIu5H7af/XbH84ju+OBORxb7qd99XgrKY987DExI6XZatmLU5o1YIOydeXjY+PqWvUi58t1+ehfn7csu+OBOWxQzpdrdR1UJu3CqvfT/qvf/GAe2R0PzOHYcj/tq8dbSWk/+/JJs9WyF6c0a8AGpbteoik5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YEjQLHYB3w6G1TdhM0Z1nBI9t4fuZpFSVKKfUImBoZrFVV8Kk6/TL5JPmwo0hdQ4GoiEwNfzIKmWFKmeWV2DZrEL+CCMr2/auzfULNr97PIWfpGuETaLwdaw31vMZtUX5AlGTZPMt63tXAcNREJy+FoyeRXEBnydlhzNIj9tMNAsdgH/xK/SLEo6EH+zyPR5ErWcz9ewTfYI82PoeJfbFzLdzEikaiCcBqQSmM8xeyYaiCRk8vXqcxCVSkbmwtcJyd0sDu8jNItdwMdqWLMoL0FJ6if5Cy6Shk+iFnXJwDnM/IJLEmsw3eE8Vl2DEoAZEbqGSlrjXxBDJl/zp5g3Bqvld/g6FVmbxRkchGaxR4KbxVXWUfCrSSbYI+RX51AP0STv9iTr9AuTvamsEeydfolvIMLeXa0Ca6OBSEsOX6suZ+bD12nJ1yxO4h00iz2S/Nmkul2APmvJZnGeTJY0i7CqlsgGQvJhkrAppMbRQKSipK+p+dTl8HVaMjWL87gGzWIX5P4gQ3V3fn1qTfPH0N4rt3MkG0Bbk8SqQtfOY9XV1xMIrZ1wHA1EKlrwNb8+fJ0KYbX0PmskMTAkaBa7IOBTcFXtYnLEuX5APTQ/WXTectkgV86e4FxnPIRfM6u1KmO92ay6vMWYyQee0+DyWLXHH68f/47tiAKU9DUz314fvk6OpFrydlbFwHigWewFSf1xXkItJZ/JFDd5PcSf+0sPsjcHsOo8wNfzAF9HAgOCMqBZTA+yNwew6jzA1/MAX0cCA4Iy3J6e/w+Uvz5r8DntXQAAAABJRU5ErkJggg==" alt="" />

[ python3 ] 基于zabbix 自动生成xlsx监控文档的更多相关文章

  1. 使用jsdoc-toolkit来自动生成js api文档

    近来前端组小盆友开发的类库越来越多,很多情况下彼此不知道写了些什么方法,为了更好的合作提高工作效率,找了个比较好的api文档生成方法.使用jsdoc-toolkit来自动生成js api文档. 一.  ...

  2. Go学习笔记(六) | 使用swaggo自动生成Restful API文档(转)

    关于Swaggo 或许你使用过Swagger, 而 swaggo就是代替了你手动编写yaml的部分.只要通过一个命令就可以将注释转换成文档,这让我们可以更加专注于代码. 目前swaggo主要实现了sw ...

  3. Golang使用swaggo自动生成Restful API文档

    #关于Swaggo 相信很多程序猿和我一样不喜欢写API文档.写代码多舒服,写文档不仅要花费大量的时间,有时候还不能做到面面具全.但API文档是必不可少的,相信其重要性就不用我说了,一份含糊的文档甚至 ...

  4. Spring Boot学习笔记 - 整合Swagger2自动生成RESTful API文档

    1.添加Swagger2依赖 在pom.xml中加入Swagger2的依赖 <!--swagger2--> <dependency> <groupId>io.spr ...

  5. C# 自动生成代码API文档

    暂时没学会正规的转载style临时记录一下 NET中的规范标准注释(一) -- XML注释标签讲解 http://www.cnblogs.com/mq0036/p/3544264.html NET中的 ...

  6. 插件式WebApi服务及自动生成Api帮助文档

    上一篇博客中,讲到了将WebApi Host到控制台和IIS,本篇总结一下如何将WebApi的Service以插件的形式进行动态部署,并设置Hoster的首页显示Api帮助文档,当然,也包括动态部署进 ...

  7. Spring MVC学习总结(9)——Spring MVC整合swagger自动生成api接口文档

    Swagger 号称:世界最流行的API框架,官网:http://swagger.io/,Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总 ...

  8. MFC:“Debug Assertion Failed!” ——自动生成的单文档程序项目编译运行就有错误

    今天照着孙鑫老师的VC++教程学习文件的操作,VS2010,单文档应用程序,项目文件命名为File,也就有了自动生成的CFileDoc.CFileView等类,一进去就编译运行(就是最初自动生成的项目 ...

  9. 利用ShowDoc自动生成api接口文档

    最近在做新项目,感觉写完一个接口 还要去再写一遍api文档 挺浪费时间的,所以借用ShowDoc的api开放功能 自动生成api文档. 首先 去 https://www.showdoc.cc/ 注册一 ...

随机推荐

  1. 安装arch系统时,把ubuntu的efi分区格式化

    导致无法从grub进入ubuntu,之后我进入win10,把ubuntu的分区都删了. 再重启,只能进入黑色的grub界面,显示 grub>> 甚至无法进入win10.只能通过在开机时按F ...

  2. 修改maven远程仓库为阿里的maven仓库(复制)

    maven之一:maven安装和eclipse集成 maven作为一个项目构建工具,在开发的过程中很受欢迎,可以帮助管理项目中的bao依赖问题,另外它的很多功能都极大的减少了开发的难度,下面来介绍ma ...

  3. c# 生成dll

    进入项目属性栏里,选择输出类型为类库.

  4. lintcode-84-落单的数 III

    84-落单的数 III 给出2*n + 2个的数字,除其中两个数字之外其他每个数字均出现两次,找到这两个数字. 样例 给出 [1,2,2,3,4,4,5,3],返回 1和5 挑战 O(n)时间复杂度, ...

  5. esayui combotree 只能选择子节点

    esayui combotree 只能选择子节点用onBeforeSelect:参数是node,节点被选中之前触发,返回false取消选择动作. 网上找了好多都没一个可用的,要想知道他是子节点还是根节 ...

  6. capacilitys 持续集成

    目前看好像是说以docker为例来看看这个权限到底是怎么来的? 可以通过在二进制上setcap得到,也可以通过函数自己用setcap得到,两种方法,docker肯定是第二种方法啊,docker中间肯定 ...

  7. 【题解】CQOI2007余数求和

    大家都说这题水然而我好像还是调了有一会儿……不过暴力真的很良心,裸的暴力竟然还有60分. 打一张表出来,就会发现数据好像哪里有规律的样子,再仔细看一看,就会发现k/3~k/2为公差为2的等差数列,k/ ...

  8. 安装全局webpack

    npm ls webpack 和npm ls webpack -g 查看本地和全局版本 npm install webpack@1.15.0 -g 全局 然后到项目里面 npm install npm ...

  9. [模拟赛] StopAllSounds

    Description 小松鼠开心地在树之间跳跃着,突然她停了下来.因为眼前出现了一个 拿着专克超萌小松鼠的法宝----超萌游戏机的游客! 超萌游戏机之所以拥有这个名字,是因为它的屏幕是一个n × 2 ...

  10. HAOI2006 均分数据 [模拟退火]

    题目描述 已知N个正整数:A1.A2.--.An .今要将它们分成M组,使得各组数据的数值和最平均,即各组的均方差最小.均方差公式如下: 输入输出格式 输入格式: 输入文件data.in包括: 第一行 ...