/[projects]/android/TrainInfoService/WebContent/version.jsp
ViewVC logotype

Contents of /android/TrainInfoService/WebContent/version.jsp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1599 - (show annotations) (download)
Thu Sep 22 15:21:15 2011 UTC (12 years, 7 months ago) by torben
File size: 2086 byte(s)
add code for extracting phone/android from apache access log
1 <%@ page import="java.io.*" %>
2 <%@ page import="java.util.*" %>
3 <%@ page import="dk.thoerup.genericjavautils.HttpUtil" %>
4 <%
5 /*
6 cat bin/traininfo-version.sh
7 #!/bin/bash
8
9
10 FILE=/var/log/apache2/access.log
11
12 if [ "$1" != "" ] ; then
13 grep traininfo/version $FILE | grep $1 | awk '{print $8}' | awk -F= '{print $2}' | awk -F\& '{print $1}' | sort | uniq -c
14 else
15 grep traininfo/version $FILE | awk '{print $8}' | awk -F= '{print $2}' | awk -F\& '{print $1}' | sort | uniq -c
16 fi
17 */
18
19 File f = new File("/var/log/apache2/access.log");
20
21 InputStream input = new FileInputStream(f);
22
23 BufferedReader in = new BufferedReader( new InputStreamReader(input) );
24
25 Map<String,Integer> versions = new TreeMap<String,Integer>();
26 Map<String,Integer> phones = new TreeMap<String,Integer>();
27
28 String line;
29 while ( (line=in.readLine()) != null) {
30 if (line.indexOf("traininfo/version") == -1)
31 continue;
32 String version = "";
33 String phone = "";
34 String parts[] = line.split(" ");
35
36 if (parts.length >= 8) {
37 String uri = parts[7];
38 Map<String,String> params = HttpUtil.decodeUri(uri);
39 String tmpVer = params.get("version");
40
41 if (tmpVer != null)
42 version = tmpVer;
43
44 String tmpPhone = params.get("phone");
45 String tmpAndroid = params.get("android");
46 if (tmpPhone != null && tmpAndroid != null)
47 phone = tmpPhone + " " + tmpAndroid;
48 }
49
50 Integer count = versions.get(version);
51 if (count == null)
52 count = 0;
53 versions.put(version, count+1);
54
55 count = phones.get(phone);
56 if (count == null)
57 count = 0;
58 phones.put(phone, count+1);
59
60 }
61
62 %>
63 <html>
64 <head>
65 <title>Traininfo versions</title>
66 </head>
67 <body>
68 <h2>Versions</h2>
69 <font size='-1'>Counts are extracted from apache access log</font>
70 <table border='0'>
71 <%
72 for (String key : versions.keySet()) {
73 int val = versions.get(key);
74 %>
75 <tr><td><%=key%></td><td align='right'><%= val %></td></tr>
76 <%
77 }
78 %>
79 </table>
80
81 <h2>Phones / Android ver.</h2>
82 <table border='0'>
83 <%
84 for (String key : phones.keySet()) {
85 int val = phones.get(key);
86 %>
87 <tr><td><%=key%></td><td align='right'><%= val %></td></tr>
88 <%
89 }
90 %>
91 </table>
92 </body>
93 </html>

  ViewVC Help
Powered by ViewVC 1.1.20