public static VizqlSession AppendAllSessionEvents(VizqlSession session, IMongoCollection <BsonDocument> collection) { AppendErrorEvents(session, collection); AppendPerformanceEvents(session, collection); return(session); }
private void ProcessSession(VizqlSession session, IMongoCollection <BsonDocument> collection) { try { session = MongoQueryHelper.AppendAllSessionEvents(session, collection); persistenceHelper.Enqueue(session as VizqlDesktopSession); } catch (Exception ex) { string errorMessage = String.Format("Failed to process session {0} in {1}: {2}", session.VizqlSessionId, collection.CollectionNamespace.CollectionName, ex.Message); Log.Error(errorMessage); pluginResponse.AppendError(errorMessage); } }
public static VizqlSession AppendPerformanceEvents(VizqlSession session, IMongoCollection <BsonDocument> collection) { foreach (var keyType in VizqlEventClassesByKeytype.Keys) { AppendEventsForKeyType(session, keyType, collection); } if (session is VizqlDesktopSession) { AppendEtcEventsForSession(session, collection); } return(session); }
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); }
private static IEnumerable <BsonDocument> GetSeveritiesforSession(VizqlSession session, string severity, IMongoCollection <BsonDocument> collection) { FilterDefinition <BsonDocument> severityQuery; if (session is VizqlServerSession) { severityQuery = Query.And(Query.Eq("sess", session.VizqlSessionId), Query.Eq("sev", severity)); } else if (session is VizqlDesktopSession) { VizqlDesktopSession desktopSession = session as VizqlDesktopSession; severityQuery = Query.And(Query.Eq("pid", desktopSession.ProcessId), Query.Eq("sev", severity)); } else { throw new Exception("VizqlSession not of type Server or Desktop"); } return(collection.Find(severityQuery).ToList()); }
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); }
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); }
public static IEnumerable <BsonDocument> GetFatalsForSession(VizqlSession session, IMongoCollection <BsonDocument> collection) { return(GetSeveritiesforSession(session, "fatal", collection)); }