i am trying to monitor my hosts through ping. the hosts information are in a mysql table. i m using fping command the code is as followings
#/bin/sh
id=$(mysql -B --column-names=0 -uroot -pPassword -D monitor -e "SELECT ipv4 FROM nics WHERE icmp=1");
result=$(fping -c 10 $id |grep 'xmt/rcv/%loss');
#echo $result;
for line in $result;
do
echo $line
done
the output is
111.125.140.6 : xmt/rcv/%loss = 10/10/0%, min/avg/max = 234/234/235
123.135.140.7 : xmt/rcv/%loss = 10/0/100%
111.125.140.1 : xmt/rcv/%loss = 10/10/0%, min/avg/max = 230/231/231
111.125.130.2 : xmt/rcv/%loss = 10/10/0%, min/avg/max = 234/234/234
now i want to get IP, loss and average record from each line and input the data in a new table
thanks in advance
awk111.125.130.2 : xmt/rcv/%loss = 10/10/0%, min/avg/max = 234/234/234then try to make:|/as yourFSinawk. it may help