Browse code

initiatl check-in

Jiri Kuthan authored on 24/04/2003 19:21:15
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,46 @@
1
+#!/bin/sh 
2
+#
3
+# $Id$
4
+#
5
+# utility for displaying geographical break-down of usrloc population
6
+# it takes functional netgeo support for ser (currently, an
7
+# experimental unavailable feature)
8
+# 
9
+
10
+TMP=/tmp/geo_split.$$
11
+
12
+stats()
13
+{
14
+	DOMAIN_CNT=`grep $1 $TMP | wc | awk ' { print $1  } '`
15
+	if [ "$DOMAIN_CNT" -eq "0" ] ; then
16
+		PC="0"
17
+	else
18
+		PC=`expr $DOMAIN_CNT \* 100 / $2`
19
+	fi
20
+	printf "$1: $DOMAIN_CNT $PC %%\n"
21
+	grep -v $1 $TMP > $TMP.2
22
+	mv $TMP.2 $TMP
23
+}
24
+
25
+mysql -h dbhost --batch -u ser -pheslo ser -e "select location from netgeo_cache" |
26
+awk -F '/' '
27
+	BEGIN { line=0 }
28
+	{ line++ }
29
+	line==1 { next; } # skip heading
30
+	length()==0 { next; } # skip empty lines
31
+	/^[A-Z][A-Z ]*\/[A-Z ]+/ { print $2; next;} 
32
+	/^[A-Z]+/ { print " " $1; next;} 
33
+	/^ [A-Z]+/ { print $1; next;} 
34
+	{ print "error" > "/dev/stderr" }' |
35
+sort -b > $TMP
36
+
37
+export TOTAL_CNT=`wc $TMP|awk '{print $1}'`
38
+
39
+printf "Total: $TOTAL_CNT\n"
40
+(for i in AU DE US NL CZ UK RO RU TR TW SW JP CA HK IT AR BE CN FI GL IN KR SE UY; do 
41
+	stats $i $TOTAL_CNT
42
+done) 
43
+#| sort
44
+cat $TMP
45
+
46
+rm $TMP*