
#!/bin/sh
# File	: get_FilerNICs_info.sh
# By	: Maarten.deBoer@atos.net, 120420
# Subject	: Scripts to collect FilerNICs 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
  ${SSH} ${FILER} ifconfig -a|grep flags|awk '{print $1}'|cut -d\: -f1|while read IF
  do
echo ${FILER}-${IF}
    INET="`${SSH} ${FILER} ifconfig ${IF}|grep inet|awk '{print $2}'`"
    MASK="`${SSH} ${FILER} ifconfig ${IF}|grep inet|awk '{print $4}'`"
# Getting GW in 2 stages from /etc/rc
    VFILER="`${SSH} ${FILER} rdfile /etc/rc|grep -v ^#|grep ${IF}|grep ifconfig|grep -v hostname`"
    if [ "${VFILER}" != "" ]; then
      GW="`${SSH} ${FILER} rdfile /etc/rc|grep ${VFILER}`"
    else
      GW="gw"
    fi
NWBUBLE="bubble"
VLAN="vlan"
SW="sw"
PORT="po"
CABLE="cbl"
    REMARKS="`${SSH} ${FILER} ifconfig ${IF}|grep ether|cut -d\( -f2|cut -d\) -f1`"
    echo "${LANDSCAPE}|${FILER};${IF};${INET};${MASK};${GW};${NWBUBLE};${VLAN};${SW};${PORT};${CABLE};${REMARKS};"|tee -a ${TMP}
  done

done

#cat ${TMP} | uuencode ${CSV}|mailx -s ${CSV} ${MAILTO}
#echo "Mailed to ${MAILTO}"
rm ${TMP}
exit 0

