// GET: Logs/Details/5 public async Task <IActionResult> Details(string id) { string targetIp = id; if (targetIp == null) { return(NotFound()); } DbSet <Log> logs = _context.Log; IQueryable <LogOf <PingResult> > pingLogs = LogOf <PingResult> .Filter(logs) .Where(pingLog => pingLog.Item.Target == targetIp) ; List <LogOf <PingResult> > allPingLogs = await pingLogs.ToListAsync(); //TODO use chart instead of this pseudo average var averagedPingResult = new PingResult(); averagedPingResult.RoundtripTime = TimeSpan.FromTicks((long)allPingLogs.Average(ping => ping.Item.RoundtripTime.Ticks)); averagedPingResult.Status = 0; averagedPingResult.Target = targetIp; var averagedPingLog = new LogOfPingResult(allPingLogs.Last().TimeStamp, averagedPingResult); return(View(averagedPingLog)); }
public void AverageLatency_PingCountIsThree() { //Assign PingStats stats = new PingStats(); PingResult result1 = new PingResult() { AddressOrIp = "www.google.com", Latency = 0, Status = PingResult.StatusMessage.SUCCESS, }; PingResult result2 = new PingResult() { AddressOrIp = "www.google.com", Latency = 50, Status = PingResult.StatusMessage.SUCCESS, }; PingResult result3 = new PingResult() { AddressOrIp = "www.google.com", Latency = 100, Status = PingResult.StatusMessage.SUCCESS, }; double expectedResult = 50; double actualResult; //act stats.Add(result1); stats.Add(result2); stats.Add(result3); actualResult = stats.AverageLatency; //assert Assert.AreEqual(expectedResult, actualResult); }
public override PingResult Ping() { var result = new PingResult { State = PingEnum.Disconnected }; if (this.socketApi.ConnectionState != HitConnectionState.Connected) { return(result); } try { var pingResult = this.ping.Send(this.pingUri.Host); if (pingResult != null && pingResult.Status == IPStatus.Success) { result.PingTime = TimeSpan.FromMilliseconds(pingResult.RoundtripTime); result.State = PingEnum.Connected; } else { Core.Instance.Loggers.Log($"{HitBTCVendor.VENDOR_NAME}. Error while pinging host: {this.pingUri.Host}"); } } catch (Exception ex) { Core.Instance.Loggers.Log(ex); } return(result); }
private void buttonPing_Click(object sender, EventArgs e) { try { Util.PreMethodCall(this, lblStatus); TaxSvc taxSvc = new TaxSvc(); SetConfig(taxSvc); PingResult result = taxSvc.Ping(""); if (result.ResultCode >= SeverityLevel.Error) { MessageBox.Show(result.Messages[0].Summary, "Ping Result", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Result Code: " + result.ResultCode + "\r\n" + "# Messages: " + result.Messages.Count.ToString() + "\r\n" + "Service Version: " + result.Version, "Ping Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Util.ShowError(ex); } finally { Util.PostMethodCall(this, lblStatus); } }
/// <summary> /// Ping KubeMQ address to check Grpc connection /// </summary> /// <returns></returns> public PingResult Ping() { PingResult rec = GetKubeMQClient().Ping(new Empty()); _logger.LogDebug($"Queue KubeMQ address:{_kubemqAddress} ping result:{rec}"); return(rec); }
/// <summary> /// Log ping results to a file /// </summary> /// <param name="pingResult">new PingResult to append to the file</param> private void LogToFile(PingResult pingResult) { if (IsLoggingEnabled) { LogPingResult.LogToTextFile(pingResult); } }
public void Add_ResultStatusFailureAndSuccess() { //Assign PingStats stats = new PingStats(); PingResult result = new PingResult() { AddressOrIp = "www.google.com", Latency = 1, Status = PingResult.StatusMessage.FAILURE, }; PingResult result2 = new PingResult() { AddressOrIp = "www.google.com", Latency = 5, Status = PingResult.StatusMessage.SUCCESS, }; bool expectedResult = true; bool actualResult; //act stats.Add(result); stats.Add(result2); actualResult = (stats.MaxLatency == 5 && stats.PacketsLost == 1 && stats.PacketsSent == 2 && stats.AverageLatency == 5); //assert Assert.AreEqual(expectedResult, actualResult); }
private void PingEx_ProgressChanged(int arg1, PingResult arg2) { AddLog(arg2.Line); if (arg2.Type == 1) { var group = resultList.GetByIp(arg2.Ip); if (group == null) { group = resultList.Add(arg2.Ip + ":Ping"); group.Archor.Ping = arg2.GetResult(); } else { group.Archor.Ping = arg2.GetResult(); } //AddLog() archorList = OnDataReceive(group); } else { if (PercentChanged != null) { PercentChanged(arg1); } } }
/// <summary> /// Ping check Kubemq response using "low level" Initiator. /// </summary> /// <returns>ping status of kubemq.</returns> public PingResult Ping() { PingResult rec = GetKubeMQClient().Ping(new Empty()); logger.LogTrace($"Initiator sent ping successfully to address {this.ServerAddress}"); return(rec); }
//[Test] public void QATest() { _addressSvc.Configuration.Url = "http://qa.avalara.com/avatax.services"; PingResult pingResult = _addressSvc.Ping(""); Assert.IsTrue(pingResult.Version.StartsWith("4.0.")); Assert.AreEqual(SeverityLevel.Success, pingResult.ResultCode); Address address = new Address(); address.Line1 = "900 Winslow Way"; address.Line2 = "Ste 130"; address.City = "Bainbridge Island"; address.Region = "WA"; address.PostalCode = "98110"; ValidateRequest validateRequest = new ValidateRequest(); validateRequest.Address = address; validateRequest.TextCase = TextCase.Upper; ValidateResult result = _addressSvc.Validate(validateRequest); Assert.AreEqual(SeverityLevel.Success, result.ResultCode); }
/// <summary> /// Each ping will call this when it's done or has failed. When we have all the pings /// we call the completion handler with the ping with the lowest time. /// <param name="p">The ping that just completed.</param> /// </summary> private void PingFinished(Ping p) { PingResult pr = new PingResult(p.ip, p.time); _pingResults.Add(pr); // Log an error if a ping failed, but we need to respond to the matcher with the time regardless, which will be -1. if (!p.isDone && _debugLogging) { Debug.LogError(string.Format("Ping failed for address: {0} with ping time: {1}", p.ip, p.time)); } _ipsLeftToPing--; if (_ipsLeftToPing <= 0) { foreach (PingResult sPing in _pingResults) { if (_debugLogging) { Debug.Log(string.Format("Realtime: IP: {0} Ping Time: {1}", sPing.address, sPing.time)); } } if (_debugLogging && (_connectionState != ConnectionState.PingingRegions || _matcher == null)) { Debug.LogWarning("Realtime: Yo, Jeff here. If you see this log, lmk, you can safely ignore it, but I want to know what's happening. The client (" + _clientIdentifier + ") sent back ping results in the state (" + connectionState + ") which was not PingingRegions."); } else { _matcher.ContinueConnectionWithPingTimes(_pingResults.ToArray()); } } }
private void CallResult(PingRuntimeData runtimeData) { int time = runtimeData.ping == null ? -1 : runtimeData.ping.time; bool isSuccess = runtimeData.errorReason == ErrorReason.None ? true : false; PingResult result = new PingResult(isSuccess, runtimeData.errorReason, runtimeData.host, runtimeData.ip, time); pingResults.Add(result); if (runtimeData.ping != null) { runtimeData.ping.DestroyPing(); } if (s_pingResultCallback != null) { s_pingResultCallback(result); } if (pingRuntimeDatas.Count <= 0) { if (s_OnComplete != null) { s_OnComplete(pingResults.ToArray()); } Destroy(this.gameObject, 0.5f); } }
private void buttonTestConnection_Click(object sender, System.EventArgs e) { //string settings = ""; bool isConnectionSuccess = false; //if(_parent.Account != null || _parent.Account != "" || _parent.Key!= null|| _parent.Key!=""||_parent.UserName!=null||_parent.UserName!=""||_parent.Password!=null||_parent.Password!="") //settings = textAccount.Text +","+ textKey.Text +","+textUserName.Text+","+textPassword.Text; try { this.Cursor = Cursors.WaitCursor; ApplySettings(); AddressSvc addressSvc = new AddressSvc(); _parent.SetConfig(addressSvc); PingResult result = addressSvc.Ping(""); if (result.ResultCode >= SeverityLevel.Error) { MessageBox.Show(result.Messages[0].Summary, "Settings Result", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { IsAuthorizedResult isAuthorizedResult = addressSvc.IsAuthorized("Validate"); if (isAuthorizedResult.ResultCode >= SeverityLevel.Error) { MessageBox.Show(isAuthorizedResult.Messages[0].Summary, "Settings Result", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { isConnectionSuccess = true; MessageBox.Show("Result Code: " + isAuthorizedResult.ResultCode + "\r\n" + "# Messages: " + isAuthorizedResult.Messages.Count + "\r\n" + "Expires: " + isAuthorizedResult.Expires + "\r\n" + "Operations: " + isAuthorizedResult.Operations, "Settings Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { isConnectionSuccess = false; Util.ShowError(ex); } finally { RejectChanges(settings); if (isConnectionSuccess) { buttonApply.Enabled = true; } else { buttonApply.Enabled = false; } this.Cursor = Cursors.Default; } }
void WorkerProgressChanged(object sender, ProgressChangedEventArgs e) { var data = e.UserState as WebSiteItem; if (data != null) { PingResult.SavePingResult(data.Id, e.ProgressPercentage); } }
public TCPingException(double latency, PingStatus status, string?info) { Result = new PingResult { Latency = latency, Status = status, Info = info }; }
/// <summary> /// Initializes a new instance of the <see cref="PingLogAnalyzer"/> class. /// </summary> /// <param name="log">The log.</param> public PingLogAnalyzer(Log log) { TimeStamp = log.Timestamp; PingResult pingResult = JsonConvert.DeserializeObject <PingResult>(log.Data); Target = pingResult.Target; Status = pingResult.Status; RoundtripTime = pingResult.RoundtripTime; }
/// <summary> /// Start an async ping /// </summary> /// <returns></returns> private async Task StartPingTask() { //ping host and log results PingResult pingResult = await Ping.StartPingAsync(); if ((bool)IsPingRunning) { PingResultsList.Add(pingResult); } }
private static void BeforeDelete(DataRow deletedRow, int itemId) { switch (deletedRow.Table.TableName) { case NameDict.WEB_SITE: PingWorker.Instance.StopWorker(itemId); PingResult.ClearPingResult(itemId); break; } }
public IActionResult Get(ApiVersion apiVersion) { var result = new PingResult(apiVersion) { Name = $"NRSRx Test Controller", Build = this.GetBuildNumber() }; return(Ok(result)); }
public ActionResult Get(ApiVersion apiVersion) { var result = new PingResult(apiVersion) { Name = $"NurseCRON {nameof(HealthItem)} API Microservice Controller", Build = this.GetBuildNumber() }; return(Ok(result)); }
public static PingResult ConvertToPingResult(this PingReply reply) { PingResult stat = new PingResult(); stat.Address = reply.Address?.ToString(); stat.Status = reply.Status == IPStatus.Success ? PingStatus.Success : PingStatus.Failed; stat.RoundtripTime = reply.RoundtripTime; stat.BufferSize = reply.Buffer.Length; stat.TimeToLive = reply.Options != null ? reply.Options.Ttl : 0; return(stat); }
public void InitPingMeasurement(PingResult result) { responseDelegate = result; if (Settings.Settings.Instance.PingCompesationActive) { InitPingSystem(); } else { ReturnADisabledLikePingSystem(); } }
public HttpResponseMessage GetChenges(int id) { if (id > 0) { PingResult.ClearPingResult(id); return(CreateResponse(HttpStatusCode.OK)); } else { return(CreateResponse(HttpStatusCode.BadRequest, "Invalid parameters")); } }
public IActionResult Ping() { xServer.Stats.IncrementPublicRequest(); PingResult pingResult = new PingResult() { Version = xServer.Version.ToString(), BestBlockHeight = xServer.AddressIndexerHeight, Tier = (int)xServer.Stats.TierLevel }; return(Json(pingResult)); }
public static void PrintPingTestResult(PingResult result) { Console.WriteLine(); Console.WriteLine("===== Ping Test Result: {0} ===== ", result.TimeStamp); Console.WriteLine("Ping target: {0}", result.PingedTarget); if (!result.IsSuccess) { Console.WriteLine("Ping failed!!!!!!!"); return; } Console.WriteLine("Ping response in: {0} ms", result.ResponseMiliseconds); }
public static PingResult PingServer(string server, Int32 port) { PingResult result = new PingResult(); try { IPAddress ipAddress = System.Net.IPAddress.Parse(server); Stopwatch watch = new Stopwatch(); var pingtimes = new List <Tuple <int, long> >(); for (int i = 0; i < 5; i++) { TcpClient tcpClient = new TcpClient(); IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port); watch.Start(); //method blocks until connection is made or fails tcpClient.Connect(ipEndPoint); watch.Stop(); tcpClient.Close(); long elapsedTimeMs = watch.ElapsedMilliseconds; //pingtimes.Add(new PinginMs() { Iteration = i, PingMs = elapsedTimeMs }); pingtimes.Add(new Tuple <int, long>(i, elapsedTimeMs)); //debug //Console.WriteLine("iteration {0} took {1} ms", i, elapsedTimeMs); watch.Reset(); } var stdDev = pingtimes.Select(x => (double)x.Item2).MeanStandardDeviation(); var max = pingtimes.Select(x => (double)x.Item2).Max(); var min = pingtimes.Select(x => (double)x.Item2).Min(); var average = pingtimes.Select(x => (double)x.Item2).Average(); result.AveragePingTimeMs = stdDev.Item1; result.PingStandardDeviationS = stdDev.Item2; result.MinPingTimeMs = min; result.MaxPingTimeMs = max; result.PingSuccess = true; return(result); } catch (SocketException ex) { Console.WriteLine("Connection check failed {0}", ex); return(null); } }
public void Properties() { var time = TimeSpan.FromSeconds(3); var r = new PingResult { Success = true, Text = "ping", Time = time }; Assert.AreEqual(true, r.Success); Assert.AreEqual("ping", r.Text); Assert.AreEqual(time, r.Time); }
public static PingResult Failed( string failureStatus, string failureDescription, long elapsedMillis ) { PingResult result = new PingResult { Status = failureStatus, Description = failureDescription, ElapsedMillis = elapsedMillis }; return(result); }
public static PingResult Succeeded( string status, string ipAddress, long elapsedMillis ) { PingResult result = new PingResult { Status = status, IpAddress = ipAddress, ElapsedMillis = elapsedMillis }; return(result); }
public static PingResult Failed( string failureStatus, string failureDescription, long elapsedMillis ) { PingResult result = new PingResult { Status = failureStatus, Description = failureDescription, ElapsedMillis = elapsedMillis }; return result; }
public static PingResult Succeeded( string status, string ipAddress, long elapsedMillis ) { PingResult result = new PingResult { Status = status, IpAddress = ipAddress, ElapsedMillis = elapsedMillis }; return result; }
public async void DoPingOne(ServerObservable server) { PingResult result = await _serverList.PingOne(server.Address); // Disable and enable filtering and sorting on latency to prevent servers from moving/disappearing. if (_serversView.CurrentSort.Equals("Latency")) { _serversView.DisableLiveUpdates("Latency"); } HandlePingResult(result); if (_serversView.CurrentSort.Equals("Latency")) { _serversView.EnableLiveUpdates("Latency"); } }