Operating System - HP-UX
1832609 Members
2479 Online
110043 Solutions
New Discussion

Re: shell about diskinfo and total size

 
chin hyeon jung
Advisor

shell about diskinfo and total size

I made following shell script becasue I want to see the resul of total size of disk
But it takes long time and show different result waht I expect
I want to see
TOTAL DISK SIZE= xxx.xxGB
How can I get this result help me ! !

########## disk script#######
#!/usr/bin/sh
/sbin/ioscan -fknC disk|awk '{print $1}'|grep -v disk|sed 's/^=*//g;s/Class//g;s/dsk/rdsk/g' 1>emcoutfile 2>/dev/null
sub=0
for disk_name in `cat emcoutfile` ; do
disk=$(/usr/sbin/diskinfo $disk_name|grep size|awk '{print$2}')
sub=$sub+$disk
done
echo "INTERNAL DISK SIZE=($sub/1024)/1024 GB"
#
6 REPLIES 6
Scott Van Kalken
Esteemed Contributor

Re: shell about diskinfo and total size

you could just go to /dev/rdsk/ and run the same on each rdsk file.. this would speed life up because you wouldn't need to do an ioscan.
chin hyeon jung
Advisor

Re: shell about diskinfo and total size

Um I must run ioscan and do not use /dev/rdsk/*
what I want to know is that
How could I calculate the total size of some disk ; like internal disk, external disk , emc disk and so on
To get the information I divided some groups and willing to running that script.
In this point I can't show the exact result.

Do you have any good idea or better formula ?
Vijeesh CTK
Trusted Contributor

Re: shell about diskinfo and total size

hi

use like this

sub=`expr $sub + $disk`
done
sub=`expr $sub / 1024`
sub=`expr $sub / 1024`
echo "INTERNAL DISK SIZE = $sub GB"


CTK
chin hyeon jung
Advisor

Re: shell about diskinfo and total size

Um I still failed
the result like this
########## disk script#######
#!/usr/bin/sh
/sbin/ioscan -fknC disk|awk '{print $1}'|grep -v disk|sed 's/^=*//g;s/Class//g;s
/dsk/rdsk/g' 1>emcoutfile 2>/dev/null
sub=0
for disk_name in `cat emcoutfile` ; do
disk=$(/usr/sbin/diskinfo $disk_name|grep size|awk '{print$2}')
sub=`expr $sub+$disk`
done
sub=`expr $sub/1024`
sub=`expr $sub/1024`
echo "INTERNAL DISK SIZE=$sub GB"
#
hanatest:/tmp/jj]./je
INTERNAL DISK SIZE=0+4194157+4194157+4194157+4194157+4194157+0/1024/1024 GB
But I want to see INTERNAL DISK SIZE= 20GB
chin hyeon jung
Advisor

Re: shell about diskinfo and total size

OK Now I hav got it HAHAHA
It was very simple problem
The point is that ; numeric or not
So I put following letter typeset -i sub=0
and then I got it
hanatest:/tmp/jj]./je
INTERNAL DISK SIZE=19 GB
Thanks All
Vijeesh CTK
Trusted Contributor

Re: shell about diskinfo and total size


hi

########## disk script#######
#!/usr/bin/sh
/sbin/ioscan -fknC disk|awk '{print $1}'|grep -v disk|sed 's/^=*//g;s/Class//g;s/dsk/rdsk/g' 1>emcou
tfile 2>/dev/null
sub=0
for disk_name in `cat emcoutfile` ; do
disk=$(/usr/sbin/diskinfo $disk_name|grep size|awk '{print$2}')
sub=`expr $sub + $disk`
done
sub=`expr $sub / 1024`
sub=`expr $sub / 1024`
echo "INTERNAL DISK SIZE = $sub GB"

put space near + , / etc

CTK