public static void LogInUUids() { var uuids = File.ReadAllLines(@"C:\Users\baibq\Downloads\uuids.txt"); var lst = new List <string>(uuids); DirectoryInfo TheFolder = new DirectoryInfo(@"C:\Users\baibq\Downloads\kegg20160314"); Console.WriteLine("start " + DateTime.Now); var ff = TheFolder.GetFiles(); var rt = new RegexTool(); for (int i = 0; i < ff.Length; i++) { var reads = File.ReadLines(ff[i].FullName); //var uids = new List<string>(); foreach (var v in reads) { var uid = rt.Substring(v, @"""uid"":""", @""""); if (lst.Contains(uid)) { // uids.Add(uid); File.AppendAllLines(@"C:\Users\baibq\Downloads\0314\" + ff[i].Name, new string[] { v }); } } } }
public static void HaveEggLog() { var filename = @"C:\Users\baibq\Desktop\webstat\ret.txt"; var lines = File.ReadAllLines(filename); var path1 = @"C:\Users\baibq\Desktop\egglog\egg20160213"; DirectoryInfo TheFolder = new DirectoryInfo(path1); Console.WriteLine("start " + DateTime.Now); var ff = TheFolder.GetFiles(); var finishLst = new List <string>(); var total = 0; for (var i = 0; i < ff.Length; i++) { var lst = new Dictionary <string, commonlog>(); Console.WriteLine("process " + ff[i].FullName); var lines1 = File.ReadLines(ff[i].FullName); var regexTool = new RegexTool(); foreach (var str in lines1) { try { var tmp = ""; Regex gex3 = new Regex(@"{([\S +|\s +])*"); var m3 = gex3.Match(str); if (m3.Success) { tmp = m3.Value; } var uid = regexTool.Substring(tmp, @"""uid"":""", @""""); if (finishLst.Contains(uid)) { continue; } if (tmp.IndexOf("{") > -1 && tmp.IndexOf("}") > -1 && tmp.IndexOf("checkupdate") > -1 && lines.Contains(uid)) { using (StreamWriter write = new StreamWriter(@"C:\Users\baibq\Desktop\webstat\finish.txt", true)) { write.WriteLine(tmp); } finishLst.Add(uid); total++; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine("finished lines " + total); } }
public static bool Filter(string log, out string type, out string date, out string ip, out string jsonStr, out string eventValue, out string killer) { type = null; date = null; ip = null; jsonStr = null; eventValue = null; killer = null; //// receive 85.97.191.69:52684 req {"event":"handshake"} //if (log.IndexOf(" req ") > -1 && log.IndexOf("handshake") > -1) { // return true; //} //send 85.97.191.69:52684 resp: {"rc":0,"payroll":{"key":"HQMLWBWXYECUUJME"}} if (log.IndexOf(" resp: ") > -1 && log.IndexOf("payroll") > -1 && log.IndexOf("key") > -1) { return(true); } // send to eggserver tcpaddr 181.49.76.77:50068 httpaddr 10.58.241.179:49612 event checkupdate elapsedtime 1 resp code 200 if (log.IndexOf("send to eggserver tcpaddr") > -1) { return(true); } //send 181.49.76.77:50068 resp: {"rc":0,"st":1448494260,"today":"20151125"} if (log.IndexOf(" resp: ") > -1 && log.IndexOf("rc") > -1 && log.IndexOf("payroll") < 0) { return(true); } //type if (log.IndexOf(" resp: ") > -1) { type = "resp"; } else { type = "req"; } //匹配日期 Regex gex1 = new Regex(@"\d+\/\d+\/\d+ \d+\:\d+\:\d+"); var m1 = gex1.Match(log); if (m1.Success) { date = m1.Value.Replace("/", "-"); } //ip Regex gex2 = new Regex(@"\d+\.\d+\.\d+\.\d+\:\d+"); var m2 = gex2.Match(log); if (m2.Success) { ip = m2.Value.Split(new char[] { ':' })[0]; } // Regex gex3 = new Regex(@"{([\S +|\s +])*"); var m3 = gex3.Match(log); if (m3.Success) { jsonStr = m3.Value; } var rg = new RegexTool(); var strt = rg.Substring(log, @"""kill"":""", @""""); if (!string.IsNullOrEmpty(strt)) { killer = strt; } //var ch = rg.Substring(log, @"""channel"":""", @""""); //if (!string.IsNullOrEmpty(ch)) //{ // channel = ch; //} //var vr = rg.Substring(log, @"""version"":""", @""""); //if (!string.IsNullOrEmpty(vr)) //{ // version = vr; //} //var ll = rg.Substring(log, @"""locale"":""", @","); //if (!string.IsNullOrEmpty(ll)) //{ // locale = int.Parse(ll) ; //} //var u = rg.Substring(log, @"""uid"":""", @""""); //if (!string.IsNullOrEmpty(u)) //{ // uid = u; //} if (log.IndexOf(@"""handshake""") > -1) { eventValue = "handshake"; } else if (log.IndexOf(@"""checkupdate""") > -1) { eventValue = "checkupdate"; } else if (log.IndexOf(@"""checktask""") > -1) { eventValue = "checktask"; } else if (log.IndexOf(@"""updateresult""") > -1) { eventValue = "updateresult"; } else if (log.IndexOf(@"""taskresult""") > -1) { eventValue = "taskresult"; } else if (log.IndexOf(@"""checkupdate2""") > -1) { eventValue = "checkupdate2"; } else if (log.IndexOf(@"""host""") > -1 && type == "resp") { eventValue = "taskresponse"; } return(false); }