- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Readable DF Script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2013 11:14 AM - last edited on 11-03-2013 07:23 PM by Lisa198503
11-01-2013 11:14 AM - last edited on 11-03-2013 07:23 PM by Lisa198503
Readable DF Script
Hello,
Recently I was asked by my DBA if there was a way to get bdf to list all output per device on one line. The bdf man pages indicated that if the device name was too long that it would insert a newline after the device name and list the space on the next line. Couple that with disk sizes that break the columnar display of the disk sizes adn you get a jumbled mess.
I had just written a quick script in awk to consolidate that data for working with something else, so I wrote rdf (readable df) to meet our needs. The script pipes the output from bdf into awk and reformats it to at least look nicer. The default output lists the logical volume name, all sizes formatted to two decimal places with a suffix, the percentage used, and the mount point. Calling rdf with a -l option causes all sizes to be displayed in Kbytes- useful for judging relative size. The decision to use the logical volume name stemmed from a desire to retain a level of identification but to shorten the name; this will not work well for environments that reuse names for logical volumes.
One flaw this script has (just realized it) is that is assumes an LVM device name and grabs the third part of the device path. If this is a direct drive mount or uses a volume manager that does not follow the /dev/<vg>/<lv> format then this will break.
Enjoy,
Mike
#!/bin/sh long=no while [ "$1" != "" ]; do case $1 in -l ) long=yes ;; esac shift done /bin/bdf | /bin/awk -v long=$long ' function resize(size) { fix="KMGTE" place=1 while (size >= 1000) { size = size / 1024.0 place++ } return sprintf("%5.2f%s", size, substr(fix, place, 1)) } BEGIN { if (long == "yes") { sizestr="Kbytes" sizelen=12 } else { sizestr="size" sizelen=7 } } { line=$0 if ($1 == "Filesystem") { fmtstr = sprintf("%%-15s %%%is %%%is %%%is %%5s %%s\n", sizelen, sizelen, sizelen) printf fmtstr, "Filesystem", sizestr, "used", "avail", "%used", "Mounted on" } else { if ($1 ~ /^\/.*/) { split($1, parts, "/") disk = parts[4] } if (length($2) > 0) { if ($1 ~ /^\/.*/) { size=$2 used=$3 free=$4 perc=$5 } else { size=$1 used=$2 free=$3 perc=$4 } mopos=index(line, "% /")+2 mount=substr(line, mopos) if (long == "yes") printf fmtstr, disk, size, used, free, perc, mount else printf fmtstr, disk, resize(size), resize(used), resize(free), perc, mount } } } '
P.S. This thread has been moved from HP-UX-General to HP-UX-languages. -HP Forum Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2013 11:19 AM
11-01-2013 11:19 AM
Re: Readable DF Script
>get bdf to list all output per device on one line
Bill has a bdfmegs script:
http://h30499.www3.hp.com/t5/LVM-and-VxVM/rbdf-script/m-p/6180027#M51190
- Tags:
- bdfmegs