Пример #1
0
        //[0]	"date"
        //[1]	"time"
        //[2]	"s-sitename"
        //[3]	"s-computername"
        //[4]	"s-ip"
        //[5]	"cs-method"
        //[6]	"cs-uri-stem"
        //[7]	"cs-uri-query"
        //[8]	"s-port"
        //[9]	"cs-username"
        //[10]	"c-ip"
        //[11]	"cs-version"
        //[12]	"cs(User-Agent)"
        //[13]	"cs(Cookie)"
        //[14]	"cs(Referer)"
        //[15]	"cs-host"
        //[16]	"sc-status"
        //[17]	"sc-substatus"
        //[18]	"sc-win32-status"
        //[19]	"sc-bytes"
        //[20]	"cs-bytes"
        //[21]	"time-taken"
        private static List<SessionEx> ReadIisFile(string path)
        {
            var text = File.ReadAllText(path);
            var lines = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            var sessions = new Dictionary<string, SessionEx>();

            foreach (var line in lines)
            {
                if (line.StartsWith("#"))
                    continue;

                var parts = line.Split(' ');
                var dateTime = DateTime.Parse(parts[0] + " " + parts[1]);

                var status = parts[16];
                if (status != "200")
                    continue;

                var contentPath = parts[6].ToLowerInvariant();
                if (!contentPath.StartsWith("/tradingapi/"))
                    continue;

                var url = parts[15] + contentPath;

                var timeTaken = (double)int.Parse(parts[21]) / 1000;

                var ip = parts[10];
                SessionEx session;
                if (!sessions.TryGetValue(ip, out session))
                {
                    session = new SessionEx { Records = new List<RecordEx>(), Ip = ip };
                    session.Records.Add(new RecordEx(session) { Time = dateTime, Name = "ClientIP", Value = ip, });
                    sessions.Add(ip, session);
                }

                var record = new RecordEx(session)
                {
                    Time = dateTime,
                    Name = "Latency " + url,
                    Value = timeTaken.ToString(),
                };
                session.Records.Add(record);
            }

            return sessions.Values.ToList();
        }
Пример #2
0
 static bool IsNtpdInfo(RecordEx record)
 {
     return Util.IsInfo(record) && record.Value.StartsWith("ntpd");
 }
Пример #3
0
        private static double GetNtpdJitter(RecordEx record)
        {
            var text = record.Value;
            var infoText = text.Split(':')[1];
            var parts = infoText.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            var minParts = parts[1].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (minParts[0] != "min")
                throw new ApplicationException();

            var maxParts = parts[2].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (maxParts[0] != "max")
                throw new ApplicationException();

            var min = double.Parse(minParts[1]);
            var max = double.Parse(maxParts[1]);

            var res = Math.Max(Math.Abs(max), Math.Abs(min));
            return res;
        }