cancel
Showing results for 
Search instead for 
Did you mean: 

script for summation

 
SOLVED
Go to solution
Highlighted
Jeeshan
Honored Contributor

script for summation

I have redirected the bdf output in a file and I want to sum all the Assigned, Used and free space and show separately. how can I did this reading all lines of bdf output?
a warrior never quits
9 REPLIES 9
Highlighted
avizen9
Esteemed Contributor

Re: script for summation

Please check attached file, copy to your unix box make it executable and run.

I recieved this updated bdf version from here some of formus.

Highlighted
Jeeshan
Honored Contributor

Re: script for summation

thnks for the reply but I need to sum the $2 $3 $4 position of bdf output and the scenario.
a warrior never quits
Highlighted
Dennis Handly
Acclaimed Contributor

Re: script for summation

>I need to sum the $2 $3 $4 position of bdf output

Did you see the -s option to bdfmegs?
Highlighted
James R. Ferguson
Acclaimed Contributor
Solution

Re: script for summation

Hi:

As noted, Bill has done this and much, much more in his script provided to you.

However, as a general example, here is one way to perform summation of fields in input data. Using 'bdf' output:

# bdf|awk '/^\/dev/ {KB+=$2;U+=$3;A+=$4};END{printf "%7.0f %7.0f %7.0f\n",KB/1024,U/1024,A/1024}'

The /^\/dev/ says when matched, perform what exists in the {...} statement. In this case, this skips the 'bdf' header from consideration.

The summation is done into our own variables 'KB', 'U' and 'A' for the appropriate fields of each line read by 'awk'. Fields are labeled '$1...$199' and a whole line is denoted by $0.

The 'END{...}' block is executed once when all input has been exhausted. Here, we simply print what we have summed, converting from values in KB to values in MB by dividing the sums by 1024.

Regards!

...JRF...
Highlighted

Re: script for summation

Hi,

just one on the top. bdf has a little problem with long devicenames. This could be a point, if you are using VXVM. So I would use awk the other way round:

bdf | awk '/% \// {KB+=$(NF-4);U+=$(NF-3);A+=$(NF-2)};END{printf "%7.0f %7.0f %7.0f\n",KB/1024,U/1024,A/1024}'

$(NF-4) is the fifth field from the end of line and so on. If you don't want to see NFS mounts in your output use "bdf -l".


Highlighted
Suraj K Sankari
Honored Contributor

Re: script for summation

Hi,

Please download this file (bdfmesg) from below link you will find this is a great tool written by Mr.Bill Hassell.

http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1326767

For you to query you have to use
#bdfmesg -s

-s = summarize total, used and available

Many Thanks to Mr.Bill Hassell to create a nice and useful tool.

Suraj
Highlighted
Roland Piette
Regular Advisor

Re: script for summation

Hi Ahsan,

You will find in attachment a self made script to prepare a semicolumn separated field to import in Excel. This summarizes per vg all lv's and make an global total fron a server. This script can be running in cron ans send the result in a mail.

I hope it will help

Roland
Highlighted
James R. Ferguson
Acclaimed Contributor

Re: script for summation

Hi (agtain) Ahsan:

Be advised that the copy (version 5.0) of Bill's script attached by the poster named "avizen9" (above) has a small bug. Bill corrected this the following month.

You should fetch and use his 5.1 version posted by Bill at the bottom of this link:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1326767

Regards!

...JRF...
Highlighted
avizen9
Esteemed Contributor

Re: script for summation

thanks ...JRF...