Using the output of bdf in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using the output of bdf in script
# 1  
Old 06-12-2012
[Solved]Using the output of bdf in script

Hello all,

First I have an old HP-UX box(11.21) for which I need to implement file-system utilization monitoring. I choosed to use bdf and a simple for loop. However sometimes the output of bdf is as this one(this is actually form linux but the idea is the same)


Code:
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/vg00-rootlv  9.3G  923M  8.2G  11% /
udev                     2.5G   12K  2.5G   1% /dev
tmpfs                    995M  528K  995M   1% /run
none                     5.0M     0  5.0M   0% /run/lock
none                     2.5G     0  2.5G   0% /run/shm
/dev/mapper/vg00-tmplv   950M   30M  920M   4% /tmp
/dev/mapper/vg00-varlv
                         4.7G  615M  4.1G  13% /var
BLABLA:BLAA              950M   30M  920M   4% /home2

My question is how can I extract only the value of Use%?

The loop is something like:

Code:
usep="output from bdf"
if [ $usep -ge 90 ]
then 
echo "Fs full"
fi

I tried awk print but since we have an line with one column less this didn`t work, I have also tried cut but I cannot find universal enough delimiter as the device might be named /dev/vx/ for example or HOST:SHARE.

Any help will be greatly appreciated since I am banging my head with this almost 3h.

p.s. The power of perl is also welcome Smilie

Last edited by click; 06-13-2012 at 08:16 AM.. Reason: Solved
# 2  
Old 06-12-2012
How about:

Code:
$ bdf | awk 'F{$0=F$0;F=x}NF<5{F=$0}!F{gsub(/%/,"",$5);print $1,$5}'
/dev/mapper/vg00-rootlv 11
udev 1
tmpfs 1
none 0
none 0
/dev/mapper/vg00-tmplv 4
/dev/mapper/vg00-varlv 13
BLABLA:BLAA 4

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 06-13-2012
Another way :
Code:
bdf | awk 'match($0,/[0-9]% \//) { if (int($(NF - 1)) > 90) print "Filesystem alarm " FS $(NF - 1) , $NF  } '

This User Gave Thanks to Peasant For This Post:
# 4  
Old 06-13-2012
Both are working great. Thank you both for the help!
# 5  
Old 06-13-2012
On HP-UX you may find df -v easier to work with than bdf.

Code:
df -v|grep "% used blocks"|awk '{print $1,$5}'|while read fs pc
do
        if [ $pc -ge 90 ]
        then
                echo "$fs : $pc %"
        fi
done

We prefer to have a table of "normal" percentage free values and compare filesystems with this list. With pre-allocated database segments a 90% full filesystem is not a problem but root at 90% could give cause for concern.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Bdf in HP-UX

Hi guys, I have to make an output of several databases we've got running on our system with the command bdf. This has to be done every 3 months. I want to put it in an scriptfile and trigger it in crontab. In the output it must display the differences in diskspace between these three monts. Any... (3 Replies)
Discussion started by: djmental
3 Replies

2. HP-UX

bdf hangs

hi, bdf command hangs but before it, it lists all the fstab content, so i cannot find the reason... could anybody give me any clue?? thanks a lot for your attention. regards Pablo i attach syslog Jan 14 16:30:00 sv23 vmunix: hp_dlpi_wput:Received an unrecognized primitive: 101d... (7 Replies)
Discussion started by: pabloli150
7 Replies

3. Shell Programming and Scripting

BDF Panic script...

I have another script which I found also on the net. I keep getting an error:confused:: Here is the script for it: {/usr/bin/bdf -l |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'//' >/tmp/b dflist} panic () {while read percent dir; do if ] then ... (16 Replies)
Discussion started by: zixzix01
16 Replies

4. Shell Programming and Scripting

Problem with a BDF script...

Hi, I'm trying to use an old script I found of the internet a while back, I forget where its from. Its supposed to convert the bdf function and display filesystem size in MB's and line it up however it never worked... Here is the error: And here is the code: #!/usr/bin/sh echo... (3 Replies)
Discussion started by: zixzix01
3 Replies

5. Shell Programming and Scripting

Formatting BDF output

Hello people. First of all I googled my problem and even found answers in this forum. Unfortunatelly my problem is not solved. When the lenght of the filesystem is too big the output of bdf wraps into another line. e.g.: Filesystem kbytes used avail %used Mounted on... (5 Replies)
Discussion started by: drbiloukos
5 Replies

6. Shell Programming and Scripting

Bdf output

Here is my bdf output #bdf Filesystem kbytes used avail %used Mounted on /dev/vg00/lvol3 2097152 217112 1865424 10% / /dev/vg00/lvol1 1835008 329040 1494288 18% /stand /dev/vg00/lvol7 10485760 7864080 2601240 75% /var /dev/vg00/lvol8 8454144 486597 7469647 ... (5 Replies)
Discussion started by: indrajit_renu
5 Replies

7. Shell Programming and Scripting

Formatting bdf output

Hi All. Using /usr/bin/ksh on a HP-UX B.11.23 ia64 system. Executing the following ... ` bdf -t vfxs | grep "/" ` The output comes out like (in part) ... /dev/vg00/lvol3 516096 229448 284480 45% / /dev/vg00/lvol1 516096 211200 302560 41% /stand /dev/vg00/lvol8 ... (5 Replies)
Discussion started by: Cameron
5 Replies

8. Shell Programming and Scripting

bdf script not working !!

Hi, I have written a funtion which taken bdf output and put's in a file. The idea is to grep a areas which greater then 80% and echo the same on the system. However the script I have written fails with the error :- + awk $0 !~ /^F/ + awk {print $5"\t" $6} + sed s/%// + 1> /tmp/bdflist}... (3 Replies)
Discussion started by: kpatel786
3 Replies

9. HP-UX

df and bdf discrepencies

I've recently had some space problems on one of our old HP9000 machines. I archived/moved/compressed/trashed some stuff to free up some space on one rather large (and important) logical volume. As one would expect, when `df -b` is executed some space is shown as free: /opt ... (2 Replies)
Discussion started by: sam_pointer
2 Replies

10. UNIX for Dummies Questions & Answers

BDF test for > 90%

I am trying to write a script that will allow me to do a bdf then do a test for a percentage that is 90% or greater. If the test is true then i want to send a message to myself and one other person. Any suggestions ? ? ? Thanks. ....svp (6 Replies)
Discussion started by: svp4444
6 Replies
Login or Register to Ask a Question