Shell Script to grab some size of disks from some servers

I have 21 AIX  servers from which I need to collect the size of all SAN disks attached to each server. I have rsh enabled. I need an output something like this

Server 1 :
hdisk0       73000mb
hdisk1       73000mb

Server 2 :
hdisk 0     73000mb

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian ParkerSenior Systems AdministratorCommented:
first of all you may want to see if you can add the AIX group to this Q.

How the script it written will depend on how your disks are reported onto the system.
Post the following listings back here;
   lsdev -Ccdisk
   lscfg | grep disk
   lscfg -vpl hdisk1

I sure someone will be able to knock something up.
I think I have a nice one for you (attached)
Things to consider -
1. You must provide a file containing your hostnames, one by line (my 'sanhosts', line 2).
2. I used ssh, please change to rsh as needed. I don't run rsh, so I can't test.
3. To find out which disk is a SAN disk, I searched for 'FC 2107' (line 6). Change it according to your environment.
4. The disks must be in some volume group, and it must be AIX.
5. I'm not _that_ awk specialist. One surely could make it look nicer there.
Have fun!

for srv in $(cat ~/sanhosts)
ssh $srv \
     'echo \\n$(/usr/bin/hostname):
     for disk in  $(lscfg |grep hdisk | grep "FC 2107" | cut -f2 -d " ")
      echo ${disk}: \\c
      lspv $disk | awk "/TOTAL PPs:/ {print \$4 \$5}" | tr -d "()" | sed "s/megabytes/ mb/"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
... and I strongly agree with jools - please add this Q to the AIX zone.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

jdenver247Author Commented:
Sure I will add this in the AIX zone
jdenver247Author Commented:
I changed the code  lil bit.. to print the the queue_dept and here is the output

hdisk6: queue_depth     256                              Queue DEPTH                      True
hdisk8: queue_depth     256                              Queue DEPTH                      True
hdisk9: queue_depth     256                              Queue DEPTH                      True
hdisk11: queue_depth     256                              Queue DEPTH                      True

How do I trim the output just to get
hdisk6: queue_depth     256                            
hdisk8: queue_depth     256                              
hdisk9: queue_depth     256                              
hdisk11: queue_depth     256                              

for srv in $(cat dwprod)
rsh $srv \
     'echo \\n$(/usr/bin/hostname):
     for disk in  $(lscfg |grep hdisk | grep "NetApp" | cut -f2 -d " ")
      echo ${disk}: \\c
      lsattr -El $disk |grep queue_depth

Open in new window


Hi, change line 9 to -
lsattr -El $disk | awk "/queue_depth/ {print \$1, \$2}"
jdenver247Author Commented:
thanks a lot its working now
You're welcome!
Have fun and success!
Norbert (wmp)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.