Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

This is in UNIX and RHEL..need a script

Posted on 2013-05-13
4
Medium Priority
?
451 Views
Last Modified: 2013-07-24
I need  a script to run commands on all servers and get the output:

I want a script in AIX and Linux

login to server run lsvg vgname
rootvg
appvg

lsvg rootvg
TOTAL PPs:      135 (34560 megabytes)

get the below value and divide by 1024 and do the same for appvg

and then I need to sum up the total and give the value as below


server12  totalstorage 120Gb
server23  totalstorage 248Gb

I will put all the server name in servername.txt

cat servername.txt

server12
server23
server34
etc

I need the same for RHEL as well

like vgdisplay anf then get then sum up all the vg's

I have a common user id on all servers with the same password and would be able to get the output

Please provide all the steps to for this script.
0
Comment
Question by:aixtutorial
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39163801
Hi,

let's start with AIX:

while read server; do
  ssh -n userid@$server 'lsvg -o | lsvg  -i' |\
    awk -v HO=$server -F"\\\(|m" '
           /TOTAL PPs:/ {SUM+=$2}
            END {printf "%s totalstorage %.0fGB\n",HO,SUM/1024}'
done < servername.AIX.txt


Working on the Linux version ...
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39163813
Here it is:

while read server; do
  ssh -n user@$server 'vgdisplay' |\
   awk -v HO=$server '
          /VG Size/ {if($4=="TB") $3=$3*1024;  SUM+=$3}
            END {printf "%s totalstorage %.0fGB\n",HO,SUM}'
done < servername.Linux.txt


If you have Linux VGs < 1 GB or >= 1 PB please let me know!
0
 

Author Comment

by:aixtutorial
ID: 39166030
For AIX..is there anyway that I could append the output of all to a file

server12 totalstorage 471GB
server23 totalstorage 550GB
etc
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1400 total points
ID: 39166079
Of course there is - use output redirection.

Either add it to the script at the end of the "done" line:

while read server; do
  ssh -n userid@$server 'lsvg -o | lsvg  -i' |\
    awk -v HO=$server -F"\\\(|m" '
           /TOTAL PPs:/ {SUM+=$2}
            END {printf "%s totalstorage %.0fGB\n",HO,SUM/1024}'
done < servername.AIX.txt >> outputfile.txt

or add it to the command line when starting the script.

Assuming you called the script myscript:

myscript >> outputfile.txt

On Linux it's exactly the same!
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

721 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