-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwasteStorageGroupList
More file actions
102 lines (86 loc) · 3.46 KB
/
Copy pathwasteStorageGroupList
File metadata and controls
102 lines (86 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
#
# This script collects the LUNs that has the usage less than the given parameter
# It requires 2 parameters to run, first is SID, second is percentage
#
#
# Author: Geri
# Version: 0.1, first working version
# Date: 2019. 06. 07.
#
# The output format is 'tab' delimited
# Sym TotalGBs AllocateGBs Used_% UsedGBs StorageGroup(s)
# 00032 20.0 1.8 10 1.8 DC01VB6PF12ESXP0X_CLUSTER_SG
# 0003B 125.0 12.0 9 12.0 QNXT53_DC01Q53RPTDBP14_DB_SG,(IsChild) QNXT53_DC01Q53RPTDBP14_SG,(IsParent)
#
# One line, one device. If it is in more then one SG, all will be listed
#
if [ $# -lt 2 ]; then
echo "You need to provide the SID number that you want to check, and the percentage"
echo "Exiting..."
exit
fi
Debug=false
if [ "$3" == "-debug" ]; then
Debug=true
fi
SID=$1
PercentLimit=$2
tempFile="DeviceTempFile"
noName="noName"
wrongPool="wrongPool"
OutputPath="\\\\ServerRoot\\Directory\\_OutputDirectory" # The idea is to put all the output into the same folder every time. It is designed
# to run in a system that can handle UNC paths, like Cygwin
if [ $PercentLimit -gt 99 ]; then
echo "The percentage you want to collect info about, is greater than 99 ($PercentLimit). Please check!"
echo "Exiting..."
exit
fi
PercentCheck=$((PercentLimit+1)) # Make the given parameter the max number included
Pools=`symcfg -sid $SID list -pool | grep RAID | awk '{print $1}'`
echo "Starting with the pools on ${SID}..."
if $Debug; then
echo $Pools
fi
for pool in $Pools; do
echo "Working on pool $pool..."
# output format: FFE1F 383.1 83.1 300.0 78 . Enabled
symcfg -sid $SID show -pool $pool -thin -gb -detail 2>$wrongPool | awk '/Other Thin Devices/{print $0}' RS="}" | sed '1,12d' | tac | sed '1,3d' | sort -k 5 | dos2unix >$tempFile
if [ ! -s $tempFile ] ; then
echo "The thin pool $pool does not exist, does not have thin device in it, or something is wrong. Going for the next pool..."
continue
fi
resultFile="DevUsage__${SID}__${pool}"
#resetting the old result file... We put the SID and pool name into the first line, easier in excel
printf "${SID}_${pool}\n" > $resultFile
#This is the header
printf "LUN ID\tDevice Name/Datastore/Mount Point\tTotal [GB]\tAllocated [GB]\tPercent [\x$(printf %x 37)]\tPoolUsed [GB]\tStorage Group I\tStorage Group II\n" >> $resultFile
while read myLine; do
#Read in the values from the line
dev=`echo $myLine | awk '{print $1}'`
total=`echo $myLine | awk '{print $3}'`
allocated=`echo $myLine | awk '{print $4}'`
percent=`echo $myLine | awk '{print $5}'`
poolused=`echo $myLine | awk '{print $6}'`
if $Debug; then
printf "Pool $pool...\n"
printf "Line: $myLine\n"
printf "Variables: $dev, $total, $allocated, $percent, $poolused\n"
fi
if [ $percent -lt $PercentCheck ]; then
devName=`symdev -sid $SID list -identifier device_name -dev $dev 2>$noName | sed '1,7d' | awk '{print $3}'`
if [ -s $noName ]; then
devName="TheDevHasNoName!"
fi
myStorGrps=`symaccess -sid $SID list -dev $dev -type storage -v | grep "Storage Group Name" | awk -F\: '{print $2}' | sed 's/^ //' | tr "\r\n" "," | sed 's/,,/\t/g' | sed 's/ /,/g'`
echo $dev $devName $total $allocated $percent $poolused $myStorGrps | sed 's/ /\t/g' | tee -a $resultFile
else
echo "I reached the limit \"$PercentLimit\", exiting the while loop!"
break
fi
#done
done < $tempFile
mv $resultFile $OutputPath
done
#cleaning up
rm -f $tempFile $noName $wrongPool