
#!/bin/sh
# File  : loop_filers_vfilers.sh
# By    : Maarten.DeBoer@Atos.net, 121026
# Subject       : A Loop-script to Send some command to all filers & vfilers
PGM="`basename $0|cut -d\. -f1`"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
FILERS="${HOME}/etc/filers"
SSH="/usr/bin/ssh -n"
CSV="${TMP}.csv"
MAILTO="maarten.deboer@atos.net"

for FILER in `cat ${FILERS}|grep -v \^#|sort`
do
  echo -n "${FILER}; ;"|tee -a ${CSV}
  ${SSH} ${FILER} options cifs.max_mpx|awk '{print $1";"$2";"}'|tee -a ${CSV}
  ${SSH} ${FILER} vfiler status|grep running|grep -v vfiler0|awk '{print $1}'| while read VFILER
  do
    echo -n "${FILER};${VFILER};"|tee -a ${CSV}
    ${SSH} ${FILER} vfiler run -q ${VFILER} options cifs.max_mpx|awk '{print $1";"$2";"}'|tee -a ${CSV}

  done  #VFILER
done  # FILER

cat ${CSV}|uuencode ${PGM}.csv|mailx -s "${PGM}.csv" ${MAILTO}

rm ${CSV}
exit 0

