Changeset 3147 in MondoRescue for branches/3.1/mindi/analyze-my-lvm


Ignore:
Timestamp:
Jun 19, 2013, 8:34:46 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • First pass on svn merge -r 2935:3146 ../3.0
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/mindi/analyze-my-lvm

    r2937 r3147  
    1313GetValueFromField() {
    1414    local res
    15     sed s/'    '/~/ "$1" | tr -s ' ' ' ' | sed s/'~ '/'~'/ | grep -i "$2~" | cut -d'~' -f2,3,4,5 | tr '~' ' ' | gawk '{ if ($2=="MB") {printf "%dm",$1;} else if ($2=="MiB") {printf "%dm",$1;} else if ($2=="KB") {printf "%dk",$1;} else if ($2=="KiB") {printf "%dk",$1;} else if ($2=="GB") {printf "%fg",$1;} else if ($2=="GiB") {printf "%fg",$1;} else if ($2=="TB") {printf "%dt",$1;} else if ($2=="TiB") {printf "%dt",$1;} else {print $0;};}'
     15    grep -i "$2" "$1" | perl -pi -e 's/\s*(.*)\s\s\s+(.+)$/$2/;s/\sT[i]*B/t/;s/\sG[i]*B/g/;s/\sM[i]*B/m/;s/\sK[i]*B/k/'
    1616}
    1717
     
    5454    # Exclude LVs member of that env var
    5555    if [ "$MINDI_EXCLUDE_DEVS" ] ; then
    56         list_of_devices="`mindi --readalllink $LV_full_string`"
     56        list_of_devices="`mindi --nolog --readalllink $LV_full_string 2> /dev/null`"
    5757        l=""
    5858        for d in $list_of_devices; do
     
    8484    device=$1
    8585    output=""
    86     $LVMCMD lvdisplay $device > $fname
     86    $LVMCMD lvdisplay $device | cat > $fname
    8787    stripes=`GetValueFromField $fname "Stripes"`
    8888    stripesize=`GetValueFromField $fname "Stripe size (MByte)"`m
     
    9090    [ "$stripesize" = "k" ] && stripesize=""
    9191    allocation=`GetValueFromField $fname "LV Size"`
    92     [ ! "`echo "$allocation" | grep "[k,m,g]"`" ] && allocation="$allocation"m
     92    [ ! "`echo "$allocation" | grep "[k,m,g,t]"`" ] && allocation="$allocation"m
    9393    if echo "$allocation" | grep -E '^.*g$' > /dev/null 2> /dev/null ; then
    9494        val=`echo "$allocation" | sed s/g//`
     
    127127
    128128
    129 
    130 
    131129ProcessVolumeGroup() {
    132130    local current_VG physical_volumes i list_of_devices VG_params
     
    152150        # If multipath check which type of devide are given, mpath prefered
    153151        for d in $list_of_devices; do
    154             l="$l `mindi --readalllink $d`"
     152            l="$l `mindi --nolog --readalllink $d 2> /dev/null`"
    155153            l="$l `GiveMapperOfdm $d`"
    156154        done
     
    184182        skip=0
    185183        l=""
    186         l="$l `mindi --readalllink $d`"
     184        l="$l `mindi --nolog --readalllink $d 2> /dev/null`"
    187185        l="$l `GiveMapperOfdm $d`"
    188186        list_of_devices="`echo $l | sort -u`"
     
    207205            for d in `cat $MINDI_TMP/pv.tmp2`; do
    208206                skip=0
    209                 l="$l `mindi --readalllink $d`"
     207                l="$l `mindi --nolog --readalllink $d 2> /dev/null`"
    210208                l="$l `GiveMapperOfdm $d`"
    211209                list_of_devices="`echo $l | sort -u`"
     
    239237GiveMapperOfdm () {
    240238
    241 major=`stat -c "%t" $1 2> /dev/null`
    242 minor=`stat -c "%T" $1 2> /dev/null`
     239major=`stat -L -c "%t" $1 2> /dev/null`
     240minor=`stat -L -c "%T" $1 2> /dev/null`
    243241
    244242for i in `ls /dev/mapper/*`; do
    245     mj=`stat -c "%t" $i`
    246     mn=`stat -c "%T" $i`
     243    mj=`stat -L -c "%t" $i`
     244    mn=`stat -L -c "%T" $i`
    247245    if [ "$mj" = "$major" ] && [ "$mn" = "$minor" ]; then
    248246        echo "$i"
    249247        return
    250248    fi
     249done
     250echo $1
     251}
     252
     253GiveVGLVOfdm () {
     254
     255major=`stat -L -c "%t" $1 2> /dev/null`
     256minor=`stat -L -c "%T" $1 2> /dev/null`
     257
     258for v in `vgs --noheadings | awk '{print $1}'`; do
     259    for i in `ls /dev/$v/*`; do
     260        mj=`stat -L -c "%t" $i`
     261        mn=`stat -L -c "%T" $i`
     262        if [ "$mj" = "$major" ] && [ "$mn" = "$minor" ]; then
     263            echo "$i"
     264            return
     265        fi
     266    done
    251267done
    252268echo $1
     
    292308
    293309ListAllLogicalVolumesSortedBydm() {
    294         for d in `ListAllLogicalVolumes` ; do
    295             dm=`mindi --readalllink $d | tail -1`
    296             echo "$dm|$d" >> $MINDI_TMP/sorteddm
    297         done
    298         sort -t'|' $MINDI_TMP/sorteddm | cut -d'|' -f2
     310    rm -f $MINDI_TMP/sorteddm
     311    for d in `ListAllLogicalVolumes` ; do
     312        dm=`mindi --nolog --readalllink $d 2> /dev/null | tail -1`
     313        echo "$dm|$d" >> $MINDI_TMP/sorteddm
     314    done
     315    if [ -f $MINDI_TMP/sorteddm ]; then
     316        cut -d'-' -f2- $MINDI_TMP/sorteddm | sort -t'|' -n | cut -d'|' -f2
     317    fi
    299318}
    300319
     
    333352# -------------------------------- main -----------------------------------
    334353
     354# These exports are needed to avoid bad formating of display commands (, instead of . for separator e.g.)
     355# Fix #654
     356export LANG=C
     357export LANGUAGE=C
     358
    335359if [ "$1" = "--givemapperofdm" ] ; then
    336360    shift
    337361    if [ _"$1" != _"" ] ; then
    338362        GiveMapperOfdm $1
     363    fi
     364    exit 0
     365fi
     366
     367if [ "$1" = "--givevglvofdm" ] ; then
     368    shift
     369    if [ _"$1" != _"" ] ; then
     370        GiveVGLVOfdm $1
    339371    fi
    340372    exit 0
Note: See TracChangeset for help on using the changeset viewer.