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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1404 - (hide annotations) (download)
Sat Apr 30 05:43:04 2011 UTC (13 years, 1 month ago) by torben
File size: 1330 byte(s)
add Requestplotter and version.jsp to admin tools
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     String uri = line.split(" ")[7];
31     String tmp = uri.split("=")[1];
32     String version = tmp.split("&") [0];
33    
34     Integer count = versions.get(version);
35     if (count == null)
36     count = 0;
37     versions.put(version, count+1);
38    
39     }
40    
41     %>
42     <html>
43     <head>
44     <title>Traininfo versions</title>
45     </head>
46     <body>
47     <h2>Versions</h2>
48     <font size='-1'>Counts are extracted from apache access log</font>
49     <table border='0'>
50     <%
51     for (String key : versions.keySet()) {
52     int val = versions.get(key);
53     %>
54     <tr><td><%=key%></td><td align='right'><%= val %></td></tr>
55     <%
56     }
57     %>
58     </table>
59    
60     </body>
61     </html>

  ViewVC Help
Powered by ViewVC 1.1.20