private MonitorState GetRemoteState() { MonitorState resultMonitorState = new MonitorState() { State = CollectorState.NotAvailable }; string currentHostAddress = EnableRemoteExecute ? RemoteAgentHostAddressFormatted : OverrideRemoteAgentHostAddressFormatted; int currentHostPort = EnableRemoteExecute ? this.RemoteAgentHostPort : OverrideRemoteAgentHostPort; try { //First set blank/NA state foreach (ICollector ca in CollectorAgents) { ca.CurrentState = new MonitorState() { ForAgent = ca.Name, State = CollectorState.NotAvailable, RawDetails = "Calling Remote agent" }; } resultMonitorState = RemoteCollectorHostService.GetCollectorHostState(this, currentHostAddress, currentHostPort); //Setting agent states to returned MonitorState child states foreach (var agentState in resultMonitorState.ChildStates) { if (agentState.ForAgentId > -1 && agentState.ForAgentId < CollectorAgents.Count) { CollectorAgents[agentState.ForAgentId].CurrentState = agentState.Clone(); } } } catch (Exception ex) { resultMonitorState.Timestamp = DateTime.Now; if (RunLocalOnRemoteHostConnectionFailure && ex.Message.Contains("There was no endpoint listening")) { //attempting to run locally resultMonitorState.RawDetails = string.Format("Remote Host call failed. Attempting to run locally. {0}", resultMonitorState.RawDetails); try { resultMonitorState = GetStateFromLocal(); } catch (Exception innerEx) { resultMonitorState.State = CollectorState.Error; resultMonitorState.RawDetails = string.Format("Remote Host call failed. Attempting to run locally. {0}", innerEx.ToString()); resultMonitorState.CurrentValue = "Remote Host call failed(local)"; resultMonitorState.ExecutedOnHostComputer = System.Net.Dns.GetHostName(); } } else { resultMonitorState.State = CollectorState.Error; resultMonitorState.RawDetails = ex.ToString(); resultMonitorState.CurrentValue = "Remote Host call failed"; //\r\n" + ex.Message; resultMonitorState.ExecutedOnHostComputer = System.Net.Dns.GetHostName(); } } return(resultMonitorState); }
private System.Data.DataSet GetAllAgentDetailsRemote() { System.Data.DataSet result = new System.Data.DataSet(); string currentHostAddress = EnableRemoteExecute ? this.RemoteAgentHostAddress : OverrideRemoteAgentHostAddress; int currentHostPort = EnableRemoteExecute ? this.RemoteAgentHostPort : OverrideRemoteAgentHostPort; try { result = RemoteCollectorHostService.GetRemoteHostAllAgentDetails(this, currentHostAddress, currentHostPort); } catch (Exception ex) { if (RunLocalOnRemoteHostConnectionFailure && ex.ToString().Contains("There was no endpoint listening")) { //attempting to run locally result = GetAllAgentDetailsLocal(); } else { throw; } } return(result); }
public System.Data.DataSet GetAllAgentDetailsRemote(string hostAddress, int hostPort) { System.Data.DataSet result = new System.Data.DataSet(); result = RemoteCollectorHostService.GetRemoteHostAllAgentDetails(this, hostAddress, hostPort); return(result); }