prd_raid.po 1.23 KB
Newer Older
Vinicius Ruoso's avatar
Vinicius Ruoso committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
function prd_raid_updatedata()
{
    UPDATA="$*"
}

function prd_raid_www()
{
    PVALUE="$*"

    OUT="false"
    SYNC="false"
    FAULTY="false"
    MISSINGPART="false"
    MISSINGDISK="false"
    NOINFO="false"

    grep -q "OUT_OF_RAID" <<< "$PVALUE" && OUT="true"
    grep -q "SYNCHRONIZING_RAID" <<< "$PVALUE" && SYNC="true"
    grep -q "FAULTY" <<< "$PVALUE" && FAULTY="true"
    grep -q "[1-9]_MISSING" <<< "$PVALUE" && MISSINGPART="true"
    grep -q "sd[a,b]_MISSING" <<< "$PVALUE" && MISSINGDISK="true"
    grep -q "NOINFO" <<< "$PVALUE" && NOINFO="true"

    PSTATETYPE="prd_raid_out.st:$OUT prd_raid_sync.st:$SYNC"
    PSTATETYPE="$PSTATETYPE prd_raid_faulty.st:$FAULTY"
    PSTATETYPE="$PSTATETYPE prd_raid_misspart.st:$MISSINGPART"
    PSTATETYPE="$PSTATETYPE prd_raid_noinfo.st:$NOINFO"
    PSTATETYPE="$PSTATETYPE prd_raid_missdisk.st:$MISSINGDISK"

    if [[ $OUT == "true" || $SYNC == "true" || $FAULTY == "true" || \
       $MISSINGPART == "true" || $MISSINGDISK == "true" || \
       $NOINFO == "true" ]]; then
          PSTATUS=red
    fi

    if grep -q "OK" <<< "$PVALUE"; then
        PVALUE="OK"
    else
        PVALUE="$(cut -d"+" -f3 <<< "$PVALUE")"
    fi
}

function getcolumninfo()
{
    WEBINTERFACE=true
    COLNAME="RAID"
}