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

touch ${TMP}

for FILER in `cat ${FILERS}|grep -v \^#|sort`
do
  ${SSH} ${FILER} vfiler status|grep running|grep -v vfiler0|awk '{print $1}'| while read VFILER
  do
    echo "${FILER}/${VFILER}:"|tee -a ${TMP}

#    ${SSH} ${FILER} vfiler run -q ${VFILER} lun show|tee -a ${TMP}
#    ${SSH} ${FILER} vfiler run -q ${VFILER} iscsi initiator show|tee -a ${TMP}
#    ANSW="`${SSH} ${FILER} vfiler status -a ${VFILER}| grep vio`"
#    if [ "${ANSW}" != "" ]; then
# Vfiler in Violet
#       echo "  Violet"|tee -a ${TMP}
#       ${SSH} ${FILER} vfiler run -q ${VFILER} cifs sessions|grep pcuser|wc -l|tee -a ${TMP}
#    fi

#    ${SSH} ${FILER} vfiler run -q ${VFILER} cifs domaininfo|grep Domain|tee -a ${TMP}
#    ${SSH} ${FILER} vfiler status -a ${VFILER}|grep address |tee -a ${TMP}
    ${SSH} ${FILER} vfiler run ${VFILER} cifs sessions|tee -a ${TMP}


  done  #VFILER
done  # FILER

date|mailx -a ${TMP} -s "${PGM}" ${MAILTO}

rm ${TMP}
exit 0

