- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: disk usage 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
Forums
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
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
08-19-2009 05:20 AM
08-19-2009 05:20 AM
I need a script which has to give following outputs..
1.number of VG presence with VG name
2.Total+used+free space per VG
please help on this
Regards
himacs
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 05:44 AM
08-19-2009 05:44 AM
Re: disk usage script
strings /etc/lvmtab | grep "^/dev" | /grep -v "/dev/dsk"| wc -l
# usage
for vg in `strings /etc/lvmtab | grep -v "/dev/dsk"`
do
pesize=`vgdisplay $vg | grep "^PE Size"|awk {'print $4'}
usedpe=`vgdisplay $vg | grep "^Alloc PE"|awk {'print $3'}
(( usedmb=${usedpe}*${pezise} ))
freepe=``vgdisplay $vg | grep "^Free PE"|awk {'print $3'}
(( freemb=${freepe}*${pezise} ))
echo "${vg} has ${usedmb} MBs used and ${freemb} MBs free space"
done
hope it helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 05:47 AM
08-19-2009 05:47 AM
Re: disk usage script
Actually i have a script but it throws error while executing..
#This pgm will display Total, Used and Free size(in MB) of all vgs in a system
system("vgdisplay |grep -e 'Name' -e 'Total PE' -e'Alloc' -e'Free'|cut -b 29- >/tmp/bdf.out");
print("Name\t Total MB\tUsed MB\tAvailable MB\n");
open (BDF,"/tmp/bdf.out");
$line=
chop $line;
while ($line ne "")
{
if ($line =~/vg/){
$count=1;
}
while($count < 5){
if($count > 1){
$line=$line*$pe_size;
}
else {
&get_pe_size;
}
print("$line \t");
$line=
chop $line;
++$count;
}
print("\n");
}
sub get_pe_size {
$vgname="vgdisplay $line";
open (WOUT,"$vgname |grep Mbyte|cut -b 28-30|");
$pe_size=
chop $pe_size;
}
eror is - free[3]: Syntax error at line 3 : `(' is not expected.
Plz let me know what causes this error..
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 06:14 AM
08-19-2009 06:14 AM
Solution> Actually i have a script but it throws error while executing..
Then _SAY_SO_.
Aside from your script being terribly un-Perlish it _IS_ a perl script and thus needs to be indentified as such.
Every good script needs to declare the interpreter it wants to use in a "she-bang" line. Failure to do so means that a shell is assumed.
Add this as the first line of your script:
#!/usr/bin/perl
...or if that fails:
#!/usr/bin/env perl
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 06:26 AM
08-19-2009 06:26 AM
Re: disk usage script
Thanx for the guidance..its worked
i added #!/usr/bin/perl as interpreter.
The same script i got from itrc after posting this thread..
anyway thanx once again..
Hi Mel ,
I executed the script suggested by u,but some errors..
./freetest[11]: /dev/vg00: Execute permission denied.
./freetest[12]: usedmb=* : Syntax error
anyhow i found ineterest ininformation in scripting with ur help.. thanx
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 06:56 AM
08-19-2009 06:56 AM
Re: disk usage script
here is a working copy:
for vg in `strings /etc/lvmtab | grep -v "^/dev/dsk" | grep "^/dev"`
do
pesize=`vgdisplay $vg | grep "^PE Size"|awk {'print $4'}`
usedpe=`vgdisplay $vg | grep "^Alloc PE"|awk {'print $3'}`
usedmb=`echo "${usedpe}*${pesize}" | bc`
freepe=`vgdisplay $vg | grep "^Free PE"|awk {'print $3'}`
freemb=`echo "${freepe}*${pesize}" | bc`
echo "${vg} has ${usedmb} MBs used and ${freemb} MBs free space"
done
HTH
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 07:20 AM
08-19-2009 07:20 AM
Re: disk usage script
One more thing..
I want to display total PVs present in VG also..
how can we edit the same script to achieve thhat..
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 07:28 AM
08-19-2009 07:28 AM
Re: disk usage script
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 07:28 AM
08-19-2009 07:28 AM
Re: disk usage script
in my script you can put this line before the echo statement and on the echo line, incorporate the pvcount into printable variables as you desire.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 07:32 AM
08-19-2009 07:32 AM
Re: disk usage script
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 08:41 AM
08-19-2009 08:41 AM
Re: disk usage script
Thanx for the info..
If i want to direct the output where should i add >/tmp/disk.out
I tried with adding in the end of echo line but ended up with directing ony VG00 info..
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 08:44 AM
08-19-2009 08:44 AM
Re: disk usage script
to use > (single redirect) do it after the word "done", for example:
...
echo "blah-blah..."
done > /tmp/myreport.txt
HTH
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 08:49 AM
08-19-2009 08:49 AM
Re: disk usage script
> One more thing..I want to display total PVs present in VG also.
One way is to add this section of Perl code to the end of what you have:
my ( $fh, $vgname, $nbrpvs );
open( my $fh, '-|', '/sbin/vgdisplay' ) or die $!;
while (<$fh>) {
$vgname = $1 if m{^VG Name\s+(.+)};
$nbrpvs = $1 if m{^Act PV\s+(.+)};
if ( defined $vgname and defined $nbrpvs ) {
printf "%-12s = %02d PVs\n", $vgname, $nbrpvs;
undef $vgname;
}
}
I would rewrite the whole script in this fashion...using an piped open() to read the output of 'vgdisplay'. The caret (^) means match at the beginning of a line. The '\s+' means one or more whitespaces (tabs, spaces, etc.). The '.+' means one or more of any character and by enclosing it in parentheses we capture whatever is seen in the '$1' variable.
As you can see, the whole script could be re-factored into a loop driven by the above.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2009 07:31 AM
09-25-2009 07:31 AM
Re: disk usage script
If you're familiar with perl, there's an HPUX::LVM perl module on CPAN that automatically parses vgdisplay/lvdisplay/pvdisplay into a perl hash. Once you get the data into a hash table, generating custom LVM reports should be trivial.
Caveats: I saw the module a while back but haven't actually tried it. Also, it appears to be based on LVMv1, so may cause problems on 11i v3.
Take a look at http://search.cpan.org/~cwhite/HPUX-LVM_0.06/LVM.pm. There's a complete sample script at the top of the page.
Other related CPAN modules include:
HPUX::Ioscan.pm
HPUX::FS.pm
HPUX::LVM.pm
If you have 11i v3 vith the latest version of LVM, there's a new option on vgdisplay that displays VG information in a format that's easier to parse with perl/awk/etc:
vgdisplay -F
Darren