date = datetime.datetime.strptime("2015-12-03","%Y-%m-%d") #Gera dict para report em html DAYS = 20 # A week startdate = date - datetime.timedelta(days=DAYS) #generate table with week results for i in range(DAYS): curdate = startdate + datetime.timedelta(days=i+1) str_curdate = curdate.strftime('%Y-%m-%d') result = database.fetch_zenoss_avail(curdate) devices=[] for row in result: device = common.device(row['device_text'],"",row['availability']) devices.append(device) #report.availability_report(date) daily_report = report.availability.federation() daily_report.init_dictionaries(devices) if str_curdate not in wr.report.keys(): wr.report[str_curdate] = {} for island in daily_report.island_nodes.keys(): #print '--------------------------------------------------------' #print str_curdate + '\t' + island #print '--------------------------------------------------------' if 'infrastructure' in daily_report.island_nodes[island].keys():
# # Pings Devices registered in zenoss from fibreoss import common from fibreoss import config from fibreoss.api import zenoss from fibreoss.agent import ping # -------------------------------------------------------------- # INSTANTIATE ZENOSS API # -------------------------------------------------------------- zenoss_api = zenoss.jsonapi() # -------------------------------------------------------------- # Get devices from Zenoss # -------------------------------------------------------------- rawdevices = zenoss_api.get_devices() devices = [] devcount = rawdevices["totalCount"] print "Devices: " + str(devcount) for dev in rawdevices["devices"]: # Iterate through each device, and pull the rows we want # devices.append(fibreoss.api.zenoss.zendevice(dev['name'],dev['uid'],dev['productionState'],dev['ipAddressString'])) device = common.device(dev["name"], dev["ipAddressString"]) devices.append(device) # ping agent expects to receive a list of devices as input ping.ping(devices)