VG calculation in GB


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting VG calculation in GB
# 8  
Old 01-31-2012
Yes, ( is there.

Please let me know how to display the output horizontally.
# 9  
Old 01-31-2012
I know it's there! I'm on a mobile now and in no position to write code!! Please post the complete output of an lsvg command, as Corona688 hinted at.
# 10  
Old 01-31-2012
lsvg output looks i.e.
PHP Code:
VOLUME GROUP:       rootvg                   VG IDENTIFIER:  00c701f000004c0000000117d056caf8
VG STATE
:           active                   PP SIZE:        64 megabyte(s)
VG PERMISSION:      read/write               TOTAL PPs:      2186 (139904 megabytes)
MAX LVs:            256                      FREE PPs:       288 (18432 megabytes)
LVs:                16                       USED PPs:       1898 (121472 megabytes)
OPEN LVs:           12                       QUORUM:         (Disabled)
TOTAL PVs:          2                        VG DESCRIPTORS3
STALE PVs
:          0                        STALE PPs:      0
ACTIVE PVs
:         2                        AUTO ON:        yes
MAX PPs per VG
:     32512                                     
MAX PPs per PV
:     2032                     MAX PVs:        16
LTG size 
(Dynamic): 256 kilobyte(s)          AUTO SYNC:      no
HOT SPARE
:          no                       BB POLICY:      relocatable 
# 11  
Old 01-31-2012
It'd be much easier to use $6 -- it's a bare number, probably the one intended for machine processing. It appears to be in units of 64 megabytes.

Using printf with %.1f to print to one decimal place, adjust as needed. Use %d if you want no decimal points at all.

Code:
awk '{ printf("%.1f\n", ($6*64)/1024); }'

---------- Post updated at 12:41 PM ---------- Previous update was at 12:35 PM ----------

actually, you can even remove the grep:

Code:
lsvg $i | awk '/TOTAL PP/ { printf("%.1f", ($6*64)/1024); }'

In fact you can do the whole thing in awk:

Code:
lsvg $i | awk -v VG="$i" '
# Execute this code for lines matching TOTAL PP
/TOTAL PP/ { TPP=$6 }
# Execute this code for lines matching FREE PP
/FREE PP/ { FPP=$6 }
# Execute this code after all lines are read
END {
        TPP=(TPP*64)/1024;
        FPP=(FPP*64)/1024;
        printf("VG Name: %s Total VG Size: %.1f Free VG Size: %.1f\n", VG, TPP, FPP);
}'

# 12  
Old 01-31-2012
And as the PP size can vary by volume group:
Code:
lsvg $(lsvg) | awk '/^VOLUME GROUP/ { printf "%s ", $3 } /PP SIZE/ { S=$6 }
/TOTAL PPs/ { printf "%d ", $6*S/1024 }
/FREE PPs/ { print $6*S/1024 }
'
rootvg 136 18

This User Gave Thanks to Scott For This Post:
# 13  
Old 01-31-2012
Good point. Keeping that in mind:


Code:
lsvg $i | awk -v VG="$i" '
# Execute this code for lines matching TOTAL PP
/TOTAL PP/ { TPP=$6 }
# Execute this code for lines matching FREE PP
/FREE PP/ { FPP=$6 }
# You know the drill by now
/PP SIZE/ { S=$6 }
# Execute this code after all lines are read
END {
        TPP=(TPP*S)/1024;
        FPP=(FPP*S)/1024;
        printf("VG Name: %s Total VG Size: %.1f Free VG Size: %.1f\n", VG, TPP, FPP);
}'

This User Gave Thanks to Corona688 For This Post:
# 14  
Old 01-31-2012
Using lsvg $(lsvg) eliminates the need to use (yuk) for i in `lsvg`, or a while loop. And there's a "cost" benefit in lsvg $(lsvg) than the iteration alternatives for those who think every CPU cycle is a prisoner(!), as lsvg is only executed twice regardless of how many volume groups there are.

So, the code I posted will give output for all volume groups.

Code:
lsvg | while read VG; do
  lsvg $VG ...
...
done

for example, will execute lsvg #of VG's + 1 times.
This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Time calculation

Hi Gurus, I need to get one hour before time is yyyymmddhh format. ex. date +"%Y%m%d%H" gives 2017052814 but I need 2017052813 Thankx Please use CODE tags as required by forum rules! (6 Replies)
Discussion started by: nalakaatslt
6 Replies

2. Shell Programming and Scripting

Calculation

Hi, i have a large file like this: Contig1 1 5 Contig1 2 4 Contig1 3 3 Contig1 4 5 Contig1 5 3 Contig1 6 4 Contig2 1 3 Contig2 2 7 Contig2 3 2 Contig2 4 9 Contig2 5 10 Contig2 6 3 Contig2 7 7 Contig2 8 2 Contig2 9 7 Contig2 10 5 contig1 2 4 contig1 3 3 contig1 4 5 (3 Replies)
Discussion started by: the_simpsons
3 Replies

3. Shell Programming and Scripting

calculation

Could someone till me what this calculation really means let foo=`date "+(1%H-106)*60+1%M-100"` bar=foo+1440 (4 Replies)
Discussion started by: freddie999
4 Replies

4. Shell Programming and Scripting

Memory Calculation

Hi, I want an script that calculate total memory consume by all Oracle Process 6689 oraprod 16 0 1163m 155m 150m S 0 2.0 0:01.95 oracle 7046 oraprod 16 0 1161m 18m 14m S 0 0.2 0:00.02 oracle 7392 oraprod 16 0 1165m 39m 33m S 0 0.5 0:00.07 oracle 7394 oraprod 16 0 1161m 22m 18m S... (1 Reply)
Discussion started by: telnor
1 Replies

5. UNIX for Dummies Questions & Answers

Time Calculation

I have a file with over 100,000 lines of data with looking to compare times of about 2000 lines to get a total time of a process. The lines of unique data are as follows. FINER: CacSoapServer:reserveNetworkResource got the sessionID and INFO: Created CAC session ID The command... (5 Replies)
Discussion started by: bpfoster76
5 Replies

6. Shell Programming and Scripting

summery calculation

Hi All I want to make summery for Date=245Duration=545 Date=245Duration=10 Date=245Duration=278 Date=246Duration=30 Date=246Duration=178 Date=246Duration=414 Date=247Duration=17 Date=247Duration=281 Date=247Duration=9 Date=248Duration=968 Date=248Duration=550 Date=248Duration=1011... (1 Reply)
Discussion started by: nalakaatslt
1 Replies

7. Shell Programming and Scripting

summery calculation

Hi All I want to make summery for Date=245Duration=545 ... (1 Reply)
Discussion started by: nalakaatslt
1 Replies

8. Shell Programming and Scripting

issue in calculation

Hi all Already posted this question,i belive i didn't exactly said my question. I have data files it stored in the different path like /st/vr/sum.dat /st/vr/pass.dat /st/vr/fail.dat we are not suppoe to mention the hardcode value of the path. I need to calculate the percentage of... (10 Replies)
Discussion started by: bobprabhu
10 Replies

9. Shell Programming and Scripting

decimal calculation

Hi am calculating the percentage of the pass and fail. Pass: echo `echo 1498*100/1667| bc`% fail: echo `echo 169*100/1667 | bc`% for this am getting PASS= 89% fail =10 % I need to fetch the exact decimal percentage like PASS = 89.8 % FAIL= 10.2 % Please advice me (3 Replies)
Discussion started by: bobprabhu
3 Replies

10. Shell Programming and Scripting

calculation

Hi, I am in ksh88 I am trying to get the result of the calculation using 3 variables: TOTAL CAPACITY and get the following error: $DB_CAPACITY=(( $DB_SIZE * 100 / $TOTAL )) ksh: syntax error: `((' unexpected I cannot figure out what am I doing wrong... Thanks for any help -A (2 Replies)
Discussion started by: aoussenko
2 Replies
Login or Register to Ask a Question