Ejemplo n.º 1
0
        public bool StoreActivity(string engineName, string activityXML)
        {
            EngineActivityItem item = new EngineActivityItem(engineName);

            if (!item.Parse(activityXML))
            {
                return(false);
            }

            List <EngineActivityItem> l = _dItemStore.AddOrUpdate(engineName, new List <EngineActivityItem> {
                item
            }, (k, v) => { v.Add(item); return(v); });

            item.LogItem();
            if (_dump)
            {
                Dump(engineName, activityXML, l.Count);
            }

            return(true);
        }
Ejemplo n.º 2
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($"----------------------------------------------------");
        }