BoxedIce.ServerDensity.Agent.Checks.ExtendedMongoDBCheck.FillBaseStatistics C# (CSharp) Метод

FillBaseStatistics() приватный Метод

private FillBaseStatistics ( BsonDocument statusOutput, object>.IDictionary status ) : void
statusOutput BsonDocument
status object>.IDictionary
Результат void
        private void FillBaseStatistics(BsonDocument statusOutput, IDictionary<string, object> status)
        {
            BsonDocument indexCountersOutput = (BsonDocument)statusOutput["indexCounters"];
            IDictionary<string, object> indexCounters = new Dictionary<string, object>();
            status.Add("indexCounters", indexCounters);

            IDictionary<string, object> btree = new Dictionary<string, object>();
            indexCounters.Add("btree", btree);

            IDictionary<string, object> opCounters = new Dictionary<string, object>();
            status.Add("opcounters", opCounters);

            IDictionary<string, object> asserts = new Dictionary<string, object>();
            status.Add("asserts", asserts);

            BsonDocument btreeOutput = new BsonDocument();
            // Index counters are currently not supported on Windows.
            if (!indexCountersOutput.Contains("note") || indexCountersOutput["note"] == null)
            {
                var version = this.GetVersion(statusOutput);
                // mongodb over 2.2.0 doesn't have a global lock, so we can't report on it
                if (version != null && version[0] <= 2 && version[1] <= 2)
                {
                    btreeOutput = (BsonDocument)indexCountersOutput["btree"];
                }
                else
                {
                    this.AddBlankBTree(btreeOutput);
                }
            }
            else
            {
                this.AddBlankBTree(btreeOutput);
            }

            BsonDocument opCountersOutput = (BsonDocument)statusOutput["opcounters"];
            BsonDocument assertsOutput = (BsonDocument)statusOutput["asserts"];

            if (_mongoDBStore == null)
            {
                Log.Debug("No cached data, so storing for the first time.");

                btree.Add("accessesPS", 0);
                btree.Add("accesses", 0);
                btree.Add("hitsPS", 0);
                btree.Add("hits", 0);
                btree.Add("missesPS", 0);
                btree.Add("misses", 0);
                btree.Add("missRatioPS", 0);
                btree.Add("missRatio", 0D);

                opCounters.Add("insertPS", 0);
                opCounters.Add("insert", 0);
                opCounters.Add("queryPS", 0);
                opCounters.Add("query", 0);
                opCounters.Add("updatePS", 0);
                opCounters.Add("update", 0);
                opCounters.Add("deletePS", 0);
                opCounters.Add("delete", 0);
                opCounters.Add("getmorePS", 0);
                opCounters.Add("getmore", 0);
                opCounters.Add("commandPS", 0);
                opCounters.Add("command", 0);

                asserts.Add("regularPS", 0);
                asserts.Add("regular", 0);
                asserts.Add("warningPS", 0);
                asserts.Add("warning", 0);
                asserts.Add("msgPS", 0);
                asserts.Add("msg", 0);
                asserts.Add("userPS", 0);
                asserts.Add("user", 0);
                asserts.Add("rolloversPS", 0);
                asserts.Add("rollovers", 0);
            }
            else
            {
                Log.Debug("Cached data exists, so calculating per sec metrics.");

                IDictionary<string, object> cachedBtree = (IDictionary<string, object>)((IDictionary<string, object>)_mongoDBStore["indexCounters"])["btree"];
                IDictionary<string, object> cachedOpCounters = (IDictionary<string, object>)_mongoDBStore["opcounters"];
                IDictionary<string, object> cachedAsserts = (IDictionary<string, object>)_mongoDBStore["asserts"];

                btree.Add("accessesPS", (float)(((int)btreeOutput["accesses"] - (int)cachedBtree["accesses"]) / 60));
                btree.Add("accesses", btreeOutput["accesses"].RawValue);
                btree.Add("hitsPS", (float)(((int)btreeOutput["hits"] - (int)cachedBtree["hits"]) / 60));
                btree.Add("hits", btreeOutput["hits"].RawValue);
                btree.Add("missesPS", (float)(((int)btreeOutput["misses"] - (int)cachedBtree["misses"]) / 60));
                btree.Add("misses", btreeOutput["misses"].RawValue);
                btree.Add("missRatioPS", (float)(((double)btreeOutput["missRatio"] - (double)cachedBtree["missRatio"]) / 60));
                btree.Add("missRatio", btreeOutput["missRatio"].RawValue);

                opCounters.Add("insertPS", (float)(((int)opCountersOutput["insert"] - (int)cachedOpCounters["insert"]) / 60));
                opCounters.Add("insert", opCountersOutput["insert"].RawValue);
                opCounters.Add("queryPS", (float)(((int)opCountersOutput["query"] - (int)cachedOpCounters["query"]) / 60));
                opCounters.Add("query", opCountersOutput["query"].RawValue);
                opCounters.Add("updatePS", (float)(((int)opCountersOutput["update"] - (int)cachedOpCounters["update"]) / 60));
                opCounters.Add("update", opCountersOutput["update"].RawValue);
                opCounters.Add("deletePS", (float)(((int)opCountersOutput["delete"] - (int)cachedOpCounters["delete"]) / 60));
                opCounters.Add("delete", opCountersOutput["delete"].RawValue);
                opCounters.Add("getmorePS", (float)(((int)opCountersOutput["getmore"] - (int)cachedOpCounters["getmore"]) / 60));
                opCounters.Add("getmore", opCountersOutput["getmore"].RawValue);
                opCounters.Add("commandPS", (float)(((int)opCountersOutput["command"] - (int)cachedOpCounters["command"]) / 60));
                opCounters.Add("command", opCountersOutput["command"].RawValue);

                asserts.Add("regularPS", (float)(((int)assertsOutput["regular"] - (int)cachedAsserts["regular"]) / 60));
                asserts.Add("regular", assertsOutput["regular"].RawValue);
                asserts.Add("warningPS", (float)(((int)assertsOutput["warning"] - (int)cachedAsserts["warning"]) / 60));
                asserts.Add("warning", assertsOutput["warning"].RawValue);
                asserts.Add("msgPS", (float)(((int)assertsOutput["msg"] - (int)cachedAsserts["msg"]) / 60));
                asserts.Add("msg", assertsOutput["msg"].RawValue);
                asserts.Add("userPS", (float)(((int)assertsOutput["user"] - (int)cachedAsserts["user"]) / 60));
                asserts.Add("user", assertsOutput["user"].RawValue);
                asserts.Add("rolloversPS", (float)(((int)assertsOutput["rollovers"] - (int)cachedAsserts["rollovers"]) / 60));
                asserts.Add("rollovers", assertsOutput["rollovers"].RawValue);
            }

            _mongoDBStore = status;
        }