采集脚本
#!/bin/sh
check_os(){
(uname -a|grep Linux)&&return 1;
(uname -a|grep AIX)&&return 2;
(uname -a|grep HP)&&return 3;
}
set +
check_os>/dev/null
os=$?
set -
case $os in
1)
platform=LINUX
hostName=`hostname`
ipAll=`ip a|grep inet|grep -v '127.0.0.' |grep -v inet6|awk '{print $2}'|awk -F '/' '{printf("%s,",$1)}END{print ""}' `
;;
2)
platform=AIX
hostName=`hostname`
ipAll=`ifconfig -a |grep netmask|grep -vE "inet 127|inet 172"|awk '{printf("%s,",$2)}END{print ""}' `
;;
3)
platform=HPUX
hostName=`hostname`
ipAll=`netstat -in |grep -v Network|grep -v '127.0.0.'|awk '{printf("%s,",$4)}END{print ""}' `
;;
esac
echo "${platform}|${hostName}|${ipAll}"
调用采集脚本
#!/bin/sh
> /tmp/ipAddress.log
cat ipList |awk '{print $1}'| while read ipAddress
do
ssh $ipAddress /home/wei/a.sh >> /tmp/ipAllAddress.log
done
cat /tmp/ipAllAddress.log