
#!/bin/sh
# File	: get_VIPAddresses_info.sh
# By	: Maarten.deBoer@atos.net, 120420
# Subject	: Scripts to collect VIPAddresses info (for CMDB filling)
PGM="`basename $0|cut -d\. -f1`"
TMP="/tmp/${PGM}.$$"
CSV="${PGM}.csv"
MAILTO="maarten.deboer@atos.net"
SSH="/usr/bin/ssh -n"
FILERS=${HOME}/etc/filers_cmdb
LANDSCAPE="FSOD-Atos"
for FILER in `cat $FILERS|grep -v \#`
do
  echo "${FILER} ..."
  ${SSH} ${FILER} vfiler status|grep -v vfiler|awk '{print $1}'|while read VFILER
  do
IPSPACE="`${SSH} ${FILER} vfiler status -r ${VFILER}|grep ipspace|cut -d\: -f2`"
NWBBL="<bubble>"
VLAN="<vlan>"
VFILERSTATUS="`${SSH} ${FILER} vfiler status ${VFILER}|awk '{print $2,$3,$4}'`"
REMARKS="vfilerstatus:${VFILERSTATUS}"
    ${SSH} ${FILER} vfiler status -r ${VFILER}|grep 'IP address'|cut -d\: -f2|while read IPADDR IF
    do
      echo ${IPADDR} ${IF}
      INTERFACE="`echo ${IF}|cut -d\[ -f2|cut -d\] -f1`"
      NWBBL="`echo ${INTERFACE}|cut -d\- -f2`"
      VLAN="`echo ${INTERFACE}|cut -d\- -f3`"
      echo "${LANDSCAPE}|${FILER}|${VFILER};${IPADDR};${IPSPACE};${INTERFACE};${NWBBL};${VLAN};${REMARKS};"|tee -a ${TMP}
    done
  done
done
cat ${TMP}|uuencode ${CSV}| mailx -s ${CSV} ${MAILTO}
echo "Mailed to ${MAILTO}"
rm ${TMP}
exit 0

