Beispiel #1
0
        public override IPluginResponse Execute()
        {
            var pluginResponse = CreatePluginResponse();

            var collectionWorkerMap = CollectionDependencies.ToDictionary(collection => collection,
                                                                          collection => ResourceManagerQueries.GetDistinctWorkers(MongoDatabase.GetCollection <BsonDocument>(collection)));

            bool persistedThresholds = ProcessDocuments(collectionWorkerMap, GetThresholds);
            bool persistedCpuInfo    = ProcessDocuments(collectionWorkerMap, SelectByPid(ResourceManagerQueries.GetCpuSamples));
            bool persistedMemoryInfo = ProcessDocuments(collectionWorkerMap, SelectByPid(ResourceManagerQueries.GetMemorySamples));
            bool persistedActions    = ProcessDocuments(collectionWorkerMap, SelectByPid(ResourceManagerQueries.GetActions));

            if (!persistedThresholds && !persistedCpuInfo && !persistedMemoryInfo && !persistedActions)
            {
                Log.Info("Failed to persist any Server Resource Manager data!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Beispiel #2
0
 private static Func <string, IMongoCollection <BsonDocument>, IEnumerable <T> > SelectByPid <T>(Func <string, int, IMongoCollection <BsonDocument>, IEnumerable <T> > selector) where T : new()
 {
     return((worker, collection) => ResourceManagerQueries.GetDistinctPids(worker, collection)
            .SelectMany(pid => selector(worker, pid, collection)));
 }
Beispiel #3
0
 private static IEnumerable <ResourceManagerThreshold> GetThresholds(string workerId, IMongoCollection <BsonDocument> collection)
 {
     return(ResourceManagerQueries.GetSrmStartEventsForWorker(workerId, collection)
            .Select(startEvent => ResourceManagerQueries.GetThreshold(startEvent, collection)));
 }