Exemplo n.º 1
0
        public static long LogIndexesChanges(List <EngineCustomStatus> A, List <EngineCustomStatus> B)
        {
            long totalChanges = 0;

            if (A.Except(B).Count() != 0)
            {
                Sys.LogError($"Cannot compare different lists of Engine Status");
                return(-1);
            }

            foreach (EngineCustomStatus A_ECS in A)
            {
                LogTable logTabeIndexesChanges = new LogTable($"Engine [{A_ECS.Name}]");
                logTabeIndexesChanges.SetInnerColumnSpaces(1, 1);

                foreach (IndexStatus A_ECS_IDX in A_ECS.indexesStatus)
                {
                    IndexStatus B_ECS_IDX = B.Single(B_ECS => Str.EQ(B_ECS.Name, A_ECS.Name)).indexesStatus.Single(x => Str.EQ(x.Name, A_ECS_IDX.Name));

                    long delta = B_ECS_IDX.DocumentCount - A_ECS_IDX.DocumentCount;
                    logTabeIndexesChanges.AddItem(A_ECS_IDX.Name, "From", A_ECS_IDX.DocumentCount.ToString("+0.#;-0.#;0"));
                    logTabeIndexesChanges.AddItem(A_ECS_IDX.Name, "To", B_ECS_IDX.DocumentCount.ToString("+0.#;-0.#;0"));
                    logTabeIndexesChanges.AddItem(A_ECS_IDX.Name, "Change", delta.ToString("+0.#;-0.#;0"));
                    totalChanges += Math.Abs(delta);
                }

                logTabeIndexesChanges.SysLog();
            }

            return(totalChanges);
        }
Exemplo n.º 2
0
        public void LogIndexesGrid()
        {
            LogTable logTableIndexes = new LogTable(Name);

            logTableIndexes.SetInnerColumnSpaces(1, 1);

            long totalDocs   = 0;
            long totalGhosts = 0;

            foreach (IndexStatus idxStatus in indexesStatus)
            {
                long docs = idxStatus.DocumentCount;
                logTableIndexes.AddItem($"{idxStatus.Name}", "Document Count", docs.ToString("N0", CultureInfo.InvariantCulture));
                totalDocs += docs;

                long ghosts = idxStatus.GhostCount;
                logTableIndexes.AddItem($"{idxStatus.Name}", "Ghost Count", ghosts.ToString("N0", CultureInfo.InvariantCulture));
                totalGhosts += ghosts;
            }
            logTableIndexes.AddItem("Total", "Document Count", totalDocs.ToString("N0", CultureInfo.InvariantCulture));
            logTableIndexes.AddItem("Total", "Ghost Count", totalGhosts.ToString("N0", CultureInfo.InvariantCulture));

            logTableIndexes.SysLog();
        }
Exemplo n.º 3
0
        public void LogStats()
        {
            Stopwatch swStats = new Stopwatch();

            swStats.Start();

            Sys.Log($"----------------------------------------------------");
            Sys.Log($"Engine Activity Statistics");
            Sys.Log($"----------------------------------------------------");

            LogTable logTableActivity = new LogTable();

            logTableActivity.SetInnerColumnSpaces(1, 1);

            foreach (string engineName in lStoreEngine)
            {
                //engine X does not exist
                List <EngineActivityItem> lItems = GetEngineActivityList(engineName);
                if (lItems == null || lItems.Count == 0)
                {
                    Sys.LogError($"Cannot get engine activity item for Engine [{engineName}]");
                    continue;
                }

                EngineActivityItem first = lItems.OrderBy(x => x.processNow).First();
                EngineActivityItem last  = lItems.OrderBy(x => x.processNow).Last();

                //activity monitored count
                logTableActivity.AddUniqueItem("Activity monitored", "unit", "");
                logTableActivity.AddItem("Activity monitored", $"{engineName}", lItems.Count.ToString(_statsFormatCount));

                //thread count
                logTableActivity.AddUniqueItem("Thread count", "unit", "");
                logTableActivity.AddItem("Thread count", $"{engineName}", first.threadPoolStatusThreadCount.ToString(_statsFormatCount));

                //installed RAM
                logTableActivity.AddUniqueItem("Installed Memory", "unit", "Gb");
                logTableActivity.AddItem("Installed Memory", $"{engineName}", first.processInstalledMemoryGb.ToString(_statsFormatGb));

                //sep
                logTableActivity.AddSeparatorAfterRow("Installed Memory");

                //CPU user time
                logTableActivity.AddUniqueItem("CPU User Time at start", "unit", "seconds");
                logTableActivity.AddItem("CPU User Time at start", $"{engineName}", first.processCPUUserTimeMs.ToString(_statsFormatCPU));
                logTableActivity.AddUniqueItem("CPU User Time at end", "unit", "seconds");
                logTableActivity.AddItem("CPU User Time at end", $"{engineName}", last.processCPUUserTimeMs.ToString(_statsFormatCPU));
                logTableActivity.AddUniqueItem("CPU User Time change", "unit", "seconds");
                logTableActivity.AddItem("CPU User Time change", $"{engineName}", (last.processCPUUserTimeMs - first.processCPUUserTimeMs).ToString(_statsFormatCPUChange));

                //CPU system time
                logTableActivity.AddUniqueItem("CPU System Time at start", "unit", "seconds");
                logTableActivity.AddItem("CPU System Time at start", $"{engineName}", first.processCPUSystemTimeMs.ToString(_statsFormatCPU));
                logTableActivity.AddUniqueItem("CPU System Time at end", "unit", "seconds");
                logTableActivity.AddItem("CPU System Time at end", $"{engineName}", last.processCPUSystemTimeMs.ToString(_statsFormatCPU));
                logTableActivity.AddUniqueItem("CPU System Time change", "unit", "seconds");
                logTableActivity.AddItem("CPU System Time change", $"{engineName}", (last.processCPUSystemTimeMs - first.processCPUSystemTimeMs).ToString(_statsFormatCPUChange));

                //sep
                logTableActivity.AddSeparatorAfterRow("CPU System Time change");

                //process VM Size
                logTableActivity.AddUniqueItem("VM Size at start", "unit", "Gb");
                logTableActivity.AddItem("VM Size at start", $"{engineName}", first.processVMSizeGb.ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("VM Size at end", "unit", "Gb");
                logTableActivity.AddItem("VM Size at end", $"{engineName}", last.processVMSizeGb.ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("VM Size change", "unit", "Gb");
                logTableActivity.AddItem("VM Size change", $"{engineName}", (last.processVMSizeGb - first.processVMSizeGb).ToString(_statsFormatGbChange));
                logTableActivity.AddUniqueItem("VM Size min", "unit", "Gb");
                logTableActivity.AddItem("VM Size min", $"{engineName}", lItems.Min(x => x.processVMSizeGb).ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("VM Size avg", "unit", "Gb");
                logTableActivity.AddItem("VM Size avg", $"{engineName}", lItems.Average(x => x.processVMSizeGb).ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("VM Size max", "unit", "Gb");
                logTableActivity.AddItem("VM Size max", $"{engineName}", lItems.Max(x => x.processVMSizeGb).ToString(_statsFormatGb));

                //sep
                logTableActivity.AddSeparatorAfterRow("VM Size max");

                //process WS Size
                logTableActivity.AddUniqueItem("WS Size at start", "unit", "Gb");
                logTableActivity.AddItem("WS Size at start", $"{engineName}", first.processWSSizeGb.ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("WS Size at end", "unit", "Gb");
                logTableActivity.AddItem("WS Size at end", $"{engineName}", last.processWSSizeGb.ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("WS Size change", "unit", "Gb");
                logTableActivity.AddItem("WS Size change", $"{engineName}", (last.processWSSizeGb - first.processWSSizeGb).ToString(_statsFormatGbChange));
                logTableActivity.AddUniqueItem("WS Size min", "unit", "Gb");
                logTableActivity.AddItem("WS Size min", $"{engineName}", lItems.Min(x => x.processWSSizeGb).ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("WS Size avg", "unit", "Gb");
                logTableActivity.AddItem("WS Size avg", $"{engineName}", lItems.Average(x => x.processWSSizeGb).ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("WS Size max", "unit", "Gb");
                logTableActivity.AddItem("WS Size max", $"{engineName}", lItems.Max(x => x.processWSSizeGb).ToString(_statsFormatGb));

                //sep
                logTableActivity.AddSeparatorAfterRow("WS Size max");

                //Available Memory
                logTableActivity.AddUniqueItem("Available Memory at start", "unit", "Gb");
                logTableActivity.AddItem("Available Memory at start", $"{engineName}", first.processAvailableMemoryGb.ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("Available Memory at end", "unit", "Gb");
                logTableActivity.AddItem("Available Memory at end", $"{engineName}", last.processAvailableMemoryGb.ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("Available Memory change", "unit", "Gb");
                logTableActivity.AddItem("Available Memory change", $"{engineName}", (last.processAvailableMemoryGb - first.processAvailableMemoryGb).ToString(_statsFormatGbChange));
                logTableActivity.AddUniqueItem("Available Memory min", "unit", "Gb");
                logTableActivity.AddItem("Available Memory min", $"{engineName}", lItems.Min(x => x.processAvailableMemoryGb).ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("Available Memory avg", "unit", "Gb");
                logTableActivity.AddItem("Available Memory avg", $"{engineName}", lItems.Average(x => x.processAvailableMemoryGb).ToString(_statsFormatGb));
                logTableActivity.AddUniqueItem("Available Memory max", "unit", "Gb");
                logTableActivity.AddItem("Available Memory max", $"{engineName}", lItems.Max(x => x.processAvailableMemoryGb).ToString(_statsFormatGb));

                //sep
                logTableActivity.AddSeparatorAfterRow("Available Memory max");

                //Working threads
                logTableActivity.AddUniqueItem("Working Threads at start", "unit", "");
                logTableActivity.AddItem("Working Threads at start", $"{engineName}", first.threadPoolStatusWorkingThreads.ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Working Threads at end", "unit", "");
                logTableActivity.AddItem("Working Threads at end", $"{engineName}", last.threadPoolStatusWorkingThreads.ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Working Threads change", "unit", "");
                logTableActivity.AddItem("Working Threads change", $"{engineName}", (last.threadPoolStatusWorkingThreads - first.threadPoolStatusWorkingThreads).ToString(_statsFormatThreadsChange));
                logTableActivity.AddUniqueItem("Working Threads min", "unit", "");
                logTableActivity.AddItem("Working Threads min", $"{engineName}", lItems.Min(x => x.threadPoolStatusWorkingThreads).ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Working Threads avg", "unit", "");
                logTableActivity.AddItem("Working Threads avg", $"{engineName}", lItems.Average(x => x.threadPoolStatusWorkingThreads).ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Working Threads max", "unit", "");
                logTableActivity.AddItem("Working Threads max", $"{engineName}", lItems.Max(x => x.threadPoolStatusWorkingThreads).ToString(_statsFormatThreads));

                //sep
                logTableActivity.AddSeparatorAfterRow("Working Threads max");

                //idle threads
                logTableActivity.AddUniqueItem("Idle Threads at start", "unit", "");
                logTableActivity.AddItem("Idle Threads at start", $"{engineName}", first.threadPoolStatusIdleThreads.ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Idle Threads at end", "unit", "");
                logTableActivity.AddItem("Idle Threads at end", $"{engineName}", last.threadPoolStatusIdleThreads.ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Idle Threads change", "unit", "");
                logTableActivity.AddItem("Idle Threads change", $"{engineName}", (last.threadPoolStatusIdleThreads - first.threadPoolStatusIdleThreads).ToString(_statsFormatThreadsChange));
                logTableActivity.AddUniqueItem("Idle Threads min", "unit", "");
                logTableActivity.AddItem("Idle Threads min", $"{engineName}", lItems.Min(x => x.threadPoolStatusIdleThreads).ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Idle Threads avg", "unit", "");
                logTableActivity.AddItem("Idle Threads avg", $"{engineName}", lItems.Average(x => x.threadPoolStatusIdleThreads).ToString(_statsFormatThreads));
                logTableActivity.AddUniqueItem("Idle Threads max", "unit", "");
                logTableActivity.AddItem("Idle Threads max", $"{engineName}", lItems.Max(x => x.threadPoolStatusIdleThreads).ToString(_statsFormatThreads));
            }

            logTableActivity.SysLog();

            Sys.Log($"----------------------------------------------------");
            swStats.Stop();
            Sys.Log($"Log Engine Activity Stats [{Sys.TimerGetText(swStats.ElapsedMilliseconds)}]");
            Sys.Log($"----------------------------------------------------");
        }