Well, I had another task for today … I have an amount of FlexVolumes (sixty currently per controller), and I didn’t know if we had any, that didn’t have any LUNs on them. Now I thought there was a command for that since my co-worker mentioned something like that. However, once again … there isn’t.

 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
#!/bin/bash

MAILTO="san@barfoo.org"
KEY_FILE="/root/.ssh/netapp.dsa"
SSH_OPTS="/root/.ssh/netapp-ssh_config"
FAS_CTRL=$1
TMPDIR="$( mktemp -d )"

ssh_fas() {
  # $@: commands for Data ONTAP
  COMMANDS="$@"
  /usr/bin/ssh -i $KEY_FILE -l root -F $SSH_OPTS $COMMANDS
}

# Get the hostname of the controller, necessary for the reporting
CTRL_HOSTNAME="$( ssh_fas $FAS_CTRL rdfile /etc/rc | grep ^hostname |
  cut -d  -f2 | tr 'a-z' 'A-Z' )"

# Get a list of all volumes / luns
VOL_LIST="$( ssh_fas $FAS_CTRL vol status | grep ^vol |
  egrep -v '(nfs|cifs)' | awk '{ print $1 }' )"
LUN_LIST="$( ssh_fas $FAS_CTRL lun show | grep '/vol' |
  awk '{ print $1 }' )"

for lun in $LUN_LIST; do
  VOL_EXTRACT="$( echo $lun | cut -d/ -f3 )"
  VOL_LIST=${VOL_LIST/${VOL_EXTRACT}/}
done

for vol in $VOL_LIST; do
  echo "Empty Flex Volume: $vol."
done > $TMPDIR/mailcontent

if [ "$( grep Flex $TMPDIR/mailcontent )" ] ; then
  cat $TMPDIR/mailcontent | mailx -r $MAILTO
    -s "$CTRL_HOSTNAME: Empty volume check" $MAILTO
fi

rm -r $TMPDIR