示例#1
0
    public void CheckRunningQueriesSP()
    {
        DataTable dtQueryList      = new DataTable();
        DataTable dtRunningQueries = new DataTable();
        int       iServerNumber    = g_SharedData.WSP_AGENT_SETTING.iServerNumber;

        try
        {
            if (String.IsNullOrEmpty(strReadRunningQuery))
            {
                WSP.Console.WS_AGENTINITIAL.AgentInitial QueryDefineList = new WSP.Console.WS_AGENTINITIAL.AgentInitial();
                QueryDefineList.Url = g_SharedData.WSP_AGENT_SETTING.strWS_URL + "/AgentInitial.asmx";

                DataTable dtParms = SetParmeterTable();

                byte[] dtResult = QueryDefineList.QueryDefineList(iServerNumber.ToString());

                if (dtResult == null)
                {
                    return;
                }

                dtQueryList = BytesToDataTable(dtResult);

                foreach (DataRow dr in dtQueryList.Rows)
                {
                    if (g_SharedData.LOCAL_SQL_SETTING.bEnableCollectingRunningQueries)
                    {
                        if (Convert.ToInt32(dr["QueryID"].ToString()) == 1)
                        {
                            strReadRunningQuery = dr["Query"].ToString();
                        }
                    }
                }
            }

            dtRunningQueries = CollectRunningQueries(strReadRunningQuery);

            if (dtRunningQueries != null)
            {
                if (dtRunningQueries.Rows.Count > 0)
                {
                    InsertRunningQueries(dtRunningQueries);
                }
            }
        }
        catch (Exception ex)
        {
            WSPEvent.WriteEvent("WSP failed to collect the information of running queries. - " + ex.Message, "W", 1179);
        }
    }
示例#2
0
    public void ReadMonitoringQueriesWS()
    {
        int iServerNumber = g_SharedData.WSP_AGENT_SETTING.iServerNumber;

        try
        {
            SetMonitoringAlertDesc();           // Set Alert Description from Alert Rules table.

            int iSavedQueryCount = iQueryCount;

            WSP.Console.WS_AGENTINITIAL.AgentInitial QueryDefineList = new WSP.Console.WS_AGENTINITIAL.AgentInitial();
            QueryDefineList.Url     = g_SharedData.WSP_AGENT_SETTING.strWS_URL + "/AgentInitial.asmx";
            QueryDefineList.Timeout = 10000;

            DataTable dtParms = SetParmeterTable();

            byte[] dtResult = QueryDefineList.QueryDefineList(iServerNumber.ToString());

            if (dtResult == null)
            {
                return;
            }

            dtChkQuery.Clear();
            dtChkQuery = BytesToDataTable(dtResult);

            iQueryCount = dtChkQuery.Rows.Count;

            if (iQueryCount > 0)
            {
                int  i        = 0;
                bool bEnabled = false;
                int  iQueryID = 0;

                foreach (DataRow dr in dtChkQuery.Rows)            // save query interval foreach Query ID.
                {
                    try
                    {
                        iQueryID = Convert.ToInt32(dr["QueryID"].ToString());
                        bEnabled = Convert.ToBoolean(dr["Enabled"].ToString());

                        iaInterval[i, 0] = iQueryID;
                        iaInterval[i, 1] = Convert.ToInt32(dr["Interval"].ToString());
                        dtLastRun[i]     = DateTime.Now.AddHours(-24.00);
                        i++;

                        if (iQueryID == 4 && bEnabled)      // To Save Linked Server Checking
                        {
                            bMonitorLinkedServer      = true;
                            strLinkedServerQuery      = dr["Query"].ToString();
                            strLinkedServerSP         = dr["SPName"].ToString();
                            strLinkedServerQueryTable = dr["DestinationTable"].ToString();
                        }

                        if (iQueryID == 1)
                        {
                            strReadRunningQuery = dr["Query"].ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        WSPEvent.WriteEvent("Service Point Agent failed to read list of query definitions from DB - " + ex.Message, "W", 1302);
                    }
                }
            }
        }
        catch (Exception e)
        {
            WSPEvent.WriteEvent("Service Point Agent failed to read list of query definitions from DB - " + e.Message, "W", 1128);
        }
    }