A python script that automatically exports Zabbix performance data for use on projects on a monthly basis 1st

Source: Internet
Author: User
Tags cpu usage python script

Based on Zabbix-manager

python2.7

#!/usr/bin/env python#-*-coding:utf-8-*-#__author__ = "Life"#Email: [Email protected]#DATE:5/28/18ImportDatetime,os,sysImportCalendardate_range=()defGet_date_range ():
# Get the 1th day of the month date Last_month_date_first= Datetime.datetime (Datetime.date.today (). Year,datetime.date.today (). month-1,1). Strftime ("%y-%m-%d") #Print (Last_month_date_first)
# Get data for the last day of last month, minus one day from 1st this month. Last_month_date_last = Datetime.datetime (Datetime.date.today (). Year,datetime.date.today (). month,1)- Datetime.timedelta (1) Last_month_date_last= Last_month_date_last.strftime ("%y-%m-%d") #Print Last_month_date_last returnLast_month_date_first,last_month_date_lastdefgen_report_files (date_range): start_date=' \"'+Date_range[0]#Print start_dateEnd_date =' \"'+ date_range[1] #Print end_dateCMD_CPU ='nohup zabbix_api--report "CPU usage"'+ start_date +"00:00:00\ ""+end_date+'23:59:00 "--xls/root/reports/cpuusage.xls >/dev/null' #Print Cmd_cpuOs.popen (cmd_cpu) Cmd_mem='nohup zabbix_api--report "free Mem%"'+ start_date +"00:00:00\ ""+end_date+'23:59:00 "--xls/root/reports/freemem.xls >/dev/null' #Print Cmd_memOs.popen (cmd_mem) Cmd_disk='nohup zabbix_api--report "free disk space on"'+ start_date +"00:00:00\ ""+end_date+'23:59:00 "--xls/root/reports/freedisk.xls >/dev/null' #Print Cmd_diskOs.popen (Cmd_disk)if __name__=='__main__': Date_range=Get_date_range ()#Print Date_range Print 'begin generating Reports In/root/reports ...'gen_report_files (Date_range)

A python script that automatically exports Zabbix performance data for use on projects on a monthly basis 1st

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.