Changeset 3016 for branches/3.0/mindi


Ignore:
Timestamp:
Jun 3, 2012, 1:52:28 AM (7 years ago)
Author:
bruno
Message:
  • Substitue a complex awk expression by a more simpler perl one in analyze-my-lvm
  • Fix a bug on RHEL 5 where lvdisplay doesn't support redirection. Adds a | cat in between, as was done for vgdisplay
File:
1 edited

Legend:

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

    r3001 r3016  
    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
     
    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//`
     
    124124    rm -f $VG_info_file
    125125}
    126 
    127 
    128126
    129127
Note: See TracChangeset for help on using the changeset viewer.