#!/usr/bin/ksh touch hostinfo$(date +%Y%m%d).csv
filename=hostinfo$(date +%Y%m%d).csv >${filename}
for ip in $(cat iplist);
do
SYSTEM=`ssh -q ${ip} uname -s`
HOST_NAME=`ssh -q ${ip} hostname`
SERNUM=""
OS="" printf "${ip}," >> ${filename}
if [ "${SYSTEM}"x = "HP-UX"x ];
then
SERNUM=`ssh -q ${ip} /usr/contrib/bin/machinfo | awk '/serial number/ {print $NF}'`
OS=`ssh -q ${ip} /usr/contrib/bin/machinfo | grep 'Release' | awk -F':' '{print $2}'`
elif [ "${SYSTEM}"x = "AIX"x ];
then
SERNUM=`ssh -q ${ip} prtconf | awk '/Machine Serial Number/ {print $NF}'`
OS=${SYSTEM}
elif [ "${SYSTEM}"x = "Linux"x ];
then
SERNUM=`ssh -q ${ip} dmidecode -t system | grep 'Serial Number' | awk -F':' '{print $2}'`
ssh ${ip} "ls /etc/redhat-release" > /dev/null >&
if [ $? -eq ];
then
OS=`ssh -q ${ip} cat /etc/redhat-release | awk '{printf("%s%s %s\n", $1, $2, $(NF-1))}'`
tmp=`echo ${OS} | grep "^CentOS"`
if [ "$tmp" != "" ]; then
OS=`echo ${tmp} | awk '{printf("CentOS %s\n", $NF)}'`
fi
else
OS=`ssh -q ${ip} cat /etc/issue | awk '{printf("%s %s %s", $3, $7, $8)}'`
fi
else
echo "other system!"
fi printf "${SERNUM}, ${HOST_NAME}, ${OS}\n" >> ${filename}
done