Esempio n. 1
0
def week_report():
    import date
    import datetime
    import pyMail
    weekreport_name = "/opt/weekreport.xls"
    d = datetime.datetime.now()
    date_from,date_to = date.week_get(d)
    print date_from,date_to
    terminal_table = False
    zabbix=zabbix_api(terminal_table)
    itemkey_list=['vm.memory.size[available]', 'agent.ping', 'vfs.fs.size[/,pfree]', 'system.cpu.load[percpu,avg1]']
    export_xls = {"xls":"ON",
                  "xls_name":weekreport_name,
                  "title":"ON",
                  "title_name":u"周报"
    }
    select_condition = {"hostgroupID":"",
            "hostID":""
    }
    zabbix.report_available2(str(date_from),str(date_to),export_xls,select_condition,itemkey_list=itemkey_list)
    
    # 1 初始化发送邮件类
    # 25 端口时,usettls = False
    # 465 端口时,usettls = True
    usettls = False
    sml = pyMail.SendMailDealer('mail_address','mail_pwd','smtp.gmail.com','25',usettls = usettls)
    # 2 设置邮件信息
    # 参数包括("收件人","标题","正文","格式html/plain","附件路径1","附件路径2")
    sml.setMailInfo('*****@*****.**','测试','正文','plain',weekreport_name)
    # 3 发送邮件
    sml.sendMail()
Esempio n. 2
0
def week_report_xls():
    ''' 生成 excel 表
    '''
    import date
    import datetime
    import pyMail
    weekreport_name = "/opt/weekreport.xls"
    d = datetime.datetime.now()
    date_from,date_to = date.week_get(d)
    print date_from,date_to
    terminal_table = False
    zabbix=zabbix_api(terminal_table)
    itemkey_list=['vm.memory.size[available]', 'agent.ping', 'vfs.fs.size[/,pfree]', 'system.cpu.load[percpu,avg1]']
    export_xls = {"xls":"ON",
                  "xls_name":weekreport_name,
                  "title":"ON",
                  "title_name":u"周报"
    }
    select_condition = {"hostgroupID":"",
            "hostID":""
    }
    zabbix._report_available2(str(date_from),str(date_to),export_xls,select_condition,itemkey_list=itemkey_list)
    
    # 1 初始化发送邮件类
    # 25 端口时,usettls = False
    # 465 端口时,usettls = True
    usettls = False
    sml = pyMail.SendMailDealer('mail_address','mail_pwd','smtp.gmail.com','25',usettls = usettls)
    # 2 设置邮件信息
    # 参数包括("收件人","标题","正文","格式html/plain","附件路径1","附件路径2")
    sml.setMailInfo('*****@*****.**','测试','正文','plain',weekreport_name)
    # 3 发送邮件
    sml.sendMail()