示例#1
0
        public static VizqlSession AppendErrorEvents(VizqlSession session, IMongoCollection <BsonDocument> collection)
        {
            IEnumerable <BsonDocument> errors = GetErrorsForSession(session, collection);

            foreach (BsonDocument logline in errors)
            {
                var message = logline.GetString("v");
                if (message != null && !message.StartsWith("Exception '' while executing command"))
                {
                    session.AppendEvent(new VizqlErrorEvent(logline));
                }
            }

            ICollection <BsonDocument> fatals = GetFatalsForSession(session, collection).ToList();

            if (fatals.Any())
            {
                string message = AssembleStackWalk(fatals);
                session.AppendEvent(new VizqlErrorEvent(fatals.First(), message));
            }

            return(session);
        }
示例#2
0
        public static VizqlSession AppendEventsForKeyType(VizqlSession session, string keyType, IMongoCollection <BsonDocument> collection)
        {
            IEnumerable <BsonDocument> documentList;

            if (session is VizqlServerSession)
            {
                if (!VizqlServerSupportedKeytypes.Contains(keyType))
                {
                    return(session);
                }
                else
                {
                    documentList = GetEventsForKeyBySession(session.VizqlSessionId, keyType, collection);
                }
            }
            else if (session is VizqlDesktopSession)
            {
                if (!VizqlDesktopSupportedKeytypes.Contains(keyType))
                {
                    return(session);
                }
                else
                {
                    VizqlDesktopSession desktopSession = session as VizqlDesktopSession;
                    documentList = GetEventsForKeyByPid(desktopSession.ProcessId, keyType, collection);
                }
            }
            else
            {
                throw new Exception("VizqlSession not of type Desktop or Server!");
            }

            foreach (var document in documentList)
            {
                try
                {
                    Object[]   args       = { document };
                    Type       t          = VizqlEventClassesByKeytype[keyType];
                    VizqlEvent vizqlEvent = (VizqlEvent)Activator.CreateInstance(t, args);
                    session.AppendEvent(vizqlEvent);
                }
                catch (Exception ex)
                {
                    Log.ErrorFormat("Exception processing {0} events on session {1}: {2}", keyType, session.VizqlSessionId, ex);
                }
            }

            return(session);
        }
示例#3
0
        public static VizqlSession AppendEtcEventsForSession(VizqlSession session, IMongoCollection <BsonDocument> collection)
        {
            var filter = Query.Nin("k", VizqlEventClassesByKeytype.Keys);
            var unsupportedKeyTypes = collection.Distinct <string>("k", filter).ToEnumerable();

            foreach (var keyType in unsupportedKeyTypes)
            {
                IEnumerable <BsonDocument> documents;
                if (session is VizqlServerSession)
                {
                    documents = GetEventsForKeyBySession(session.VizqlSessionId, keyType, collection);
                }
                else if (session is VizqlDesktopSession)
                {
                    VizqlDesktopSession desktopSession = session as VizqlDesktopSession;
                    documents = GetEventsForKeyByPid(desktopSession.ProcessId, keyType, collection);
                }
                else
                {
                    throw new Exception("VizqlSession must be of type Server or Desktop");
                }

                foreach (var document in documents)
                {
                    try
                    {
                        session.AppendEvent(new VizqlEtc(document));
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Unable to create VizqlEtc record for " + session.VizqlSessionId + " for keyType " + keyType + ":" + ex.Message);
                    }
                }
            }

            return(session);
        }