public void AlertMail(IStatistic st)
        {
            bool IsMailTest    = Constant.IsMailTest;
            bool IsMailEnabled = Constant.IsMailEnabled;

            if (IsMailEnabled == false)
            {
                return;
            }

            decimal  avgSession       = Math.Round(st.TotalStatisticSession().Percent, 0);
            decimal  avgProcess       = Math.Round(st.TotalStatisticProcess().Percent, 0);
            decimal  ParameterSession = Math.Round(st.GetParameterSession(), 0);
            decimal  ParameterProcess = Math.Round(st.GetParameterProcess(), 0);
            DateTime eventDT          = st.TotalStatisticSession().Cdt;

            if (avgProcess >= 80 || avgSession >= 80 || IsMailTest)
            {
                StringBuilder subject = new StringBuilder();
                subject.Append("Alert PI ORACLE DB Performance (over 80%)- ");
                subject.Append("Session: "); subject.Append(avgSession.ToString()); subject.Append("% , ");
                subject.Append("Process: "); subject.Append(avgProcess.ToString()); subject.Append("%");

                StringBuilder content = new StringBuilder();

                content.Append(@"<h3>PIP ORACLE Database performance averaged over the last five minutes more than 80%: </h3>");
                content.Append(@"<p>event: " + eventDT.ToString("yyyy/MM/dd HH:mm:ss") + "</p>");
                content.Append(@"<p>Average usage Percentage of Database:");
                content.Append(@"<ul>");
                content.Append(@"<li>Session: ");
                content.Append(avgSession.ToString());
                content.Append(@" % </li>");
                content.Append(@"<li>Process: ");
                content.Append(avgProcess.ToString());
                content.Append(@" % </li>");
                content.Append(@"</ul>");
                content.Append(@"</p>");
                content.Append(@"<p>");
                content.Append(@"Please refer to the following url for the detail: <br />");
                content.Append(@"<a href='" + Constant.B2BDBPerfURL + "'>B2B Service/Database Performance Monitoring</a>");
                content.Append(@"</p>");

                try
                {
                    Method.SendMail(subject.ToString(), content.ToString());
                }
                catch
                {
                    // do nothing;
                }
            }
        }
Example #2
0
        public MonitorDB(string server)
        {
            IStatistic st = DataAccess.CreateStatistic(server);

            CurrentParameter      = st.GetParameter();
            ParameterSessionValue = st.GetParameterSession();
            ParameterProcessValue = st.GetParameterProcess();
            CurrentSession        = st.StatisticSession();
            CurrentProcess        = st.StatisticProcess();
            TotalSession          = st.TotalStatisticSession();
            TotalProcess          = st.TotalStatisticProcess();

            CurrentMONITOR_DB = st.QueryMONITOR_DB();
            MaxSessionValue   = st.GetMaxSessionValue();
            MaxProcessValue   = st.GetMaxProcessValue();

            MaxSessionPercent = Math.Round(100 * MaxSessionValue / ParameterSessionValue, 2);
            MaxProcessPercent = Math.Round(100 * MaxProcessValue / ParameterProcessValue, 2);
        }