Example #1
0
def configureArray(sessionid, ip1, ip2):
    try:
        logging.info("In configureArray")
        url = urlToServer + '/storage-systems'
        data = "{ \"controllerAddresses\": [\"" + ip1 + "\",\"" + ip2 + "\"]}"
        r = requests.post(url,
                          data,
                          verify=False,
                          headers={
                              'Content-Type': 'application/json',
                              'Cookie': 'JSESSIONID=' + sessionid
                          })

        if r.status_code == 201:
            lstOfArraySys = r.json()

            # datamap=getNewStorageSystem(sessionid,arrayid)
            strresult = "Array configured successfully with id : " + lstOfArraySys[
                "id"]
            SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid,
                                                      0)
            return strresult
        else:
            global stat
            stat = 2
            return "Array does not exist and it can't be configured with given ip"

    except Exception, err:
        logger.error("Error in configure array", exc_info=True)
        print "STATUS UNKNOWN"
        sys.exit(3)
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}
Example #3
0
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}
Example #4
0
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}
Example #5
0
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}
Example #6
0
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}
Example #7
0
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}
Example #8
0
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 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}
Example #10
0
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)
Example #11
0
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}
Example #12
0
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}
Example #13
0
def getArrayInformation():
    global stat
    logger.info("Inside getArrayInformation")
    sessionid = SANtricityStorage.login(loginUrl, username, password)
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid)
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    strResultData = ""
    contcount = 0
    currentArrayId = ""
    firstArray = True

    arrayId = ''
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if hostipaddress and (
                    row[headerList.index("ip1")] == hostipaddress or row[headerList.index("ip2")] == hostipaddress):
                arrayId = row[headerList.index("arrayId")]
                lstEle = {"arrayName": row[headerList.index("arrayName")], "arrayId": arrayId}
                contcount += 1
                if contcount == 2:
                    break
            elif hostipaddress == "":
                arrayId = row[headerList.index("arrayId")]
                if currentArrayId <> arrayId and firstArray == False:
                    strResultData += get_array_availibility(sessionid, currentArrayId)
                else:
                    firstArray = False

                currentArrayId = arrayId

    if arrayId:
        strResultData += get_array_availibility(sessionid, arrayId)
    else:

        stat = 3
        strResultData = "STATUS UNKNOWN - Host ip is not configured with webproxy"

    return strResultData
Example #14
0
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_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_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}
Example #17
0
def checkforhostconfiguration(ip1, ip2):
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)
    data = checkStorageSystem(sessionid, ip1, ip2)
    if data:
        if data["status"] == "optimal":
            stat = 0
        elif data["status"] == "needAttn":
            stat = 1
        elif data["status"] == "offline":
            stat = 2
        return "Array : " + data[
            "arrayName"] + " is up and running with status \"" + data[
                "status"] + "\""
    else:

        return configureArray(sessionid, ip1, ip2)
Example #18
0
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 getphysicalcomptstatus():
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid,
                                              SANtricityStorage.getTime())
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileforread = open(file, "rb")
    csvreader = csv.reader(fileforread, delimiter=",")
    firstline = True
    currentarrayid = ""
    arrayinfo = {}
    strresultdata = ""
    strresultperdata = ""
    lstresult = []
    firstarray = True
    controllername = {}
    contcount = 0
    arrayId = ""
    for row in csvreader:
        if firstline:
            headerList = row
            firstline = False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress
                                  or row[headerList.index("ip2")]
                                  == hostipaddress):
                arrayId = row[headerList.index("arrayId")]
                arrayinfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")]
                }
                controllername[row[headerList.index("controllerRef")]] = row[
                    headerList.index("controllerLabel")]
                contcount += 1
                if contcount == 2:
                    break
            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayinfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")]
                }
                if currentarrayid <> arrayId and firstarray == False:

                    lstresult.append(
                        get_phy_comp_stat_by_array(currentarrayid, sessionid,
                                                   arrayinfo, controllername))
                    controllername = {}
                    controllername[row[headerList.index(
                        "controllerRef")]] = row[headerList.index(
                            "controllerLabel")]

                else:
                    firstarray = False

                currentarrayid = arrayId
    if arrayId:

        lstresult.append(
            get_phy_comp_stat_by_array(arrayId, sessionid, arrayinfo,
                                       controllername))
        firstPerData = ""
        firstline = True

        for listEle in lstresult:
            strresultdata += listEle["strOutPut"]
            if firstline:
                firstPerData = listEle["strPerfData"]
                strArry = firstPerData.split(" ")
                if " " in firstPerData:
                    firstspace = firstPerData.index(" ")
                    strresultperdata += firstPerData[firstspace + 1:] + " "
                    firstPerData = firstPerData[0:firstPerData.index(" ")]

                firstline = False
            else:
                strresultperdata += listEle["strPerData"]

        # strResultPerData = strResultPerData.strip()

        if stat == 0:
            strResult = "OK - All " + msglist[
                mode] + " are in optimal stat.|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 1 and (mode == '' or mode == 'ARRY'):
            strResult = "Warning - Array is in need attention stat|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 1 and mode != "" and mode != 'ARRY':
            strResult = "OK - All " + msglist[
                mode] + " are in optimal stat.|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 2:
            strResult = "Critical - Some physical components are down.|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 3:
            strResult = "STATUS UNKNOWN - Physical component not found" + strresultdata
    else:
        strResult = "Unknown -  Host ip address is not configured in web proxy."
        stat = 3
    fileforread.close()
    return strResult
Example #20
0
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 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 getVolumeState():
    global stat
    sessionId = SANtricityStorage.login(loginUrl,username,password)
    logger.debug("In getVolume State method")
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionId, SANtricityStorage.getTime())

    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    currentArrayId = ""
    controllerId = []
    arrayInfo = {}
    strResultData = ""
    strResultPerData = ""
    lstResult = []
    controllerName = {}
    arrayId = ""
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if hostipaddress and (
                    row[headerList.index("ip1")] == hostipaddress or row[headerList.index("ip2")] == hostipaddress):
                controllerId.append(row[headerList.index("controllerRef")])
                controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {"arrayName": row[headerList.index("arrayName")],
                                      "controllerLabel": controllerName}

            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {"arrayName": row[headerList.index("arrayName")],
                                      "controllerLabel": controllerName}
                if currentArrayId <> arrayId and len(controllerId) <> 0:
                    (arrayInfo[currentArrayId])["controllerLabel"] = controllerName
                    lstResult.append(get_volume_info(currentArrayId, controllerId, sessionId, arrayInfo))
                    controllerId = []
                    controllerName = {}
                    controllerId.append(row[headerList.index("controllerRef")])
                    controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                elif currentArrayId <> arrayId:
                    controllerId = []
                    controllerName = {}
                    controllerId.append(row[headerList.index("controllerRef")])
                    controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                else:
                    controllerId.append(row[headerList.index("controllerRef")])
                    controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                currentArrayId = arrayId
    if arrayId:
        (arrayInfo[arrayId])["controllerLabel"] = controllerName

        lstResult.append(get_volume_info(arrayId, controllerId, sessionId, arrayInfo))
        firstPerData = ""
        firstLine = True
        for listEle in lstResult:
            strResultData += listEle["strOutPut"]
            if firstLine:
                firstPerData = listEle["strPerData"]
                strArry = firstPerData.split(" ")
                firstPerData = strArry[0]
                strResultPerData += strArry[1] + " "
                firstLine = False
            else:
                strResultPerData += listEle["strPerData"]

        strResultPerData = strResultPerData.strip()

        strResultData = "\nThreshold Values - Range Selector : "+range +", Warning : " + str(low) + ", Critical : " \
                        + str(high)+"\nVolume Statistics by Controller\nTotal : "+str(total)+", OK : "+\
                        str(total -(warningdrive +criticaldrive))+", Warning : "+str(warningdrive)+\
                        ", Critical : "+str(criticaldrive) + strResultData


        if stat == 0:
            strResult = "OK - All controllers are within defined threshold.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 1:
            strResult = "Warning - Some controllers are functioning at threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 2:
            strResult = "Critical - Some controllers are out side threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData

    else:

        stat = 3
        strResult = "Unknown - Host Ip is not configured with web proxy"

    fileForRead.close()
    return strResult
Example #23
0
def getVolumeState():
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)
    logger.debug("Inside getvolumestate")
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid,
                                              SANtricityStorage.getTime())
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    controllername = {}
    controllerdetails = {}
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if (hostipaddress and row[headerList.index("ip1")] == hostipaddress
                    or row[headerList.index("ip2")]
                    == hostipaddress) or hostipaddress == "":
                controllername[row[headerList.index("arrayId")] + "~" + row[headerList.index("controllerRef")]] = "\nArray Name:" + \
                    row[headerList.index("arrayName")] + ",Controller Name:" + row[headerList.index("controllerLabel")] + "\n"
                controllerdetails[row[headerList.index(
                    "controllerRef")]] = row[headerList.index(
                        "controllerLabel")]
    if len(controllername) == 0:
        strResult = "Unknown-  Host ip address not configured in web proxy."
        global stat
        stat = 3
        return strResult
    file = SANtricityStorage.getStoragePath() + "/VolumeGroup.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    currentArrayId = ""
    controllerId = []

    arrayInfo = {}
    strResultData = ""
    strResultPerData = ""
    lstResult = []
    volumegroupName = {}
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress
                                  or row[headerList.index("ip2")]
                                  == hostipaddress):
                controllerId.append(row[headerList.index("volumeGroupRef")])
                volumegroupName[row[headerList.index("volumeGroupRef")]] = row[
                    headerList.index("volumeGroup")]
                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupName
                }

            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupName
                }
                if currentArrayId <> arrayId and len(controllerId) <> 0:
                    (arrayInfo[currentArrayId]
                     )["volumeGroup"] = volumegroupName
                    lstResult.append(
                        getVolumeInfo(currentArrayId, controllerId, sessionid,
                                      arrayInfo, controllername,
                                      controllerdetails))

                    controllerId = []
                    volumegroupName = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupName[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                elif currentArrayId <> arrayId:
                    controllerId = []
                    volumegroupName = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupName[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                else:
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupName[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                currentArrayId = arrayId
    if arrayId:
        (arrayInfo[arrayId])["volumeGroup"] = volumegroupName

        lstResult.append(
            getVolumeInfo(arrayId, controllerId, sessionid, arrayInfo,
                          controllername, controllerdetails))
        firstPerData = ""
        firstLine = True
        for listEle in lstResult:
            strResultData += listEle["strOutPut"]
            if firstLine:
                firstPerData = listEle["strPerData"]

                firstspace = firstPerData.index(" ")
                strResultPerData += firstPerData[firstspace + 1:] + " "
                firstPerData = firstPerData[0:firstPerData.index(" ")]

                firstLine = False
            else:
                strResultPerData += listEle["strPerData"]

        strResultPerData = strResultPerData.strip()
        strResultData = "Array Name : " + arrayInfo[arrayId][
            "arrayName"] + strResultData
        if stat == 0:
            strResult = "OK - Volume cache statistics fetched.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 1:
            strResult = "Warning- Some volume  are functioning at threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 2:
            strResult = "Critical- Some volume  are out side threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
    else:
        strResult = "Unknown -  Host ip address not configured in web proxy."

        stat = 3
    fileForRead.close()
    return strResult
def getStoragePoolInformation():
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid)
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileforread = open(file, "rb")
    csvreader = csv.reader(fileforread, delimiter=",")
    firstline = True
    arrayinfo = {}
    strperfdata = ""
    strrepdata = ""
    contcount = 0
    currentarrayid = ""
    firstarray = True
    arrayId = ""
    for row in csvreader:
        if firstline:
            headerList = row
            firstline = False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress
                                  or row[headerList.index("ip2")]
                                  == hostipaddress):
                arrayId = row[headerList.index("arrayId")]
                lstEle = {
                    "arrayName": row[headerList.index("arrayName")],
                    "arrayId": arrayId
                }
                contcount += 1
                if contcount == 2:
                    break
            elif hostipaddress == "":
                arrayId = row[headerList.index("arrayId")]
                arrayinfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")]
                }
                if currentarrayid <> arrayId and firstarray == False:
                    lstEle = {
                        "arrayName": currentarrayname,
                        "arrayId": currentarrayid
                    }
                    getStoragePoolInfo(lstEle, sessionid)
                else:
                    firstarray = False

                currentarrayid = arrayId
                currentarrayname = row[headerList.index("arrayName")]

    if arrayId:
        getStoragePoolInfo(lstEle, sessionid)
    else:

        stat = 3
        return "STATUS UNKNOWN - Host ip is not configured with webproxy"

    lstsorted = sorted(dirdiskdata.keys())
    size = len(lstsorted) - 1
    totalcnt = 0
    if hostipaddress != '':
        strrepdata = "\n\nArray Name:" + lstEle["arrayName"]

    while size >= 0:
        data = dirdiskdata[lstsorted[size]]
        if len(data) == 1 and (noofoutput == -1 or
                               (noofoutput != -1 and totalcnt < noofoutput)):
            datafromdir = data[0]
            strperfdata += datafromdir["strData"]
            strrepdata += datafromdir["strRepData"]
            totalcnt += 1
        else:
            for lstitem in data:
                if noofoutput == -1 or (noofoutput != -1
                                        and totalcnt < noofoutput):
                    strperfdata += lstitem["strData"]
                    strrepdata += lstitem["strRepData"]
                    totalcnt += 1
                else:
                    break
        size -= 1

    if stat == 0:
        stResult = "OK - All thin volumes have used space within threshold range."
    elif stat == 1:
        stResult = "Warning - Some thin volumes have free space below the warning threshold"
    elif stat == 2:
        stResult = "Critical - Some thin volumes have free space below the critical threshold"
    elif stat == 3:
        stResult = "STATUS UNKNOWN - No thin volumes configured on this host "
    if " " in strperfdata:
        strFirstPerfData = strperfdata[0:strperfdata.index(" ")]
        strperfdata = strperfdata[strperfdata.index(" ") + 1:]
        strrepdata = "\nThreshold Values -   Warning : " + str(
            warning) + "%,  Critical : " + str(critical) + "%" + strrepdata
        stResult += "|" + strFirstPerfData + strrepdata + "|" + strperfdata
    else:
        strFirstPerfData = ""

    logging.info("dataa=" + stResult)
    return stResult
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 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
Example #27
0
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)
Example #28
0
def getVolumeState():
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)

    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid,
                                              SANtricityStorage.getTime())
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    controllername = {}
    controllerDetails = {}
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if (hostipaddress and row[headerList.index("ip1")] == hostipaddress
                    or row[headerList.index("ip2")]
                    == hostipaddress) or hostipaddress == "":
                controllername[
                    row[headerList.index("arrayId")] + "~" +
                    row[headerList.index(
                        "controllerRef")]] = "\nArray Name : " + row[
                            headerList.index(
                                "arrayName")] + ", Controller Name : " + row[
                                    headerList.index("controllerLabel")] + "\n"
                controllerDetails[row[headerList.index(
                    "controllerRef")]] = row[headerList.index(
                        "controllerLabel")]
    file = SANtricityStorage.getStoragePath() + "/VolumeGroup.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    currentArrayId = ""
    controllerId = []

    arrayInfo = {}
    strresultdata = ""
    strResultPerData = ""
    lstResult = []
    volumegroupname = {}
    arrayId = ""
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress
                                  or row[headerList.index("ip2")]
                                  == hostipaddress):
                controllerId.append(row[headerList.index("volumeGroupRef")])
                volumegroupname[row[headerList.index("volumeGroupRef")]] = row[
                    headerList.index("volumeGroup")]
                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupname
                }

            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupname
                }
                if currentArrayId <> arrayId and len(controllerId) <> 0:
                    (arrayInfo[arrayId])["volumeGroup"] = volumegroupname
                    lstResult.append(
                        getVolumeInfo(currentArrayId, controllerId, sessionid,
                                      arrayInfo, controllername,
                                      controllerDetails))
                    controllerId = []
                    volumegroupname = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupname[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                elif currentArrayId <> arrayId:
                    controllerId = []
                    volumegroupname = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupname[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                else:
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupname[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                currentArrayId = arrayId
    if arrayId:
        (arrayInfo[arrayId])["volumeGroup"] = volumegroupname

        lstResult.append(
            getVolumeInfo(arrayId, controllerId, sessionid, arrayInfo,
                          controllername, controllerDetails))
        firstPerData = ""
        firstLine = True
        for listEle in lstResult:
            strresultdata += listEle["strOutPut"]
            if firstLine:
                firstPerData = listEle["strPerData"]
                strArry = firstPerData.split(" ")
                firstspace = firstPerData.index(" ")
                strResultPerData += firstPerData[firstspace + 1:] + " "
                firstPerData = firstPerData[0:firstPerData.index(" ")]

                firstLine = False
            else:
                strResultPerData += listEle["strPerData"]

        strResultPerData = strResultPerData.strip()
        strresultdata = "\nThreshold Values - Range Selector : "+range +", Warning : " + str(low) + ", Critical : " \
                        + str(high)+"\n Volume Statistics By Volume Group\nTotal : "+str(total) +", Ok : "+ \
                        str(total - (warningdrive + criticaldrive))+", Warning : "+str(warningdrive)\
                        +", Critical : "+str(criticaldrive)+ strresultdata
        if stat == 0:
            strResult = "OK - All volume groups are within the defined threshold.|" + firstPerData + strresultdata + "|" + strResultPerData
        elif stat == 1:
            strResult = "Warning - Some volume groups are functioning at threshold values.|" + firstPerData + "\n" + strresultdata + "|" + strResultPerData
        elif stat == 2:
            strResult = "Critical - Some volume groups are out side threshold values.|" + firstPerData + "\n" + strresultdata + "|" + strResultPerData

    else:
        strResult = "Unknown -  Host ip address is not configured in web proxy."

        stat = 3
    fileForRead.close()
    return strResult
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)
Example #30
0
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)