Ejemplo n.º 1
0
        public void LoggerWork()
        {
            while (!bIsServiceReady)
            {
                Thread.Sleep(1000);
            }

            IISLogHandler.IISLogOperation LogOp = new IISLogHandler.IISLogOperation();

            if (g_SharedData.WEB_SETTING.bIISLogAnalysis)
            {
                do
                {
                    LogOp.g_SharedData = g_SharedData;

                    try
                    {
                        if (bIsServiceReady)
                        {
                            if (LogOp.BuildAnalsysIISLog())
                            {
                                if (LogOp.AnalyzeIISLogCommands())
                                {
                                    LogOp.LoadAnalysisFilesToDataTable();
                                    LogOp.InsertAllToDB();

                                    if (bFirstRunIISLog)
                                    {
                                        WSPEvent.WriteEvent("Service Point Agent started collecting IIS Log successfully.", "I", 1002);
                                        bFirstRunIISLog = false;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        WSPEvent.WriteEvent("Service Point Agent failed to analyze IIS Log. - " + ex.Message, "W", 1161);
                    }

                    Thread.Sleep(300000);              // To run every 5 minutes
                }while (g_SharedData.WEB_SETTING.bIISLogAnalysis && _bLoggerThreadFlag);
            }
        }
Ejemplo n.º 2
0
        private void ObserverCheck(object obj)
        {
            if (!bIsServiceReady)
            {
                return;
            }

            g_GlobalGUID = Guid.NewGuid();
            g_TimeIn     = DateTime.Now;
            g_TimeIn_UTC = DateTime.UtcNow;
            //g_TimeIn = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            //g_TimeIn_UTC = Convert.ToDateTime(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));

            _bThreadFlag = true;          // RESUME PERF DATA THREAD

            bool bIsMaxAgentMemory = false;

            PerfReaders.g_SharedData = g_SharedData;

            //bIsMaxAgentMemory = PerfReaders.ReadWSPAgentMemorySize();

            if (bIsMaxAgentMemory)
            {
                PerfReaders.StopPerformanceReaders();

                _shouldStop        = true;
                _bThreadFlag       = false;
                _bLoggerThreadFlag = false;
                _bHCThreadFlag     = false;

                WSPEvent.WriteEvent("Service Point Agent reached its maximum memory size. This service process will be shutdowned, and resumed", "W", 1168);

                Thread.Sleep(10000);

                Environment.Exit(1);
            }


            // test code - to enable agent CPU chk.
            bool bIsHighCPU = false;

            //bIsHighCPU = PerfReaders.CheckSPAgentCPUStatus();

            if (bIsHighCPU)
            {
                iAgentHighCPUCounter++;

                if (iAgentHighCPUCounter == 3)   // 3회 연속
                {
                    g_SharedData.WEB_SETTING.bIISLogAnalysis = false;
                    WSPEvent.WriteEvent("Because of high CPU utilization of Service Point Agent, it will turn off [Enable IIS Log Analysis] option until restarting this service.", "W", 1208);
                }

                if (iAgentHighCPUCounter == 12)  // 3분 이상
                {
                    WSPEvent.WriteEvent("Because of high CPU utilization of Service Point Agent, it will turn off [Enable IIS Log Analysis] option in its settings.", "W", 1207);

                    IISLogHandler.IISLogOperation LogOp = new IISLogHandler.IISLogOperation();
                    LogOp.TurnOffIISLogAnalysisOption();

                    WSPEvent.WriteEvent("Service Point Agent reached its maximum CPU Utilzation. This service process will be shutdowned, and resumed", "W", 1206);

                    PerfReaders.StopPerformanceReaders();

                    _shouldStop        = true;
                    _bThreadFlag       = false;
                    _bLoggerThreadFlag = false;
                    _bHCThreadFlag     = false;

                    Thread.Sleep(10000);

                    Environment.Exit(1);
                }
            }
            else
            {
                iAgentHighCPUCounter = 0;
            }
        }