?
Solved

Shell Script to grab some size of disks from some servers

Posted on 2008-11-10
8
Medium Priority
?
328 Views
Last Modified: 2012-08-14
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

0
Comment
Question by:jdenver247
  • 4
  • 3
8 Comments
 
LVL 19

Expert Comment

by:jools
ID: 22922647
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.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 22922649
Hi,
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!
 
wmp
 
 

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

Open in new window

0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22922713
... and I strongly agree with jools - please add this Q to the AIX zone.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jdenver247
ID: 22922919
Sure I will add this in the AIX zone
0
 

Author Comment

by:jdenver247
ID: 22922984
Hello,
I changed the code  lil bit.. to print the the queue_dept and here is the output

aixserver27:
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
aixserver27:
hdisk6: queue_depth     256                            
hdisk8: queue_depth     256                              
hdisk9: queue_depth     256                              
hdisk11: queue_depth     256                              

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

Open in new window

0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22923104

Hi, change line 9 to -
 
lsattr -El $disk | awk "/queue_depth/ {print \$1, \$2}"
0
 

Author Comment

by:jdenver247
ID: 22923178
thanks a lot its working now
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22923198
You're welcome!
Have fun and success!
 
Norbert (wmp)
 
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question