Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: how can i get size of block device (perl, shell script)

 
SOLVED
Go to solution
James R. Ferguson
Acclaimed Contributor

Re: how can i get size of block device (perl, shell script)


@support_billa wrote:

more questions :

1. best way to parse "bdf", when it reports is over 2 lines :


You seem to have solved this.  Bill Hassell has a very nice script that handles 2-line 'bdf' output and adds lots of useful information in addition to improving the output formatting.  See this thread for a copy:

 

http://h30499.www3.hp.com/t5/System-Administration/bdfmegs-version-5-8-available/m-p/4673433/highlight/true#M381988

 


@support_billa wrote:

more questions :

 

2. questions to "df" and "bdf"

 

i have a large fs and "df" reports 100 % usage , "bdf" 99 % usage :


Different tools often use different methods to deduce things.  You are quibbling over small differences.  What exactly is the problem you are attempting to solve?  It seems that this is becoming an academic exercise rather than one to solve a real-world problem.

 

That said, look at the 'df' and 'bdf' manpages.  From 'df(1M)', "The df command displays the number of free 512-byte blocks and free inodes available for file systems by examining the counts kept in the superblock or superblocks."   In contrast, from 'bdf(1M)', "Non-HFS file systems may have other items not accounted for by this command."

 

Regards!

 

...JRF...

support_billa
Valued Contributor

Re: how can i get size of block device (perl, shell script)


@Bill Hassell has a very nice script that handles 2-line 'bdf' output 
@_________________________________________________________________________________________________________
@ http://h30499.www3.hp.com/t5/System-Administration/bdfmegs-version-5-8-available/m-p/4673433/highlig...

thank you

i have a large fs and "df" reports 100 % usage , "bdf" 99 % usage :

sorry, maybe i am quibbling over small differences.
i was looking about a command to save easy in a shell variable the value of the block device size .
i thought , this would be a short task , i know "bdf" and "df" and i hope that a perl function will exist ...
perl module exists, but not in a core module , so i read "bdf" and "df" man pages and then i detected those
difference above :-( i asked also my colleagues , they had also no  explanation.

From 'df(1M)' : there are a lot of options, which i didn't know it before and i read it exactly and only "df -g"
shows exact the same value (without multiply , divide ..) like "bdf"

you explain the difference very good , so i understand it know.

finaly , i also don't like to write a degree dissertation about those commands !
so i will stop it now and thanks to your great response

VK2COT
Honored Contributor

Re: how can i get size of block device (perl, shell script)

Hello,

 

Why reinvent the wheel when you can use simle tools native to HP-UX:

 

# /opt/ignite/bin/print_manifest

...

File System layout

    LVM Device file            mount point     size  fs type
    /dev/vg00:
    /dev/vg00/lvol1            /stand          1792  vxfs
    /dev/vg00/lvol2            swap            4096
    /dev/vg00/lvol3            /               95584 vxfs
    /dev/vg00                  unallocated     0
    /dev/vg01:
    /dev/vg01/lvol10           /guests1        149984vxfs
    /dev/vg01                  unallocated     3584

Or,

 

# /usr/sam/lbin/lvlist -p
/dev/vg00/lvol1|/dev/vg00|vxfs|1792|0|LVM|/stand|266240|available/syncd|1
/dev/vg00/lvol2|/dev/vg00|swap/dump|4096|0|LVM|-|131330|available/syncd|1
/dev/vg00/lvol3|/dev/vg00|vxfs|95584|0|LVM|/|266240|available/syncd|1
/dev/vg01/lvol10|/dev/vg01|vxfs|149984|0|LVM|/guests1|266240|available/syncd|1

Or,

 

# /usr/sam/lbin/vginfo -v
vg00:available,read/write@:255:16:3:1:0:32:3737:101472:0:0:3171:0:0:/dev/vg00/lvol1@available/syncd@1792@56@1,/dev/vg00/lvol2@available/syncd@4096@128@1,/dev/vg00/lvol3@available/syncd@95584@2987@1:/dev/disk/disk12_p2@@available@3171@0::LVM
vg01:available,read/write@:16:16:1:1:0:32:4799:153568:3584:112:4799:0:0:/dev/vg01/lvol10@available/syncd@149984@4687@1:/dev/disk/disk31@@available@4799@112::LVM
slvm_dsk1:available,shared,client,read/write@brk13,brk11:2047:2048:0:1:0:4:51200:204788:204788:51197:51197:0:0::/dev/disk/disk13@@available@51197@51197::LVM

All these commands can pe parsed and proper information extracted easily.

 

VK2COT

VK2COT - Dusan Baljevic
H.Merijn Brand (procura
Honored Contributor

Re: how can i get size of block device (perl, shell script)

I'm in the middle of a discussion with the author of the "Disk Info" utility di which is also available for HP-UX..

This utility works on HP-UX as well as on all other Unix-like OS's and gives the output the same on allOS's.

 

I've talked him into implementing a new -c option to generate the output as csv, so it is extremely easy to parse.

If you are interested, keep your eyes open on  http://www.gentoo.com/di/

Enjoy, Have FUN! H.Merijn
support_billa
Valued Contributor

Re: how can i get size of block device (perl, shell script)

hello VK2COT,

 

@ Why reinvent the wheel when you can use simle tools native to HP-UX

@ All these commands can pe parsed and proper information extracted easily.

 

i have been working with HP-UX for many years and i have never heard about those commands !!!!

These are great commands and easy to parse !

 

Does a white paper exists about those commands ? I didn't find man pages !

 

i use for example  :

/usr/sam/lbin/fslist -p /tmp

 

and i can interprete many columns , but when i have informations what column include what value it is easier !

 

regards

 


VK2COT
Honored Contributor

Re: how can i get size of block device (perl, shell script)

Hello,

 

It is my pleasure to share information.

 

Yes, I know that these commands are not known to majority of users :)

 

I am a Senior Instructor in HP Education and IT Architect in Australia/New Zealand

(teaching all sorts of HP-UX, Solaris, LInux (Red Hat, SUSE and Ubuntu), 3PAR,

ServiceGuard, Data Protector, EVA and Ibris X9000 NAS courses. I am also

a Wordwide Unix Ambassador and Unix Profession Leadership team at HP

so it is lot of fun for me to work on unsual things.

 

Unfortunately, there are no manuals on these rare commands that I listed yesterday..

Some of the commands in ./usr/sam/lbin and Shell scripts and the only way to

learn what they do is to look into them.

 

Let me show some other intresting commands in this directory:

 

# paginglist

/dev/vg00/lvol2|dev|4194304|4.0 GB|0|0.0 KB|4194304|4.0 GB|0%|0|-|1|no|now|
reserve|reserve|0|0.0 KB|3667436|3.5 GB|-3667436|-3667436`KB||0||0|no|now|
total|total|4194304|4.0 GB|3667436|3.5 GB|526868|514.5 MB|87%|0|0|0|no|now|

# importablevgs
1:/dev/disk/disk11_p2

 

And then new way to check ServiceGuard:

 

# /opt/OV/bin/ovclusterinfo -a

 

This command supports other types of clusters:

 

           - Microsoft Clustering Services (Windows)

           - MC/ServiceGuard (HP-UX)

           - VERITAS Cluster Server (Solaris)

           - Sun Cluster (Solaris)

           - TRU64 Cluster (TCR)

           - Red Hat Advanced Server (RHAS)

           - HACMP (AIX)

           - Unknown.

If you want to learn more of the "unusual" commands take a look at my

Operations Acceptance Testing Perl script for HP-UX:

 

http://www.circlingcycle.com.au/Unix-sources/

 

Cheers,

 

VK2COT

VK2COT - Dusan Baljevic
H.Merijn Brand (procura
Honored Contributor

Re: how can i get size of block device (perl, shell script)

After maybe 40 mails with the author of di, I am glad to say that the just release new version 4.29 works on all HP-UX that I could access, ranging from 10.20 +DAportable to 11.31 with gcc/64
I have uploaded the depots to my site which should be in sync within 20 hours, so feel free to grab your copy. Some examples:

$ di -l -c
s,m,b,u,v,p,T
/dev/vg00/root,/,"400.0M","333.2M","66.3M",83%,vxfs
/dev/vg00/data,/data,"12.0G","11.3G","0.6G",95%,vxfs
/dev/vg00/home,/home,"512.0M","265.1M","246.9M",52%,vxfs
/dev/vg00/opt,/opt,"6.5G","6.1G","0.4G",95%,vxfs
/dev/vg00/pro,/pro,"24.0G","22.2G","1.8G",93%,vxfs
/dev/vg00/stand,/stand,"304.0M","183.2M","119.9M",61%,vxfs
/dev/vg00/tmp,/tmp,"2.0G","0.8G","1.2G",40%,vxfs
/dev/vg00/usr,/usr,"5.3G","2.2G","3.1G",42%,vxfs
/dev/vg00/var,/var,"4.5G","1.8G","2.7G",41%,vxfs
/dev/vg00/wrk,/wrk,"1.0G","0.3G","0.6G",37%,vxfs
$ di -c >di.csv
$ env DBI_DSN="dbi:CSV:f_ext=.csv/r" qs -L f di w p '>' 90
SCHEMA: merijn, TABLE: di
[.]
select    s, m, b, u, v, p, t
from      di
where     p > '90'
s             |m      |b    |u    |v   |p  |t
/dev/vg00/data|/data  |12.0G|11.3G|0.6G|95%|vxfs
/dev/vg00/opt |/opt   |6.5G |6.1G |0.4G|95%|vxfs
/dev/vg00/pro |/pro   |24.0G|22.2G|1.8G|93%|vxfs
$

qs is a perl script that acts as a command-line SQL query interpreter (qs = quick select), and used here just to demonstrate how easy the output of the new -c option for di is parsable (as a database). 

Enjoy, Have FUN! H.Merijn