aixtutorial
asked on
This is in UNIX and RHEL..need a script
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.
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.
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!
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!
ASKER
For AIX..is there anyway that I could append the output of all to a file
server12 totalstorage 471GB
server23 totalstorage 550GB
etc
server12 totalstorage 471GB
server23 totalstorage 550GB
etc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 ...