示例#1
0
        private void InsertHostWS()
        {
            WSP.Console.WS_AGENTINITIAL.AgentInitial UpdateHoststatusVersion = new WSP.Console.WS_AGENTINITIAL.AgentInitial();
            UpdateHoststatusVersion.Url     = g_SharedData.WSP_AGENT_SETTING.strWS_URL + "/AgentInitial.asmx";
            UpdateHoststatusVersion.Timeout = 10000;

            try
            {
                int    iServerNumber = g_SharedData.WSP_AGENT_SETTING.iServerNumber;
                string Hostname      = g_SharedData.SYSINFO.strComputerName;
                string CurrentStatus = "0";
                string RAMSize       = Convert.ToInt64(g_SharedData.SYSINFO.flRAMSize).ToString();
                string WinVer        = g_SharedData.SYSINFO.strWinVer;
                string Processors    = g_SharedData.SYSINFO.iNumberOfProcessors.ToString();
                string IPAddress     = g_SharedData.SYSINFO.strIPAddress;
                string AgentVer      = g_SharedData.WSP_AGENT_SETTING.iBuildNumber;

                int iResult = UpdateHoststatusVersion.UpdateHoststatus_Version(Hostname, CurrentStatus, RAMSize, WinVer, Processors, IPAddress, AgentVer, iServerNumber);

                if (iResult > 0)
                {
                    bRegisterd = true;
                }
            }
            catch (Exception ex)
            {
                WSPEvent.WriteEvent("Service Point Agent has failed to update this server information. - " + ex.Message, "E", 1170);
            }
        }
示例#2
0
        public bool ReadAlertRules()
        {
            WSP.Console.WS_AGENTINITIAL.AgentInitial AlertRuleList = new WSP.Console.WS_AGENTINITIAL.AgentInitial();
            AlertRuleList.Url     = g_SharedData.WSP_AGENT_SETTING.strWS_URL + "/AgentInitial.asmx";
            AlertRuleList.Timeout = 10000;

            DataTable dtParms = SetParmeterTable();

            try
            {
                if (dtAlertRules.Rows.Count > 0)
                {
                    dtAlertRules.Rows.Clear();
                }

                dtParms.Rows.Add(g_SharedData.WSP_AGENT_SETTING.iServerNumber, "ServerNum", "INT", g_SharedData.WSP_AGENT_SETTING.iServerNumber);

                //byte[] btResult = wsSelect.SelectSPVaules("p_AlertRules_Server_List", DataTableToBytes(dtParms));
                byte[] btResult = AlertRuleList.AlertRuleList(g_SharedData.WSP_AGENT_SETTING.iServerNumber.ToString());

                DataTable dtResult = BytesToDataTable(btResult);

                if (btResult == null || dtResult == null)
                {
                    return(false);
                }
                else
                {
                    dtAlertRules = dtResult.Copy();
                }
            }
            catch (Exception e)
            {
                WSPEvent.WriteEvent("Service Point Agent failed to read rules for alerts - " + e.Message, "E", 1171);
                return(false);
            }

            return(true);
        }
示例#3
0
        public bool ReadPerformanceCounters()
        {
            WSP.Console.WS_AGENTINITIAL.AgentInitial PCIDList = new WSP.Console.WS_AGENTINITIAL.AgentInitial();
            PCIDList.Url     = g_SharedData.WSP_AGENT_SETTING.strWS_URL + "/AgentInitial.asmx";
            PCIDList.Timeout = 10000;

            DataTable dtParms = SetParmeterTable();

            try
            {
                if (dtPCID.Rows.Count > 0)
                {
                    dtPCID.Clear();
                }

                dtParms.Rows.Add(g_SharedData.WSP_AGENT_SETTING.iServerNumber, "ServerNum", "INT", g_SharedData.WSP_AGENT_SETTING.iServerNumber);
                Byte[] btResult = PCIDList.PCIDList(g_SharedData.WSP_AGENT_SETTING.iServerNumber.ToString());

                DataTable dtResult = BytesToDataTable(btResult);

                if (btResult == null || dtResult == null)
                {
                    return(false);
                }
                else
                {
                    dtPCID = dtResult.Copy();
                }
            }
            catch (Exception e)
            {
                WSPEvent.WriteEvent("Service Point Agent failed to read list of performance counters from WSP DB - " + e.Message, "E", 1172);
                return(false);
            }


            try
            {
                dtParms.Rows.Clear();
                if (dtInstanceList.Rows.Count > 0)
                {
                    dtInstanceList.Clear();
                }

                dtParms.Rows.Add(g_SharedData.WSP_AGENT_SETTING.iServerNumber, "ServerNum", "INT", g_SharedData.WSP_AGENT_SETTING.iServerNumber);

                byte[] btPIList = PCIDList.PCIDInstanceList(g_SharedData.WSP_AGENT_SETTING.iServerNumber.ToString());

                DataTable dtResultInstance = BytesToDataTable(btPIList);

                if (btPIList == null || dtResultInstance == null)
                {
                    return(false);
                }
                else
                {
                    dtInstanceList = dtResultInstance.Copy();
                }
            }
            catch (Exception e)
            {
                WSPEvent.WriteEvent("Service Point Agent failed to read list of Instances from WSP DB - " + e.Message, "E", 1146);
                return(false);
            }

            return(true);
        }
示例#4
0
        //Agent Login 서비스 시작
        public bool IsServiceReady()
        {
            WSP.Console.WS_AGENTINITIAL.AgentInitial AgentLogin = new WSP.Console.WS_AGENTINITIAL.AgentInitial();
            AgentLogin.Url     = g_SharedData.WSP_AGENT_SETTING.strWS_URL + "/AgentInitial.asmx";
            AgentLogin.Timeout = 10000;
            g_SharedData.WSP_AGENT_SETTING.iRemainingMinutes = 0;

            DataTable dtParms       = SetParmeterTable();
            int       iServerNumber = g_SharedData.WSP_AGENT_SETTING.iServerNumber;

            try
            {
                dtParms.Rows.Add(iServerNumber, "ProductKey", "STRING", g_SharedData.WSP_AGENT_SETTING.strServerKey);

                byte[] btResult = AgentLogin.AgentLogin(g_SharedData.WSP_AGENT_SETTING.strServerKey);

                if (btResult == null)
                {
                    return(false);
                }

                DataTable dtAgentLogIn = new DataTable();
                dtAgentLogIn = BytesToDataTable(btResult);

                if (dtAgentLogIn == null)
                {
                    return(false);
                }

                foreach (DataRow dr in dtAgentLogIn.Rows)
                {
                    g_SharedData.WSP_AGENT_SETTING.iServerNumber = Convert.ToInt32(dr["ServerNum"].ToString());
                    g_iServerNumber = g_SharedData.WSP_AGENT_SETTING.iServerNumber;

                    if (g_SharedData.WSP_AGENT_SETTING.iServerNumber < 1)       // No valid product key for this server.
                    {
                        WSPEvent.WriteEvent("Service Point Agent has failed to validate product key.", "E", 1169);
                        return(false);
                    }

                    g_SharedData.WSP_AGENT_SETTING.strServerType = dr["ServerType"].ToString();
                    SetServerType();

                    g_SharedData.WSP_AGENT_SETTING.strDisplayName  = dr["DisplayName"].ToString();
                    g_SharedData.WSP_AGENT_SETTING.strDisplayGroup = dr["DisplayGroup"].ToString();
                    g_SharedData.WSP_AGENT_SETTING.iCompanyNumber  = Convert.ToInt32(dr["CompanyNum"]);
                }

                // WHEN AGENT FAILS TO GET SERVER NUMBER, OR IT'S EXPIRED.
                if (g_SharedData.WSP_AGENT_SETTING.iServerNumber <= 0)
                {
                    WSPEvent.WriteEvent("License for Service Point Agent has been expired, or failed to validate the product key.", "E", 1184);
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                WSPEvent.WriteEvent("Service Point Agent has failed to access the database to validate this server. - " + ex.Message, "E", 1169);
                return(false);
            }
        }
示例#5
0
        public void UpdateHostPerfStatus(DataTable dtToBeAlerted, DateTime dtLastPerfDataTimeIn, DateTime g_dtTimeIn_UTC)
        {
            string strReasonCode = "";
            string strAlertLevel = "";
            int    iAlertLevel   = 0;
            int    iMaxLevel     = 0;

            if (dtToBeAlerted.Rows.Count > 0)
            {
                foreach (DataRow dr in dtToBeAlerted.Rows)
                {
                    strReasonCode = dr["ReasonCode"].ToString();
                    var Rows = dtAlertRules.Select("ReasonCode = '" + strReasonCode + "'");

                    foreach (DataRow dr2 in Rows)
                    {
                        strAlertLevel = dr2["AlertLevel"].ToString();
                        if (strAlertLevel == "Information")
                        {
                            iAlertLevel = 1;
                        }
                        if (strAlertLevel == "Warning")
                        {
                            iAlertLevel = 2;
                        }
                        if (strAlertLevel == "Critical")
                        {
                            iAlertLevel = 3;
                        }
                        if (iAlertLevel > iMaxLevel)
                        {
                            iMaxLevel = iAlertLevel;
                        }
                    }
                }
            }

            if (g_SharedData.WSP_AGENT_SETTING.strServerType == "SQL")
            {
                if (g_iSQLMaxAlertLevel > iMaxLevel)
                {
                    iMaxLevel = g_iSQLMaxAlertLevel;
                }
            }

            if (g_SharedData.WSP_AGENT_SETTING.strServerType.ToUpper() == "WEB")
            {
                if (g_iWebMaxAlertLevel > iMaxLevel)
                {
                    iMaxLevel = g_iWebMaxAlertLevel;
                }
            }

            DateTime dtNow         = DateTime.Now;
            int      iServerNumber = g_SharedData.WSP_AGENT_SETTING.iServerNumber;

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

                string CurrentStatus = iMaxLevel.ToString();
                string TimeIn        = dtLastPerfDataTimeIn.ToString("yyyy-MM-dd HH:mm:ss");

                int iResult = UpdateHoststatus.UpdateHoststatus(CurrentStatus, iServerNumber, TimeIn, g_dtTimeIn_UTC.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            catch (Exception ex)
            {
                WSPEvent.WriteEvent("WSP has failed to update host information for performance data. - " + ex.Message, "E", 1167);
            }
        }