
#!/bin/sh
# File	: check_ip-addresses.sh
# By	: Maarten.deBoer@Atos.net, 160518
# Subject	: Script to check Filer IP-adresses for 161 from /appl/asup/data/
PGM="`basename $0|cut -d\. -f1`"
VER="0.1"
TMP="/tmp/${PGM}.$$"

BASEDIR="`pwd | sed 's/scripts//'|sed 's/bin//'`"
LOG="${BASEDIR}/log/${PGM}.log"

ASUPDATADIR="/appl/asup/data"

echo "`date` ${PGM} v${VER} started."|tee -a ${LOG}
touch ${TMP}

cd ${ASUPDATADIR}
ls -1 | while read LINE
do
  IPADDRESS=""
#  echo ${LINE}
  cd ${ASUPDATADIR}/${LINE}

  FILE="`ls -1tr ${ASUPDATADIR}/${LINE}/*messages.desc 2> /dev/null|tail -1`"
  if [ "${FILE}" != "" ]; then
    IPADDRESS="`grep -i 'ip address:' ${FILE}|head -1|awk -F\: '{print $2}'|sed 's/ //g'`"
  fi  # FILE

  FILE="`ls -1tr ${ASUPDATADIR}/${LINE}/*ems.desc 2> /dev/null|tail -1`"
  if [ "${FILE}" != "" ]; then
    IPADDRESS="`grep -i 'ip address:' ${FILE}|head -1|awk -F\: '{print $2}'|sed 's/ //g'`"
  fi  # FILE

  FILE="`ls -1tr ${ASUPDATADIR}/${LINE}/*SYSCONFIG-A.txt 2> /dev/null|tail -1`"
  if [ "${FILE}" != "" ]; then
    IPADDRESS="`grep -i 'ip address:' ${FILE}|head -1|awk -F\: '{print $2}'|sed 's/ //g'`"
  fi  # FILE

  echo "${LINE} : ${IPADDRESS}"| grep '161.'


done  # ls -1

rm ${TMP}
echo "`date` ${PGM} finished."|tee -a ${LOG}
exit 0

