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_legacy_snap_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "legacy-snapshots") strresultdata = "\n\nSnapshot Volumes Status\n\nLegacy Snapshots Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalsize = round( float(item["totalSizeInBytes"]) / (1024 * 1024 * 1024), 2) strresultdata += "\nLabel : " + item["label"] + ", Type : " + item[ "objectType"] + ", Snapshot Time : "+datetime.datetime.fromtimestamp(int(item["snapshotTime"])).strftime("%m/%d/%y")\ +", Total Capacity : " + str(totalsize) + "GB, Repository Full : "\ +str(item["repositoryFull"])+ ", Status : " + item["status"] if item["status"] != "active" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Label:" + item["label"] + "=" + str( optimal) + ";;0;1; " else: stat = 3 strresultdata += "\nNo Legacy snapshot found." return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def get_storage_pool_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "storage-pools") strresultdata = "\n\nData Pool Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalsize = round( float(item["totalRaidedSpace"]) / (1024 * 1024 * 1024), 2) freespace = round( float(item["freeSpace"]) / (1024 * 1024 * 1024), 2) usedspace = round( round(float(item["usedSpace"]) / (1024 * 1024 * 1024), 2)) if item["diskPool"]: type = "Disk Pool" else: type = "Volume Group" strresultdata += "\nLabel : " + item["label"] + ", Type : " + type + ", Total Space : " + str( totalsize) + "GB, Used Space : " + str(usedspace) + "GB, Free Space :" + str(freespace) + "GB, Status : " + \ item["raidStatus"] if item["raidStatus"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Pool:" + item["label"] + "=" + str( optimal) + ";;0;1; " else: stat = 3 strresultdata += "No Storage Pool found." return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def get_con_group_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "consistency-groups") strresultdata = "\n\nConsistency Group Status" strperfdata = "" if len(lstdata): for item in lstdata: strresultdata += "\nLabel : " + item[ "label"] + ", Repository Full Policy : " + item[ "repFullPolicy"] + ", Warning Threshold : " + str( item["fullWarnThreshold"] ) + ", Auto Delete Limit : " + str( item["autoDeleteLimit"] ) + ", Creation Pending Status : " + item[ "creationPendingStatus"] if item["creationPendingStatus"] != "none" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Volume-Label:" + item["label"] + "=" + str( optimal) + ";;0;1; " else: stat = 3 strresultdata += "\nNo Consistency group found." return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def get_volume_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "volumes") strresultdata = "\n\nVolume Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalSize = round( float(item["totalSizeInBytes"]) / (1024 * 1024 * 1024), 2) strresultdata += "\nVolume Label : " + item[ "label"] + ", Disk Pool : " + str( item["diskPool"]) + ", Total Size : " + str( totalSize) + "GB, Volume Use : " + item[ "volumeUse"] + ", Status : " + item["status"] if item["status"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Volume-Label:" + item["label"] + "=" + str( optimal) + ";;0;1; " else: stat = 3 strresultdata += "No Volumes found" return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def get_snap_rep_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "legacy-snapshots") strresultdata = "\n\nRepository Status\nSnapshot Repository Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalsize = round( float(item["aggregateCapacity"]) / (1024 * 1024 * 1024), 2) strresultdata += "\nVolume Handle : " + item[ "volumeHandle"] + ", Type : " + item[ "baseObjectType"] + ", Aggregated Capacity : " + str( totalsize) + "GB, Status : " + item["status"] if item["raidStatus"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Storage-Pool:" + item["label"] + "=" + str( optimal) + ";;0;1; " else: stat = 3 strresultdata += "\nNo Legacy Snapshot found." return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def get_pit_snap_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "snapshot-images") strresultdata = "\n\nPIT Snapshots Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalsize = round( float(item["pitCapacity"]) / (1024 * 1024 * 1024), 2) strresultdata += "\nSequence No : " + item["pitSequenceNumber"] + ", Creation Method : " + item[ "creationMethod"] + \ ", Capacity : " + str(totalsize) + "GB, Utilization : " + str( item["repositoryCapacityUtilization"]) + \ ", Creation Time : " + str( datetime.datetime.fromtimestamp(int(item["pitTimestamp"])).strftime("%m/%d/%y")) + \ ", Status : " + item["status"] if item["status"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "SeqNO:" + item["pitSequenceNumber"] + "=" + str( optimal) + ";;0;1; " else: stat = 3 strresultdata += "\nNo PIT Snapshot found." return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def get_asynch_mirror_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "async-mirrors/pairs") strresultdata = "\n\nAsync Mirror Volumes Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalsize = round( float(item["totalSizeInBytes"]) / (1024 * 1024 * 1024), 2) strresultdata += "\nRemote Volume Name : " + item["remoteVolumeName"] + ", Last Recovery Point Time : " + str( datetime.datetime.fromtimestamp(int(item["lastRecoveryPointTime"])).strftime("%m/%d/%y")) + ", " \ "Total Space : " + str( totalsize) + "GB, Status : " + item["remoteVolumeInfo"]["remoteVolState"] if item["remoteVolumeInfo"][ "remoteVolState"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Async-Label:" + item[ "remoteVolumeName"] + "=" + str(optimal) + ";;0;1; " else: stat = 3 strresultdata += "\nNo Async Mirror Volumes found" return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def checkStorageSystem(sessionId, ip1, ip2): try: logging.info("In getStorageSystem") url = urlToServer + '/storage-systems' r = requests.get(url, verify=False, headers={ 'Content-Type': 'application/json', 'Cookie': 'JSESSIONID=' + sessionId }) lstOfArraySys = SANtricityStorage.get_data_from_REST( urlToServer, sessionId, None, "storage-systems") logging.info(len(lstOfArraySys)) lst = [] for listEle in lstOfArraySys: if listEle["ip1"] == ip1 and listEle["ip2"] == ip2: dataMap = {} dataMap["arrayId"] = listEle["id"] dataMap["arrayName"] = listEle["name"] dataMap["status"] = listEle["status"] return dataMap return False except Exception, err: logger.error("Error in checkStorageSystem", exc_info=True) print "STATUS UNKNOWN" sys.exit(3)
def get_pit_repo_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "repositories/concat") strresultdata = "\n\nPIT Repository Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalsize = round( float(item["aggregateCapacity"]) / (1024 * 1024 * 1024), 2) strresultdata += "\nVolume Handle : " + str( item["volumeHandle"]) + ", Type : " + item[ "baseObjectType"] + ", Aggregated Capacity : " + str( totalsize) + "GB, Status : " + item["status"] if item["status"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Volume-Handle : " + str( item["volumeHandle"]) + "=" + str(optimal) + ";;0;1; " else: stat = 3 strresultdata += "No PIT Repository found" return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def get_array_availibility(sessionid, arrayid): global stat data = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid) status = data["status"] if status == "needsAttn" and stat < 1: stat = 1 elif status == "neverContacted" and stat < 2: stat = 2 logger.debug("ArrayID:" + arrayid) logger.debug("Array Name:" + data["name"] + "ip1:" + data["ip1"] + "ip2: " + data["ip2"] + " id: " + data["id"]) return "\nArray Name:" + data["name"] + " Status:" + data["status"] + " Last Boot Time:" + data["bootTime"]
def get_array_status(sessionid, arrayid): data = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "") global stat if data: status = data["status"] if status == "needsAttn" and stat < 1 and (mode == "" or mode == "ARRY"): stat = 1 elif status == "neverContacted": stat = 2 stroutput = ", Status : " + data["status"] return {"strOutPut": stroutput}
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}
def get_mirror_vol_status(arrayid, sessionid, arrinfo, controllername): global stat lstdata = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "remote-mirror-pairs") strresultdata = "\n\nMirror Volume Status\nMirror Repository Volumes Status" strperfdata = "" if len(lstdata) > 0: for item in lstdata: totalsize = round( float(item["base"]["capacity"]) / (1024 * 1024 * 1024), 2) lasttime = "" if item["lastCompleteTime"]: lasttime = str( datetime.datetime.fromtimestamp( int(item["lastCompleteTime"])).strftime("%m/%d/%y")) else: lasttime = "NA" strresultdata += "\nLabel : " + str(item["base"]["label"]) + ", Type : " + item["base"]["objectType"] + ", " \ "Last Start Time : " + lasttime + ", Capacity : " + str( totalsize) + "GB, Status : " + item["status"] if item["status"] != "optimal" and stat < 2: stat = 2 optimal = 0 else: optimal = 1 strperfdata += "Label:" + str( item["base"]["label"]) + "=" + str(optimal) + ";;0;1; " else: stat = 3 strresultdata += "\n No Mirror Repository Volumes found." return {"strOutPut": strresultdata, "strPerfData": strperfdata}
def getVolumeInfo(arrayId, controllerIds, sessionId, arrayInfo, controllername, controllerdetails): try: logger.info("In Volume INFO") filedata = SANtricityStorage.get_data_from_REST( urlToServer, sessionId, arrayId, "analysed-volume-statistics") if filedata: lstofarraysys = filedata lst = [] logger.debug("Response received") logger.debug(len(lstofarraysys)) dirData = {} arryIdWiseInfo = arrayInfo[arrayId] arrayname = arryIdWiseInfo["arrayName"] volumegroupname = arryIdWiseInfo["volumeGroup"] strPerData = "" showoutput = False for lst in lstofarraysys: controllerid = lst["controllerId"] cntContWise = 0 if lst["poolId"] + "~" + controllerid in dirData: stroutput = (dirData[lst["poolId"] + "~" + controllerid])["strOutput"] else: stroutput = "\nVolume Group Name:" + volumegroupname[ lst["poolId"]] stroutput += "\n\nVolume Name:" + lst["volumeName"] if mode == "PRC": readHitOp = round(lst["readHitOps"], 2) readIOP = round(lst["readIOps"], 2) readcacheuti = round(lst["readCacheUtilization"], 2) writecacheuti = round(lst["writeCacheUtilization"], 2) readHitBytes = round(lst["readHitBytes"] / (1024 * 1024), 2) writeIOP = round(lst["writeIOps"], 2) writeHitOp = round(lst["writeHitOps"], 2) writeHitBytes = round(lst["writeHitBytes"] / (1024 * 1024), 2) logger.debug("Volume Id:" + lst["volumeId"] + ",controllerId:" + lst["controllerId"] + ",poolId:" + lst["poolId"] + ",readHitOp:" + str(readHitOp) + "readHitBytes:" + str(readHitBytes) + "readIops:" + str(readIOP) + "readCacheUtilization:" + str(readcacheuti)) logger.debug("writeHitOp:" + str(writeHitOp) + ",writeHitBytes:" + str(writeHitBytes) + ",writeIops:" + str(writeIOP) + ",writeCacheUtilization:" + str(writecacheuti)) totalCacheHit = readHitOp + writeHitOp totalCacheHitPer = 0 if readcacheuti > 0 and writecacheuti > 0: totalCacheHitPer = round( (readcacheuti + writecacheuti) / 2, 2) elif readcacheuti > 0 and writecacheuti == 0: totalCacheHitPer = readcacheuti elif writecacheuti > 0 and readcacheuti == 0: totalCacheHitPer = writecacheuti totalCacheByte = readHitBytes + writeHitBytes totatlCachBytePer = 0 stroutput += "\nNo of Read I/O that hit cache : " + str( readHitOp ) + ", No of bytes of Read I/O that hit I/O : " + str( readHitBytes ) + "MB, % of Read I/O that hit cache : " + str( readcacheuti) stroutput += "\nNo of Write I/O that hit cache : " + str( writeHitOp ) + ", No of bytes of Write I/O that hit cache : " + str( writeHitBytes ) + "MB, % of Write I/O that hit cache : " + str( writecacheuti) stroutput += "\nNo of Read/Write I/O that hit cache : " + str( totalCacheHit ) + ", No of bytes of Read/Write Hit I/O that hit cache : " + str( totalCacheByte ) + "MB, % of Read/Write I/O that hit cache :" + str( totalCacheHitPer) strPerData += lst["volumeName"] + "=" + str( totalCacheHitPer) + "%; " elif mode == "SSDC": readHitOp = round(lst["flashCacheReadHitOps"], 2) readcacheuti = round(lst["readCacheUtilization"], 2) readHitBytes = round(lst["flashCacheReadHitBytes"], 2) readIOP = round(lst["readIOps"], 2) # logger.debug("Volume Id:"+lst["volumeId"]+",controllerId:"+lst["controllerId"]+",poolId:"+lst["poolId"]+",flashCacheReadHitOPs:"+str(readHitOp) +",flashCacheReadHitBytes:"+str(readHitBytes) +",readIops:"+readIOP+",readBytes:"+readBytes) logger.debug("Volume Id:" + lst["volumeId"] + ",controllerId:" + lst["controllerId"] + ",poolId:" + lst["poolId"] + ",flashCacheReadHitOPs:" + str(readHitOp) + ",flashCacheReadHitBytes:" + str(readHitBytes) + ",readIops:" + str(readIOP) + ",readCacheHit:" + str(readcacheuti)) stroutput += "\n No of Read I/O that hit SSD cache : " + str( readHitOp ) + ", No of bytes of Read I/O that hit cache :" + str( readHitBytes ) + ", % of Read I/O that hit cache :" + str(readcacheuti) strPerData += lst["volumeName"] + "=" + str( readcacheuti) + "%; " dirData[lst["poolId"] + "~" + controllerid] = { "strOutput": stroutput, "arrayId": arrayId, "controllerId": controllerid } stroutput = "Array Name : " + arrayname if mode == "PRC": stroutput = "\n\nPrimary Cache Statistics" elif mode == "SSDC": stroutput = "\n\nFlash Cache Statistics" for lstContId in dirData.keys(): mapdata = dirData[lstContId] if mapdata["arrayId"] + "~" + mapdata[ "controllerId"] not in controllerdetails: stroutput += "\n\nController Name : " + controllerdetails[ mapdata["controllerId"]] controllerdetails[mapdata["arrayId"] + "~" + mapdata["controllerId"]] = 1 stroutput += mapdata["strOutput"] dirData["strOutPut"] = stroutput dirData["strPerData"] = strPerData return dirData else: print "STATUS UNKNOWN" sys.exit(3) except Exception, err: logger.error("Error in getvolumeinfo", exc_info=True) print "STATUS UNKNOWN" sys.exit(3)
def get_phy_comp_stat_by_array(arrayid, sessionid, arrinfo, controllername): data = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "graph") strOutPut = "\nArray Name : " + arrinfo[arrayid]["arrayName"] resultdata = get_array_status(sessionid, arrayid) strOutPut += resultdata["strOutPut"] if stat == 2: print "Critical - Array is down, no other status can be fetched" sys.exit(2) resultdata = {} strPerfData = "" if data: if mode == "": resultdata = get_drive_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] resultdata = get_controller_status(data, arrayid, controllername) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] resultdata = get_battery_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] resultdata = get_fan_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] resultdata = get_powersupp_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] resultdata = get_esm_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] resultdata = get_tray_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] elif mode == "BATT": resultdata = get_battery_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] elif mode == "RBCON": resultdata = get_controller_status(data, arrayid, controllername) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] elif mode == "PSU": resultdata = get_powersupp_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] elif mode == "DDS": resultdata = get_drive_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] elif mode == "FAN": resultdata = get_fan_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] elif mode == "EBIOM": resultdata = get_esm_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] elif mode == "TRAY": resultdata = get_tray_status(data) strOutPut += resultdata["strOutPut"] strPerfData += resultdata["strPerfData"] resultdata["strOutPut"] = strOutPut resultdata["strPerfData"] = strPerfData return resultdata
def get_volume_info(arrayid, controllerids, sessionid, arrayinfo): global total global stat global warningdrive global criticaldrive try: logger.debug("In Volume INFO") lstOfArraySys = [] lstOfArraySys = SANtricityStorage.get_data_from_REST(urlToServer, sessionid, arrayid, "analysed-volume-statistics") if lstOfArraySys and len(lstOfArraySys) > 0: logger.debug("Response received") logger.debug(len(lstOfArraySys)) dirdata = {} arrayidwiseinfo = arrayinfo[arrayid] controllername = arrayidwiseinfo["controllerLabel"] keytofatch = listMode[mode] for lst in lstOfArraySys: if lst["controllerId"] not in dirdata: dirdata[lst["controllerId"]] = {"readIOP": 0} cntconwise = 0 logger.debug( "Volume Id : " + lst["volumeId"] + ", controllerId : " + lst["controllerId"] + ", poolId : " + lst[ "poolId"] + ", " + keytofatch + " : " + str(round(lst[keytofatch], 2))) cntconwise = (dirdata[lst["controllerId"]])["readIOP"] if mode == "RTHP" or mode == "WTHP": # cntconwise+=(lst[keytofatch] /(1024*1024)) cntconwise += round(lst[keytofatch], 2) else: # cntconwise+=lst[keytofatch]/1000 cntconwise += round(lst[keytofatch], 2) (dirdata[lst["controllerId"]])["readIOP"] = cntconwise strOutPut = "" strPerData = "" showoutput = False total =len(controllerids) for lstContId in controllerids: lstrContData = dirdata[lstContId] contwiseLat = lstrContData["readIOP"] if (range== "low" and contwiseLat <=low and contwiseLat >high) or (range =="high" and contwiseLat >=low and contwiseLat <high): if stat < 1: stat = 1 warningdrive +=1 showoutput = True elif (range == "low" and contwiseLat <= high) or (range == "high" and contwiseLat >=high): if stat < 2: stat = 2 showoutput = True criticaldrive +=1 contwiseLat = round(contwiseLat, 2) if showoutput: strOutPut += "\nArray Name : " + arrayidwiseinfo["arrayName"] + ", Controller Name : " + \ controllername[lstContId] + ", " + dirmsg[mode] + " : " + str(contwiseLat) strPerData += arrayidwiseinfo["arrayName"] + "-" + controllername[lstContId] + "=" + str(contwiseLat) + \ dirunit[mode] + ";" + str(low) + ":" + str(low) + ";@" + str(low) + ":" + str(high) + "; " showoutput = False dirdata["strOutPut"] = strOutPut dirdata["strPerData"] = strPerData return dirdata else: print "STATUS UNKNOWN - No details fetched from the array." sys.exit(3) except Exception, err: logger.error("Error in get volume info", exc_info=True)
def getVolumeInfo(arrayId, controllerIds, sessionId, arrayInfo, controllername, controllerDetails): global stat global warningdrive global total global criticaldrive try: logger.info("In Volume INFO") lstOfArraySys = SANtricityStorage.get_data_from_REST( urlToServer, sessionId, arrayId, "analysed-volume-statistics") if lstOfArraySys and len(lstOfArraySys) > 0: logger.info("Response received") logger.info(len(lstOfArraySys)) dirData = {} arryIdWiseInfo = arrayInfo[arrayId] volumegroupname = arryIdWiseInfo["volumeGroup"] keytofatch = listMode[mode] for lst in lstOfArraySys: controllerid = lst["controllerId"] if lst["poolId"] + "~" + controllerid in dirData: cntContWise = (dirData[lst["poolId"] + "~" + controllerid])["readIOP"] else: cntContWise = 0.0 dirData[lst["poolId"] + "~" + controllerid] = { "readIOP": 0, "controllerId": controllerid, "poolId": lst["poolId"] } if mode == "RTHP" or mode == "WTHP": # cntContWise+=int(lst[keytofatch] /(1024*1024)) cntContWise += (lst[keytofatch]) else: # cntContWise+=lst[keytofatch]/1000 cntContWise += lst[keytofatch] logger.debug("Volume Id : " + lst["volumeId"] + ", controllerId : " + lst["controllerId"] + ", poolId : " + lst["poolId"] + ", " + keytofatch + " : " + str(round(lst[keytofatch], 2))) (dirData[lst["poolId"] + "~" + controllerid])["readIOP"] = cntContWise strPerData = "" showoutput = False total = len(dirData.keys()) for lstContId in dirData.keys(): lstrContData = dirData[lstContId] contwiseLat = lstrContData["readIOP"] contwiseLat = round(contwiseLat, 2) if (range == "low" and contwiseLat <= low and contwiseLat > high) or (range == "high" and contwiseLat >= low and contwiseLat < high): if stat < 1: stat = 1 showoutput = True warningdrive += 1 elif (range == "low" and contwiseLat <= high) or (range == "high" and contwiseLat >= high): if stat < 2: stat = 2 showoutput = True criticaldrive += 1 if showoutput: strOutPut = controllername[arrayId + "~" + lstrContData["controllerId"]] strOutPut += "\nVolume Group Name : " + volumegroupname[ lstrContData["poolId"]] + ", " + dirmsg[ mode] + " : " + str(contwiseLat) controllername[arrayId + "~" + lstrContData["controllerId"]] = strOutPut showoutput = False strPerData += controllerDetails[ lstrContData["controllerId"]] + "-" + volumegroupname[ lstrContData["poolId"]] + "=" + str( contwiseLat) + dirunit[mode] + ";" + str( low) + ":" + str(low) + ";@" + str( low) + ":" + str(high) + "; " strOutPut = "" for stopdata in list(controllername.keys()): if stopdata.find(arrayId) > -1: strOutPut += "\n" + controllername[stopdata] dirData["strOutPut"] = strOutPut dirData["strPerData"] = strPerData return dirData else: print "STATUS UNKNOWN - No volumes returned from array." sys.exit(3) except Exception, err: logger.error("Error in getting volume state by controller", exec_info=True)
def getstoragepoolinfo(eleMap, sessionid): try: global stat logging.info("In StoragePool INFO") arrayid = eleMap["arrayId"] arrayname = eleMap["arrayName"] lstofarraysys = SANtricityStorage.get_data_from_REST( urlToServer, sessionid, arrayid, "storage-pools") lst = [] logging.info(len(lstofarraysys)) strdata = "" strrepdata = "" strfirstperfdata = "" for lst in lstofarraysys: if lst["usedSpace"]: totalspace = round( float(lst["totalRaidedSpace"]) / (1024 * 1024 * 1024), 2) usedspace = round( float(lst["usedSpace"]) / (1024 * 1024 * 1024), 2) calwarning = round((float(warning) * totalspace / 100), 2) calcritical = round((float(critical) * totalspace / 100), 2) usedpercentage = round(((usedspace * 100) / totalspace), 2) poolname = lst["label"] stStatus = 'Ok' if usedspace >= calwarning and usedspace < calcritical and stat < 1: stat = 1 stStatus = "Warning" elif usedspace >= calcritical: stStatus = "Critical" stat = 2 if lst["diskPool"]: type = "Disk Pool" else: type = "Volume Group" logger.debug("Pool Id : " + lst["id"] + " Label : " + poolname + " diskPool : " + str(lst["diskPool"]) + "usedSpace : " + str(lst["usedSpace"]) + " Free Space : " + str(lst["freeSpace"]) + "raidedSpace : " + str(lst["totalRaidedSpace"])) if hostipaddress: strrepdata = "\nlabel : " + poolname + ", Pool Type : " + type + ", Raided Space : " + str( totalspace) + "GB, Used Space : " + str( usedspace) + "GB, Used Space(%) : " + str( usedpercentage) else: strrepdata = "\nArray Name : " + arrayname + ", label : " + poolname + ", Pool Type : " + type + ", Raided Space : " + str( totalspace) + "GB, Used Space : " + str( usedspace) + "GB, Used Space(%) : " + str( usedpercentage) reslistdata = { "strData": poolname + "=" + str(usedspace) + "GB;" + str(calwarning) + ";" + str(calcritical) + ";0;" + str(totalspace) + " ", "strRepData": strrepdata } if dirdiskdata.get(usedpercentage): listFromDir = dirdiskdata.get(usedpercentage) listFromDir.append(reslistdata) dirdiskdata[usedpercentage] = listFromDir else: dirdiskdata[usedpercentage] = [reslistdata] return {"strPerfData": strdata, "reportData": strrepdata} except Exception, err: logger.error("Error in Storage pool", exc_info=True) print "STATUS UNKNOWN - Error in storage pool" sys.exit(3)
def getStoragePoolInfo(eleMap, sessionid): try: global stat logging.info("In StoragePool INFO") arrayid = eleMap["arrayId"] arrayname = eleMap["arrayName"] lstofarraysys = SANtricityStorage.get_data_from_REST( urlToServer, sessionid, arrayid, "thin-volumes") logging.info(len(lstofarraysys)) strdata = "" strrepdata = "" if len(lstofarraysys) > 0: for lst in lstofarraysys: if lst["capacity"]: capacity = round( float(lst["capacity"]) / (1024 * 1024 * 1024), 2) inpprovcap = round( float(lst["initialProvisionedCapacity"]) / (1024 * 1024 * 1024), 2) currprovcap = round( float(lst["currentProvisionedCapacity"]) / (1024 * 1024 * 1024), 2) freespace = capacity - inpprovcap totalspace = round( float(lst["totalSizeInBytes"]) / (1024 * 1024 * 1024), 2) calwarning = round((float(warning) * totalspace / 100), 2) calcritical = round((float(critical) * totalspace / 100), 2) usedpercentage = round(((freespace * 100) / totalspace), 2) reqcapacity = capacity - currprovcap poolname = lst["label"] if freespace <= calwarning and freespace > calcritical and stat < 1: stat = 1 elif freespace <= calcritical: stat = 2 logger.debug( "Pool Id : " + lst["id"] + " Label : " + poolname + ", Full thin prov. volume allocation : " + str(capacity) + "GB, Actual thin prov. capacity : " + str(inpprovcap) + "GB, Actual capacity consumed : " + str(currprovcap) + "GB, Free space available : " + str(currprovcap) + "GB, Capacity req to satisfy full demand allocation : " + str(reqcapacity)) if hostipaddress: strrepdata = "\nLabel : " + poolname + ", Full thin prov. volume allocation : " + str( capacity ) + "GB, Actual thin prov. volume allocation : " + str( inpprovcap ) + "GB, Actual capacity consumed : " + str( currprovcap ) + "GB, Free space available : " + str( freespace ) + "GB, Capacity req to satisfy full demand allocation : " + str( reqcapacity) else: strrepdata = "\nArray Name : " + arrayname + ", Label : " + poolname + ", Full thin prov. volume allocation : " + str( capacity ) + "GB, Actual thin prov. volume allocation : " + str( inpprovcap ) + "GB, Actual capacity consumed : " + str( currprovcap ) + "GB, Free space available : " + str( freespace ) + "GB, Capacity req to satisfy full demand allocation : " + str( reqcapacity) reslistdata = { "strData": poolname + "=" + str(freespace) + "GB;" + str(calwarning) + ";" + str(calcritical) + ";0;" + str(totalspace) + " ", "strRepData": strrepdata } if dirdiskdata.get(usedpercentage): listFromDir = dirdiskdata.get(usedpercentage) listFromDir.append(reslistdata) dirdiskdata[usedpercentage] = listFromDir else: dirdiskdata[usedpercentage] = [reslistdata] else: strrepdata = "No thin volumes found" stat = 3 return {"strPerfData": strdata, "reportData": strrepdata} except Exception, err: logger.error("Error in Storage pool", exc_info=True) print "STATUS UNKNOWN - Error in storage pool" sys.exit(3)
def getVolumeInfo(arrayId, controllerIds, sessionId, arrayInfo, controllername, controllerdetails): try: logger.info("In Volume INFO") filedata = SANtricityStorage.get_data_from_REST(urlToServer, sessionId, arrayId, "analysed-volume-statistics") if filedata: lstOfArraySys = filedata logger.debug("Response received") logger.debug(len(lstOfArraySys)) dirData = {} arryIdWiseInfo = arrayInfo[arrayId] volumegroupname = arryIdWiseInfo["volumeGroup"] showoutput = False readHitPer = 0 for lst in lstOfArraySys: controllerid = lst["controllerId"] volumegroupid = lst["poolId"] if volumegroupid + "~" + controllerid in dirData: map = dirData[lst["poolId"] + "~" + controllerid] readIOP = map["readIOP"] readcacheuti = map["readCacheUtilization"] readHitOp = map["readHitOp"] writecacheuti = map["writeCacheUtilization"] writeHitOp = map["writeHitOp"] writeHitBytes = map["writeHitBytes"] readHitBytes = map["readHitBytes"] noofreadcachhit = map["noofreadcachehit"] noofwritecachehit = map["noofwritecachehit"] else: readIOP = 0 writeIOP = 0 readHitOp = 0 writeHitOp = 0 readHitBytes = 0 writeHitBytes = 0 noofreadcachhit = 0 noofwritecachehit = 0 writecacheuti=0 readcacheuti=0 if mode == "PRC": readHitOp += lst["readHitOps"] readIOP += lst["readIOps"] readHitBytes += round(lst["readHitBytes"] / (1024 * 1024), 2) writeIOP += lst["writeIOps"] writeHitOp += lst["writeHitOps"] if lst["readCacheUtilization"] > 0: noofreadcachhit += 1 readcacheuti += round(lst["readCacheUtilization"], 2) if lst["writeCacheUtilization"] > 0: noofwritecachehit += 1 writecacheuti += round(lst["writeCacheUtilization"], 2) writeHitBytes += round(lst["writeHitBytes"] / (1024 * 1024), 2) logger.debug( "Volume Id:" + lst["volumeId"] + ",controllerId:" + lst["controllerId"] + ",poolId:" + lst[ "poolId"] + ",readHitOp:" + str(readHitOp) + "readHitBytes:" + str( readHitBytes) + "readIops:" + str(readIOP) + "readCacheHit:" + str(readcacheuti)) logger.debug( "writeHitOp:" + str(writeHitOp) + ",writeHitBytes:" + str(writeHitBytes) + ",writeIops:" + str( writeIOP) + ",writeCacheUti:" + str(writecacheuti)) elif mode == "SSDC": readHitOp += round(lst["flashCacheReadHitOps"], 2) if lst["readCacheUtilization"] >0: readcacheuti +=round(lst["readCacheUtilization"],2) noofreadcachhit +=1 readHitBytes += round(lst["flashCacheReadHitBytes"] / (1024 * 1024), 2) readIOP += round(lst["readIOps"], 2) logger.debug( "Volume Id:" + lst["volumeId"] + ",controllerId:" + lst["controllerId"] + ",poolId:" + lst[ "poolId"] + ",flashCacheReadHitOPs:" + str( readHitOp) + ",flashCacheReadHitBytes:" + str(readHitBytes) + ",readIops:" + str( readIOP) + ",readCacheUti:" + str(readcacheuti)) if lst["readCacheUtilization"] > 0: noofreadcachhit += 1 readcacheuti += round(lst["readCacheUtilization"], 2) dirData[lst["poolId"] + "~" + controllerid] = {"arrayId": arrayId, "controllerId": controllerid, "volumeGroupId": volumegroupid, "readIOP": readIOP, "writeIOP": writeIOP, "readCacheUtilization": readcacheuti, "writeCacheUtilization": writecacheuti, "readHitOp": readHitOp, "writeHitOp": writeHitOp, "readHitBytes": readHitBytes, "writeHitBytes": writeHitBytes, "noofreadcachehit":noofreadcachhit, "noofwritecachehit":noofwritecachehit} strOutPut = "\nArray Name : " + arrayInfo[arrayId]["arrayName"] if mode == "PRC": strOutPut += "\nPrimary Cache Statistics" elif mode == "SSDC": strOutPut += "\nFlash Cache Statistics" strPerData = "" for lstContId in dirData.keys(): mapdata = dirData[lstContId] if mapdata["arrayId"] + "~" + mapdata["controllerId"] not in controllerdetails: strOutPut += "\n\nController Name : " + controllerdetails[mapdata["controllerId"]] controllerdetails[mapdata["arrayId"] + "~" + mapdata["controllerId"]] = 1 strOutPut += "\n\nVolume Group Name:" + volumegroupname[mapdata["volumeGroupId"]] if mode == "PRC": readHitOp = mapdata["readHitOp"] readcacheuti = mapdata["readCacheUtilization"] readHitBytes = mapdata["readHitBytes"] writecacheuti = mapdata["writeCacheUtilization"] writeHitOp = mapdata["writeHitOp"] writeHitBytes = mapdata["writeHitBytes"] noofreadcachhit=mapdata["noofreadcachehit"] noofwritecachehit = mapdata["noofwritecachehit"] totalCacheHit = readHitOp + writeHitOp totalCacheByte = readHitBytes + writeHitBytes if noofwritecachehit >0: writecacheuti=writecacheuti / noofwritecachehit if noofreadcachhit >0: readcacheuti = readcacheuti / noofreadcachhit toatlCacheHitPer = 0 if readcacheuti > 0 and writecacheuti > 0: toatlCacheHitPer = round((readcacheuti + writecacheuti) / 2, 2) elif readcacheuti > 0 and writecacheuti == 0: toatlCacheHitPer = readcacheuti elif readcacheuti == 0 and writecacheuti > 0: toatlCacheHitPer = writecacheuti strOutPut += "\nNo of Read I/O that hit cache : " + str(readHitOp) + \ ", No of bytes of Read I/O that hit I/O : " + str(readHitBytes) + \ "MB, % of Read I/O that hit cache : " + str(readcacheuti) strOutPut += "\nNo of Write I/O that hit cache : " + str(writeHitOp) + \ ", No of bytes of Write I/O that hit cache : " + str(writeHitBytes) + \ "MB, % of Write I/O that hit cache : " + str(writecacheuti) strOutPut += "\nNo of Read/Write I/O that hit cache : " + str(totalCacheHit) + \ ", No of bytes of Read/Write Hit I/O that hit cache : " + str(totalCacheByte) \ + "MB, % of Read/Write I/O that hit cache :" + str(toatlCacheHitPer) strPerData += volumegroupname[mapdata["volumeGroupId"]] + "=" + str(toatlCacheHitPer) + "%; " elif mode == "SSDC": readHitBytes = mapdata["readHitBytes"] readHitOp = mapdata["readHitOp"] readcacheuti = mapdata["readCacheUtilization"] noofreadcachhit = mapdata["noofreadcachehit"] if noofreadcachhit >0: readcacheuti = round(readcacheuti / noofreadcachhit,2) strOutPut += "\n No of Read I/O that hit SSD cache : " + str(readHitOp) + \ ", No of bytes of Read I/O that hit cache :" + str(readHitBytes) + \ ", % of Read I/O that hit cache :" + str(readcacheuti) strPerData += volumegroupname[mapdata["volumeGroupId"]] + "=" + str(readHitPer) + "%; " dirData["strOutPut"] = strOutPut dirData["strPerData"] = strPerData return dirData else: print "STATUS UNKNOWN" sys.exit(3) except Exception, err: logger.error("Error in getvolumeinfo", exc_info=True) print "STATUS UNKNOWN" sys.exit(3)
def getVolumeInfo(arrayId, controllerIds, sessionId, arrayInfo, controllername, controllerdetails): try: global stat logger.debug("In Volume INFO") #filedata = SANtricityStorage.getVolumeStates(urlToServer, sessionId, SANtricityStorage.getTime(), arrayId) filedata = SANtricityStorage.get_data_from_REST( urlToServer, sessionId, arrayId, "analysed-volume-statistics") if filedata: lstOfArraySys = filedata lst = [] logger.debug("Response received") logger.debug(len(lstOfArraySys)) dirData = {} arryIdWiseInfo = arrayInfo[arrayId] volumegroupname = arryIdWiseInfo["volumeGroup"] keytofatch = listMode[mode] strPerData = "" showoutput = False global total total = len(lstOfArraySys) for lst in lstOfArraySys: controllerid = lst["controllerId"] cntContWise = 0 if mode == "RTHP" or mode == "WTHP": cntContWise += lst[keytofatch] else: cntContWise += lst[keytofatch] logger.debug("Volume Id : " + lst["volumeId"] + ", controllerId : " + lst["controllerId"] + ", poolId : " + lst["poolId"] + ", " + keytofatch + " : " + str(round(lst[keytofatch], 2))) cntContWise = round(cntContWise, 2) if (range == "low" and cntContWise <= low and cntContWise > high) or (range == "high" and cntContWise >= low and cntContWise < high): if stat < 1: stat = 1 showoutput = True global warningdrives warningdrives += 1 elif (range == "low" and cntContWise <= high) or (range == "high" and cntContWise >= high): if stat < 2: stat = 2 showoutput = True global criticaldrives criticaldrives += 1 if showoutput: showoutput = False if lst["poolId"] + "~" + controllerid in dirData: strOutPut = (dirData[lst["poolId"] + "~" + controllerid])["strOutput"] else: # strOutPut = controllername[arrayId+"~"+controllerid] strOutPut = "\n\nVolume Group Name : " + volumegroupname[ lst["poolId"]] strOutPut += "\nVolume Name : " + lst[ "volumeName"] + ", " + dirmsg[mode] + " : " + str( cntContWise) dirData[lst["poolId"] + "~" + controllerid] = { "strOutput": strOutPut, "arrayId": arrayId, "controllerId": controllerid } strPerData += lst["volumeName"] + "=" + str( cntContWise) + dirunit[mode] + ";" + str(low) + ":" + str( low) + ";@" + str(low) + ":" + str(high) + "; " strOutPut = "\nArray Name : " + arrayInfo[arrayId]["arrayName"] # controllerdetails={} for lstContId in dirData.keys(): mapdata = dirData[lstContId] if mapdata["arrayId"] + "~" + mapdata[ "controllerId"] not in controllerdetails: strOutPut += "\n\nController Name : " + controllerdetails[ mapdata["controllerId"]] controllerdetails[mapdata["arrayId"] + "~" + mapdata["controllerId"]] = 1 strOutPut += mapdata["strOutput"] dirData["strOutPut"] = strOutPut dirData["strPerData"] = strPerData return dirData else: print "STATUS UNKNOWN" logger.error("No data returned from REST end point", exc_info=True) sys.exit(3) except Exception, err: logger.error("Error in getvolumeinfo", exc_info=True) print "STATUS UNKNOWN" sys.exit(3)