def get_drive_status(data): global stat datalist = data["drive"] driveinfo = SANtricityStorage.read_csv_file("driverMap.csv", "diskId", "") stroutput = "\n\nDrive Status" optimal = 1 strPerfData = "" total = 0 if len(datalist) > 0: for ele in datalist: if ele["status"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 stroutput += "\nDrive : " + driveinfo[ ele["id"]]["driveLabel"] + ", Product Id : " + ele[ "productID"].strip() + ", Status : " + ele["status"] strPerfData += "Drive:" + driveinfo[ ele["id"]]["driveLabel"] + "=" + str(optimal) + ";;0;1; " total += 1 else: stat = 3 stroutput += "No drives found in array." return {"strOutPut": stroutput, "strPerfData": strPerfData}
def get_phy_comp_temprature(arrayid,sessionid,arrayinfo): global stat logger.info("Inside get_phy_comp_temprature") stroutput="\nArray Name:"+arrayinfo[arrayid]["arrayName"] strperdata="" data = SANtricityStorage.get_data_from_REST(urlToServer,sessionid,arrayid,"graph") tmpstatus= data["componentBundle"]["thermalSensor"] strpowesupp="\n\nPower Supply and Fan Temperature Status" strcont="\n\nController Temperature Status" stresm="\n\nESM Temperature Status" for ele in tmpstatus: crutype=ele["rtrAttributes"]["parentCru"]["type"] if crutype in ["supportCru","controller","esm"] and ele["status"] !="optimal": stat =2 if crutype =="supportCru": strpowesupp+="\nSlot : "+str(ele["physicalLocation"]["slot"]) +" Status : "+ele["status"] elif crutype =="controller": strcont+="\nSlot : "+str(ele["physicalLocation"]["slot"]) +" Status : "+ele["status"] elif crutype =="esm": stresm+="\nSlot : "+str(ele["physicalLocation"]["slot"]) +" Status : "+ele["status"] stroutput += strpowesupp + strcont + stresm data = SANtricityStorage.get_data_from_REST(urlToServer,sessionid,arrayid,"drives") driveinfo= SANtricityStorage.read_csv_file("driverMap.csv","diskId","") stroutput+= "\n\nDrive Temperature" for ele in data: currtemp=float(ele["driveTemperature"]["currentTemp"]) reftemp=float(ele["driveTemperature"]["refTemp"]) calwarning = round((warning*reftemp)/100,2) calcritical = round((critical *reftemp)/100,2) if currtemp > calcritical and stat <2: stat = 2 elif currtemp < calcritical and currtemp > calwarning and stat <= 1: stat=1 logger.debug("Drive Id : "+ele["id"] +", Current Temp : "+str(currtemp) +", Ref Temp : "+str(reftemp)) stroutput+= "\nDrive : "+driveinfo[ele["id"]]["driveLabel"] + ", Current Temp : "+str(currtemp) +"C, Ref Temp : "+str(ele["driveTemperature"]["refTemp"]) +"C" strperdata+=driveinfo[ele["id"]]["driveLabel"]+"="+str(currtemp) +"C;"+str(warning)+";"+str(critical)+";;; " return {"strOutPut":stroutput,"strPerData":strperdata}
def get_ssd_drive_stat(arrayid, sessionid, arrayinfo): global stat logger.info("Inside get_phy_comp_temprature") stroutput = "\nArray Name:" + arrayinfo[arrayid]["arrayName"] strperdata = "" data = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "drives") driveinfo = SANtricityStorage.read_csv_file("driverMap.csv", "diskId", "") stroutput += "\n\nSSD Wear Life Monitoring" for ele in data: if ele["driveMediaType"] == "ssd": rawcapacity = round( int(ele["rawCapacity"]) / (1024 * 1024 * 1024), 2) usablecapacity = round( int(ele["usableCapacity"]) / (1024 * 1024 * 1024), 2) avgerasecountper = round( ele["ssdWearLife"]["averageEraseCountPercent"], 2) spareblkrem = round( ele["ssdWearLife"]["spareBlocksRemainingPercent"], 2) if avgerasecountper >= warning and avgerasecountper < critical and stat < 1: stat = 1 elif avgerasecountper >= critical and stat < 2: stat = 2 logger.debug("Drive Id : " + ele["id"] + ", Average Erase Count : " + str(avgerasecountper) + ", Spare Block Percent : " + str(spareblkrem)) stroutput+= "\nDrive : "+driveinfo[ele["id"]]["driveLabel"] + ", Raw Capacity : "+str(rawcapacity) +\ "GB, Usable Capacity : "+str(usablecapacity) +"GB, Average Erase Count : "+str(avgerasecountper)\ +"%, Spare Block Remaining : "+str(spareblkrem) +"%" strperdata += driveinfo[ele["id"]]["driveLabel"] + "=" + str( spareblkrem) + "%;" + str(warning) + ";" + str( critical) + ";;; " return {"strOutPut": stroutput, "strPerData": strperdata}