Ejemplo n.º 1
0
 public NetClient(ServerDetail hostDetail, string _name, string _identifier)
 {
     instance   = this;
     HostDetail = hostDetail;
     Name       = _name;
     Identifier = _identifier;
 }
Ejemplo n.º 2
0
        public List <ServerDetail> getServerInfo(string serverType, string status)
        {
            List <ServerDetail> lSd = new List <ServerDetail>();
            string        conString = ConfigurationManager.ConnectionStrings["VitalSignsConnectionString"].ToString();
            VSAdaptor     VSA       = new VSAdaptor();
            StringBuilder s         = new StringBuilder();

            serverType = serverType.Replace(" (*)", "");
            if (serverType == "All" && status != "All")
            {
                s.Append("select Name,details,description,status from status where StatusCode='" + status + "'");
            }
            //else if(serverType =="All" && status == "All" )
            //    s.Append("select Name,details,description from status");
            else
            {
                s.Append("select Name,details,description,status from status where (TYPE='" + serverType + "' OR SecondaryRole='" + serverType + "')  and StatusCode='" + status + "'");
            }
            DataTable DT = VSA.FetchData(conString, s.ToString());

            foreach (DataRow dr in DT.Rows)
            {
                ServerDetail sd = new ServerDetail();
                sd.ServerName    = dr[0].ToString();
                sd.ServerDetails = dr[1].ToString();
                sd.Comment       = dr[2].ToString();
                sd.Status        = dr["Status"].ToString();
                lSd.Add(sd);
            }

            return(lSd);
        }
Ejemplo n.º 3
0
        private void CheckForHighResponseTime(MonitorRequest request, RequestSummary requestSummary)
        {
            EventType type = Facade.EventTypeDomainController.GetTypeByName(StaticStrings.ResponseTimeHigh);

            if (request.RequestTimeMiliSeconds > type.PeakValue)
            {
                //Lav notification
                Notification notification = new Notification();
                notification.Seen    = false;
                notification.Created = DateTime.Now;
                notification         = Facade.NotificationDomainController.Create(notification);
                //request should have serverId SOMEDAY
                // Facade.ServerDetailDomainController.GetLatestServerDetail(request.ServerId);

                int serverInterval = Facade.SettingDomainController.GetValueByName(StaticStrings.ServerDetailInterval);
                //If interval = 10min -> check 15min back
                ServerDetail latestServerDetailSummary = Facade.ServerDetailDomainController.GetLatestServerDetailByInterval(serverInterval + (serverInterval / 2));

                Event e = new Event();
                e.Created          = DateTime.Now;
                e.Value            = Convert.ToInt32(request.RequestTimeMiliSeconds);
                e.EventTypeId      = type.Id;
                e.NotificationId   = notification.Id;
                e.RequestSummaryId = requestSummary == null ? 0 : requestSummary.Id;
                e.ServerDetailId   = latestServerDetailSummary == null ? 0 : latestServerDetailSummary.Id;

                Facade.EventDomainController.Create(e);
            }
        }
Ejemplo n.º 4
0
        static async Task <Uri> CreateServerDetailAsync(ServerDetail serverDetails, HttpClient client)
        {
            HttpResponseMessage response = null;

            try
            {
                Console.WriteLine("Sending server data...");
                response = await client.PostAsJsonAsync("api/ServerDetails/PostServerDetail/", serverDetails);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Console.WriteLine("Successfully sent information");
                }
                else
                {
                    Console.WriteLine("CreateServerDetailAsync - status code " + response.StatusCode);
                    Program.log.Info("CreateServerDetailAsync - status code " + response.StatusCode);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("CreateServerDetailAsync - Error " + e);
                Program.log.Info("CreateServerDetailAsync - Error " + e);
            }

            // Return the URI of the created resource.
            return(response.Headers.Location);
        }
Ejemplo n.º 5
0
        private void CreateServerDownEvent(ServerDataViewModel sdvm)
        {
            try
            {
                Model.EventType type                      = Facade.EventTypeDomainController.GetTypeByName(StaticStrings.ServerDown);
                int             serverInterval            = Facade.SettingDomainController.GetValueByName(StaticStrings.ServerDetailInterval);
                RequestSummary  requestSummary            = Facade.RequestSummaryDomainController.GetRequestSummaryLastMinutes(serverInterval);
                ServerDetail    latestServerDetailSummary = Facade.ServerDetailDomainController.GetLatestServerDetailByInterval(serverInterval + (serverInterval / 2));

                Notification n = new Notification();
                n.Seen = false;
                n      = Facade.NotificationDomainController.Create(n);

                Model.Event e = new Model.Event();
                e.Created          = DateTime.Now;
                e.Value            = 1;
                e.EventTypeId      = type.Id;
                e.RequestSummaryId = requestSummary == null ? 0 : requestSummary.Id;
                e.ServerDetailId   = latestServerDetailSummary == null ? 0 : latestServerDetailSummary.Id;
                e.NotificationId   = n.Id;
                Facade.EventDomainController.Create(e);
                sdvm.Uptime        = CalculateUpTime(0);
                sdvm.CurrentStatus = false;
            }
            catch (Exception e)
            {
                log.Error("ServerLogic - CreateServerDownEvent: " + e);
            }
        }
Ejemplo n.º 6
0
    IEnumerator RequestServerList()
    {
        List <ServerDetail> servers = GetComponent <SplashController> ().servers;

        Debug.Log("Updating Server List...");

        www = new WWW(url);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(www.error);
        }
        else
        {
            serverList = www.text;
        }
        string[] alldataRow = serverList.Split('\n');

        foreach (string line in alldataRow)
        {
            if (String.IsNullOrEmpty(line))
            {
                continue;
            }
            string[] strCol = line.Split('\t');
            if (strCol.Length == 0)
            {
                continue;
            }
            string skey = strCol [0];
            if (string.IsNullOrEmpty(skey))
            {
                yield return(0);
            }
            ServerDetail sd = new ServerDetail(strCol);
            servers.Add(sd);
        }
        if (servers.Count > 0)
        {
            this.GetComponent <SplashController> ().LoadingProgress.GetComponent <UISlider> ().sliderValue = 1.0f;
            BoxManager.removeMessage();
            this.GetComponent <SplashController> ().DownloadListFinish();
            this.GetComponent <SplashController> ().UIForLoadServer(false);
            this.enabled = false;
            //use updated server
        }
        else
        {
//			BoxManager.showMessage("获取服务器列表失败,请重试",ClientConfigure.title);
            BoxManager.showMessageByID((int)MessageIdEnum.Msg145);
            UIEventListener.Get(BoxManager.buttonYes).onClick += Reconnect;
            //generator server list failed; use local server list
        }
    }
Ejemplo n.º 7
0
        public NetHost(ServerDetail detail)
        {
            instance = this;
            Detail = detail;

            Listener = new TcpListener(Detail.EndPoint);
            Listener.Start();

            IsRunning = true;
            AcceptClientTask = Task.Run(AcceptClient);
        }
Ejemplo n.º 8
0
        static int HostCommand()
        {
            var broadcast   = Broadcast.Instance;
            var dummyServer = new ServerDetail("Dummy", "001122AABBCC", "127.0.0.1", 2333);

            broadcast.StartBroadcast(dummyServer);
            while (true)
            {
            }
            return(0);
        }
Ejemplo n.º 9
0
        public void Test()
        {
            var dummyServer = new ServerDetail("Dummy", "001122AABBCC", "127.0.0.1", 2333);

            broadcast.StartBroadcast(dummyServer);

            var task = broadcast.GetServer();

            task.Wait();
            var receivedServer = task.Result;

            Assert.Equal(dummyServer, receivedServer);
        }
    void OnEnable()
    {
#if UNITY_EDITOR
        GetComponent <ServerListDownloader>().enabled = true;
#elif UNITY_STANDALONE_WIN
        GetComponent <ServerListDownloader>().enabled = false;
#elif UNITY_IPHONE
        GetComponent <ServerListDownloader>().enabled = true;
#elif UNITY_ANDROID
        GetComponent <ServerListDownloader>().enabled = true;
#else
        ServerDetail sd = new ServerDetail();
        sd.address = "http://127.0.0.1:8080/XJGameServer/s";
        sd.name    = "LocalHost";
        sd.state   = ServerDetail.ServerState.New;
        servers.Add(sd);
#endif
    }
Ejemplo n.º 11
0
        public List <ServerDetails> getExecutiveSummary()
        {
            List <ServerDetails> lSd      = new List <ServerDetails>();
            string              conString = ConfigurationManager.ConnectionStrings["VitalSignsConnectionString"].ToString();
            VSAdaptor           VSA       = new VSAdaptor();
            StringBuilder       s         = new StringBuilder();
            List <ServerDetail> lSd1      = new List <ServerDetail>();

            s.Append("select Name,details,description,statuscode,status from  status where  StatusCode in ('Issue','Maintenance','Not Responding','OK') order by statuscode");
            string    statusCode = "";
            DataTable DT         = VSA.FetchData(conString, s.ToString());

            foreach (DataRow dr in DT.Rows)
            {
                ServerDetail sr = new ServerDetail();

                sr.Status        = dr["Status"].ToString();
                sr.Comment       = dr[2].ToString();
                sr.ServerName    = dr[0].ToString();
                sr.ServerDetails = dr[1].ToString();

                if ((statusCode != "" && statusCode != dr[3].ToString()))
                {
                    ServerDetails SS1 = new ServerDetails();
                    SS1.Status = statusCode;
                    SS1.sd     = lSd1.ToArray();

                    lSd.Add(SS1);
                    lSd1.Clear();
                }
                lSd1.Add(sr);
                statusCode = dr[3].ToString();
            }
            ServerDetails SS2 = new ServerDetails();

            SS2.Status = statusCode;
            SS2.sd     = lSd1.ToArray();

            lSd.Add(SS2);
            return(lSd);
        }
Ejemplo n.º 12
0
        public static void SendServerInfo()
        {
            HttpClient client = new HttpClient();

            APISetup.AddHeaders(client);
            try
            {
                var          temp          = Temperature.Temperatures;
                ServerDetail serverDetails = new ServerDetail
                {
                    Created            = DateTime.Now,
                    CpuUtilization     = Convert.ToInt32(Program.cpuCounter.NextValue()),
                    Processes          = GetProcesses(),
                    UpTime             = Convert.ToInt32(Program.upTime.NextValue()),
                    RamAvailable       = Convert.ToInt32(Program.ramCounter.NextValue()),
                    RamTotal           = Convert.ToInt32(GetTotalMemoryInBytes()),
                    BytesReceived      = Program.bytesReceived,
                    BytesSent          = Program.bytesSent,
                    ServerId           = Program.ServerId,
                    Temperature        = temp.HasValue ? Convert.ToDecimal(temp.GetValueOrDefault()) : 0,
                    NetworkUtilization = Convert.ToDecimal(Network.GetNetworkUtilization()),
                    HarddiskUsedSpace  = Convert.ToDecimal(HarddiskStatus.UsedDiskSpace()),
                    HarddiskTotalSpace = Convert.ToDecimal(HarddiskStatus.TotalDiskSpace()),
                    Handles            = Convert.ToDecimal(GetHandles()),
                    Threads            = Convert.ToDecimal(GetThreads())
                };
                Network.ResetNetwork();
                Program.bytesSent     = 0;
                Program.bytesReceived = 0;
                var result = CreateServerDetailAsync(serverDetails, client).Result;
            }
            catch (Exception e)
            {
                Program.log.Info("SendServerInfo - Error: " + e);
                Environment.Exit(0);
            }
        }
Ejemplo n.º 13
0
        public HttpResponseMessage PostServerDetailCurrent(ServerDetailModel serverDetails)
        {
            try
            {
                if (serverDetails == null || serverDetails.ServerName == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.BadRequest));
                }
                //Server regonized?
                Server s = Facade.ServerDomainController.GetServerByName(serverDetails.ServerName);
                if (s == null)
                {
                    s      = new Server();
                    s.Name = serverDetails.ServerName;
                    s      = Facade.ServerDomainController.CreateServer(s);
                }
                //Create everytime!
                ServerDetailCurrent currentServerDetail = new ServerDetailCurrent();
                currentServerDetail.Handles            = serverDetails.Handles;
                currentServerDetail.Utilization        = serverDetails.Utilization;
                currentServerDetail.Thread             = serverDetails.Thread;
                currentServerDetail.Processes          = serverDetails.Processes;
                currentServerDetail.UpTime             = serverDetails.Uptime;
                currentServerDetail.RAMUtilization     = serverDetails.RAMUtilization;
                currentServerDetail.RAMAvailable       = serverDetails.RAMAvailable;
                currentServerDetail.RAMTotal           = serverDetails.RAMTotal;
                currentServerDetail.BytesReceived      = serverDetails.BytesReceived;
                currentServerDetail.BytesSent          = serverDetails.BytesSent;
                currentServerDetail.NetworkUtilization = serverDetails.NetworkUtilization;
                currentServerDetail.ServerId           = s.Id;
                Facade.ServerDetailCurrentDomainController.CreateServerDetailCurrent(currentServerDetail);
                //Styrer den sidste del af grafen (Bliver slettet løbende)



                //ServerSummary hvert interval!

                //der gemmes et summary hvert interval (10 MIN). DVS 13:35, består af data fra 13:30-13:40

                //ved 13:30, kan vi gemme (summary 13:45)
                //ved 13:40, kan vi gemme (summary 13:35) OSV

                //KL 13:50:01, tjekker vi 15minutter tilbage (1,5 interval)

                //Get the interval
                int serverInterval = Facade.SettingDomainController.GetValueByName(StaticStrings.ServerDetailInterval);
                //If interval = 10min -> check 15min back
                ServerDetail latestServerDetailSummary = Facade.ServerDetailDomainController.GetLatestServerDetailByInterval(serverInterval + (serverInterval / 2));
                //If null, create new
                if (latestServerDetailSummary == null)
                {
                    //get all servercurrent
                    List <ServerDetailCurrent> currentServerDetailsList = Facade.ServerDetailCurrentDomainController.GetAll();
                    //create new serverdetailSummary with the averages from all servercurrent
                    ServerDetail serverDetailSummary = new ServerDetail();
                    serverDetailSummary.Handles            = Convert.ToInt32(currentServerDetailsList.Average(x => x.Handles));
                    serverDetailSummary.RAMAvailable       = Convert.ToInt32(currentServerDetailsList.Average(x => x.RAMAvailable));
                    serverDetailSummary.RAMTotal           = Convert.ToInt32(currentServerDetailsList.Average(x => x.RAMTotal));
                    serverDetailSummary.Thread             = Convert.ToInt32(currentServerDetailsList.Average(x => x.Thread));
                    serverDetailSummary.Processes          = Convert.ToInt32(currentServerDetailsList.Average(x => x.Processes));
                    serverDetailSummary.Utilization        = Convert.ToInt32(currentServerDetailsList.Average(x => x.Utilization));
                    serverDetailSummary.ServerId           = currentServerDetailsList.FirstOrDefault().ServerId;
                    serverDetailSummary.UpTime             = currentServerDetailsList.LastOrDefault().UpTime;
                    serverDetailSummary.Created            = GetStartOfInterval(DateTime.Now, serverInterval);
                    serverDetailSummary.BytesSent          = currentServerDetailsList.Sum(x => x.BytesSent);
                    serverDetailSummary.BytesReceived      = currentServerDetailsList.Sum(x => x.BytesReceived);
                    serverDetailSummary.NetworkUtilization = Convert.ToInt32(currentServerDetailsList.Average(x => x.NetworkUtilization));

                    latestServerDetailSummary = Facade.ServerDetailDomainController.Create(serverDetailSummary);
                }

                //Events - Could add more


                RequestSummary requestSummary = Facade.RequestSummaryDomainController.GetRequestSummaryLastMinutes(serverInterval);

                EventLogic      ev           = new EventLogic(); //Move most logic to this. Maybe make generic method for creating events?
                Model.EventType cpuEventType = Facade.EventTypeDomainController.GetTypeByName(StaticStrings.CpuUsageHigh);
                if (currentServerDetail.Utilization > cpuEventType.PeakValue)
                {
                    //Notification
                    Notification n = Facade.NotificationDomainController.Create(new Notification());

                    //Event
                    Model.Event e = new Model.Event();
                    //ServerDetail -> tage nuværende snapshot, eller tage summary eller begge?
                    e.ServerDetailId = latestServerDetailSummary.Id; //Server summary
                                                                     // requestSummary i dette tidsrum
                    e.RequestSummaryId = requestSummary == null ? 0 : requestSummary.Id;
                    e.Created          = DateTime.Now;
                    e.EventTypeId      = cpuEventType.Id;
                    e.NotificationId   = n.Id;
                    e.Value            = serverDetails.Utilization;
                    Model.Event createdEvent = Facade.EventDomainController.Create(e);

                    //Notify by email?
                    if (cpuEventType.Notify)
                    {
                        EmailManager emailManager = new EmailManager();
                    }
                }
                Model.EventType ramEventType = Facade.EventTypeDomainController.GetTypeByName(StaticStrings.LowMemory);
                if (currentServerDetail.RAMAvailable < ramEventType.PeakValue)
                {
                    //Notification
                    Notification n = Facade.NotificationDomainController.Create(new Notification());

                    //Event
                    Model.Event e = new Model.Event();
                    e.ServerDetailId   = latestServerDetailSummary.Id;
                    e.RequestSummaryId = requestSummary == null ? 0 : requestSummary.Id;
                    e.Created          = DateTime.Now;
                    e.EventTypeId      = ramEventType.Id;
                    e.NotificationId   = n.Id;
                    e.Value            = serverDetails.RAMAvailable;
                    Model.Event createdEvent = Facade.EventDomainController.Create(e);

                    //Notify by email?
                    if (ramEventType.Notify)
                    {
                        EmailManager emailManager = new EmailManager();
                    }
                }
            }
            catch (Exception e)
            {
                var response = new HttpResponseMessage(HttpStatusCode.BadRequest);
                response.Content = new StringContent("Error: " + e);
                return(response);
            }


            //Slet Dem her?
            int setupInterval = Facade.SettingDomainController.GetValueByName(StaticStrings.ServerDetailInterval);

            Facade.ServerDetailCurrentDomainController.DeleteAllOlderThanInterval(setupInterval);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Ejemplo n.º 14
0
 public HostHandler(ServerDetail detail)
 {
     Detail = detail;
 }