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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1405 - (hide annotations) (download)
Mon May 2 08:08:56 2011 UTC (13 years, 1 month ago) by torben
File size: 1481 byte(s)
remove an NPE
1 torben 1404 <%@ page import="java.io.*" %>
2     <%@ page import="java.util.*" %>
3     <%
4     /*
5     cat bin/traininfo-version.sh
6     #!/bin/bash
7    
8    
9     FILE=/var/log/apache2/access.log
10    
11     if [ "$1" != "" ] ; then
12     grep traininfo/version $FILE | grep $1 | awk '{print $8}' | awk -F= '{print $2}' | awk -F\& '{print $1}' | sort | uniq -c
13     else
14     grep traininfo/version $FILE | awk '{print $8}' | awk -F= '{print $2}' | awk -F\& '{print $1}' | sort | uniq -c
15     fi
16     */
17    
18     File f = new File("/var/log/apache2/access.log");
19    
20     InputStream input = new FileInputStream(f);
21    
22     BufferedReader in = new BufferedReader( new InputStreamReader(input) );
23    
24     Map<String,Integer> versions = new TreeMap<String,Integer>();
25    
26     String line;
27     while ( (line=in.readLine()) != null) {
28     if (line.indexOf("traininfo/version") == -1)
29     continue;
30 torben 1405 String version = "";
31     String parts[] = line.split(" ");
32    
33     if (parts.length >= 8) {
34     String uri = parts[7];
35     if (uri.indexOf("=") != -1) {
36     String tmp = uri.split("=")[1];
37     if (tmp.indexOf("&") != -1) {
38     version = tmp.split("&") [0];
39     }
40     }
41     }
42 torben 1404
43     Integer count = versions.get(version);
44     if (count == null)
45     count = 0;
46     versions.put(version, count+1);
47    
48     }
49    
50     %>
51     <html>
52     <head>
53     <title>Traininfo versions</title>
54     </head>
55     <body>
56     <h2>Versions</h2>
57     <font size='-1'>Counts are extracted from apache access log</font>
58     <table border='0'>
59     <%
60     for (String key : versions.keySet()) {
61     int val = versions.get(key);
62     %>
63     <tr><td><%=key%></td><td align='right'><%= val %></td></tr>
64     <%
65     }
66     %>
67     </table>
68    
69     </body>
70     </html>

  ViewVC Help
Powered by ViewVC 1.1.20