ESGFNodeInstallation: geoiplookup0.2.sh

File geoiplookup0.2.sh, 571 bytes (added by terryk, 7 years ago)
Line 
1#!/bin/sh
2
3IP=`cat ip_addresses.txt`
4
5for i in $IP; do
6GEOIPLOOKUP=`/usr/local/geoip/bin/geoiplookup $i`
7#LOCATION=`echo $GEOIPLOOKUP | awk '{print VALUES $4}'| sed 's/,//g'| egrep -v "can"`
8LOCATION=`/usr/local/geoip/bin/geoiplookup $i| awk '{print VALUES $4}'| sed 's/,//g'`
9ERROR=`echo $GEOIPLOOKUP | awk '{print VALUES $4}'`
10if [[ "$ERROR" != "can't" ]]
11then
12 HOST=`host $i|awk '{print VALUES $5}'| egrep -v "NXDOMAIN"|egrep -v "FAIL"| egrep -v alias| tail -1`
13 echo -e "insert into esgf_dashboard.stats_support_table(ip,country) values('$i','$LOCATION');" 
14fi
15
16done