Operating System - HP-UX
1752796 Members
5901 Online
108789 Solutions
New Discussion юеВ

bdf is not reflecting properly.

 
SOLVED
Go to solution
bullz
Super Advisor

bdf is not reflecting properly.

Hello Gurus,

i am trying to capture bdf o/p into some text file.

since below mountpoint is showing in double line (as shown below).

/dev/sample/samplelvm
32768 1117 29680 4% /test

my script is picking only mountpoint name and percentage, but in this case my scripting picking worng data.
11 REPLIES 11
James R. Ferguson
Acclaimed Contributor

Re: bdf is not reflecting properly.

Hi:

This is a property of 'bdf' output for large filesystems. You might want to look at Bill Hassell's script which handles this and much, much more:

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

Regards!

...JRF...

Tingli
Esteemed Contributor

Re: bdf is not reflecting properly.

It is hard when scripting with bdf. Either you can manipulate your script to handle both single and double lines of bdf output, or you can use df -k which will have a consistent multi-line output.
TTr
Honored Contributor

Re: bdf is not reflecting properly.

If you want to stick with the system supplied bdf, once you parse the mountpoint, you can check if the bdf output starts with "/". If so, it is a single line output, otherwise it is a two-line output.

Then use awk to printout either field $4 or $5 to get the percentage.

If you need the device file for your mountpoint use the /etc/mnttab file.
bullz
Super Advisor

Re: bdf is not reflecting properly.

Folks,

Its very diffult to get output for double line mountpoints?

Any scripting? :(

mu bdf o/p is like this

Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 589824 383784 204480 65% /
/dev/vg00/lvol1 314736 58376 224880 21% /stand
/dev/vg00/lvol8 4718592 2795120 1908552 59% /var
/dev/vg00/lvol7 3801088 1711496 2073296 45% /usr
/dev/vg00/lvol4 229376 77440 150776 34% /tmp
/dev/vg00/test12 1048576 16725 967368 2% /sample
/dev/vg00/lvol6 4128768 2482416 1633528 60% /opt
/dev/vg00/lvol5 32768 8520 24064 26% /home
/dev/sample/samplelvm
32768 1117 29680 4% /test


TTr
Honored Contributor

Re: bdf is not reflecting properly.

You have to give a detailed description of what you are trying to do in your script with the percentages.
bullz
Super Advisor

Re: bdf is not reflecting properly.

Well, Hello all,

I am trying to do scripting for geting an alert for mountpoint.

wen i try to store the list of mountpoint name and used details to file as below

bdf | tail -$cnt | awk '{print $5"#"$6}' > /tmp/mountpoint.txt

cnt variable is to avoid the title of bdf o/p
But since bdf o/p in double line for few mountpoint, i am not bale to get the exact o/p which i want :(

65%#/
21%#/stand
59%#/var
45%#/usr
34%#/tmp
2%#/sample
60%#/opt
26%#/home
#
/test#
Mel Burslan
Honored Contributor

Re: bdf is not reflecting properly.

Here is a general purpose script I have provided to another similar question. SInce I do not know what your case is, I am providing the script as is. It is pretty easy to understand and you can make modifications as you wish. This script will alert you (using any method you like by replacing echo statements) when the filesystem utilization reaches a warning level and a critical level.

Hope this helps... Script follows:

#!/bin/bash
df | grep ^"/" > /tmp/filesystem_names

for fs in `cat /tmp/filesystem_names`
do
df $fs > /tmp/currFS
ln=`cat /tmp/currFS |grep -v ^Filesystem| wc -l`
case $ln in
2) perctg=`tail -1 /tmp/currFS|awk {'print $4'}|cut -d"%" -f1` ;;
1) perctg=`tail -1 /tmp/currFS|awk {'print $5'}|cut -d"%" -f1` ;;
*) echo "There was an error with volume ${fs}. Check manually" ;;
esac

if [ $perctg -ge 80 ] && [ $perctg -lt 90 ]
then
echo "replace this line with your WARNING action for volume $fs"
fi

if [ $perctg -ge 90 ]
then
echo "replace this line with your CRITICAL action for volume $fs"
fi
done
________________________________
UNIX because I majored in cryptology...
bullz
Super Advisor

Re: bdf is not reflecting properly.

Thanks for this, But i don't think so it can help me as i need to implement this on many servers. :(

Just i am facing problem only in bdf o/p
If some one help me to get the o/p of bdf wothout double line it would be gr8


James R. Ferguson
Acclaimed Contributor
Solution

Re: bdf is not reflecting properly.

Hi (again):

> Just i am facing problem only in bdf o/p

Well, then:

# bdf | awk '{if (NF==1) {line=$0;getline;sub(" *"," ");print line$0} else {print}}'

Regards!

...JRF...