This is the testing jsp that reads the log file and generate data. the output will be something like {ping: 0,reg: 1,unreg: 0,search: 0} {ping: 1,reg: 1,unreg: 0,search: 2} ... and if 1 minute pass {ping: 0,reg: 1,unreg: 0,search: 0} {ping: 0,reg: 2,unreg: 0,search: 0} ...
<%@ page language="java" contentType="text/plain"%> <%@ page import="java.io.FileReader"%> <%@ page import="java.io.FileInputStream"%> <%@ page import="java.io.BufferedReader"%> <%@ page import="java.util.StringTokenizer"%> <%@ page import="java.util.Calendar"%> <%@ page import="java.util.GregorianCalendar"%> <%@ page import="java.io.IOException"%> <%! long time; int cID; //command ID int sID; //sequence ID String sIP; //source IP String dIP; //destination IP long payload; //payload Calendar t = new GregorianCalendar(); String text = ""; int nReg = 0, nUnreg = 0, nPing = 0, nSea = 0; //number of registry, unregistry, number of ping, number of search %> <% int initialTime= 60, currentTime; int timeInterval = 1; //set the time interval as 5 minutes String file = "log.txt"; try { BufferedReader in = new BufferedReader(new FileReader(file)); String origiLine; while ( (origiLine = in.readLine()) != null) { origiLine = origiLine.replace(",", " "); String[] newLine = new String[6]; StringTokenizer token = new StringTokenizer (origiLine); int counter = 0; if(token.countTokens()==6) { while (token.hasMoreTokens()) { newLine [counter] = token.nextToken(); counter++; } setTime(Long.parseLong(newLine[0])); setCommandID(Integer.parseInt(newLine[1])); setSequenceID(Integer.parseInt(newLine[2])); setSourceIP(newLine[3]); setDestIP(newLine[4]); setPayload(Long.parseLong(newLine[5])); if(currentTime < initialTime || currentTime - initialTime == timeInterval) { initialTime = currentTime; nPing = 0; nReg =0; nSea =0; } else { initialTime = initialTime; if (getCommandID() == 1) ++nPing; else if (getCommandID()== 11) ++nReg; else if (getCommandID() == 103) ++nUnreg; else if (getCommandID()== 13) ++nSea; } if (getCommandID() == 1) ++nPing; else if (getCommandID()== 11) ++nReg; else if (getCommandID() == 103) ++nUnreg; else if (getCommandID()== 13) ++nSea; out.print("{"); out.print("ping: " + nPing); out.print(","); out.print("reg: " + nReg); out.print(","); out.print("unreg: " + nUnreg); out.print(","); out.print("search: " + nSea); out.print("}"); out.println(""); } } in.close(); } catch (IOException e) { System.err.println(e); System.exit(1); } %> <%! public void timeParser(long time) { Calendar t = new GregorianCalendar(); t.setTimeInMillis(time); } public void setTime(long time) { this.time = time; t.setTimeInMillis(time); } public void setCommandID(int cID) { this.cID = cID; } public void setSequenceID(int sID) { this.sID = sID; } public void setSourceIP(String sIP) { this.sIP = sIP; } public void setDestIP(String dIP) { this.dIP = dIP; } public void setPayload(long payload) { this.payload = payload; } public Calendar getTime() { return t; } public int getCommandID() { return cID; } public int getSequenceID() { return sID; } public String getSourceIP() { return sIP; } public String getDestIP() { return dIP; } public long getPayload() { return payload; } %> --- Holger Will <[EMAIL PROTECTED]> wrote: > solomoonor wrote: > > > > > Hi, I use javascript svg and jsp to visualize the > log file. The > > javascript read the log file every second. The > problem is each one > > second generate one message it works ok, however > there will be manay > > messages generate within one second. Anybody have > any idea how to deal > > with this? I am not very familiar with javascript > acutally. Thank for > > any help!!! : ) > > can you post any code ? > > regards > Holger > > __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/