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