private void cmdRemoteAgentTest_Click(object sender, EventArgs e) { CollectorEntry testCollector = new CollectorEntry(); testCollector.UniqueId = lblId.Text; testCollector.Name = txtName.Text.Trim(); testCollector.Enabled = chkEnabled.Checked; testCollector.IsFolder = currentEditingEntry.IsFolder; if (cboParentCollector.SelectedIndex > 0) { CollectorEntryDisplay ced = (CollectorEntryDisplay)cboParentCollector.SelectedItem; SelectedEntry.ParentCollectorId = ced.CE.UniqueId; } else { SelectedEntry.ParentCollectorId = ""; } if (currentEditingEntry.IsFolder) { testCollector.CollectorRegistrationName = "Folder"; } else { //Collector type testCollector.CollectorRegistrationName = currentEditingEntry.CollectorRegistrationName; testCollector.CollectorRegistrationDisplayName = currentEditingEntry.CollectorRegistrationDisplayName; testCollector.InitialConfiguration = currentEditingEntry.InitialConfiguration; } testCollector.CollectOnParentWarning = chkCollectOnParentWarning.Checked && !currentEditingEntry.IsFolder; testCollector.RepeatAlertInXMin = (int)numericUpDownRepeatAlertInXMin.Value; testCollector.AlertOnceInXMin = (int)AlertOnceInXMinNumericUpDown.Value; testCollector.DelayErrWarnAlertForXSec = (int)delayAlertSecNumericUpDown.Value; testCollector.CorrectiveScriptDisabled = chkCorrectiveScriptDisabled.Checked; testCollector.CorrectiveScriptOnWarningPath = txtCorrectiveScriptOnWarning.Text; testCollector.CorrectiveScriptOnErrorPath = txtCorrectiveScriptOnError.Text; testCollector.EnableRemoteExecute = chkRemoteAgentEnabled.Checked; testCollector.RemoteAgentHostAddress = txtRemoteAgentServer.Text; testCollector.RemoteAgentHostPort = (int)remoteportNumericUpDown.Value; testCollector.EnabledPollingOverride = false; try { MonitorState testState = CollectorEntryRelay.GetRemoteAgentState(testCollector); if (testState.State == CollectorState.Good) { MessageBox.Show("Success", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format("State: {0}\r\nDetails: {1}", testState.State, testState.RawDetails), "Test", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void lblComputer_DoubleClick(object sender, EventArgs e) { try { if (txtComputer.Text.Length > 0) { string versionInfo = CollectorEntryRelay.GetRemoteAgentHostVersion(txtComputer.Text, (int)remoteportNumericUpDown.Value); MessageBox.Show("Version Info: " + versionInfo, "Version", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Version", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RefreshItem(object o) { ListViewItem lvi = (ListViewItem)o; try { try { bool hostExists = false; RemoteAgentInfo ri = (RemoteAgentInfo)lvi.Tag; CollectorEntry ce = new CollectorEntry(); ce.EnableRemoteExecute = true; ce.RemoteAgentHostAddress = ri.Computer; ce.RemoteAgentHostPort = ri.PortNumber; ce.CollectorRegistrationName = "PingCollector"; ce.CollectorRegistrationDisplayName = "Ping Collector"; ce.InitialConfiguration = "<config><hostAddress><entry pingMethod=\"Ping\" address=\"localhost\" description=\"\" maxTimeMS=\"1000\" timeOutMS=\"5000\" httpProxyServer=\"\" socketPort=\"23\" receiveTimeoutMS=\"30000\" sendTimeoutMS=\"30000\" useTelnetLogin=\"False\" userName=\"\" password=\"\" /></hostAddress></config>"; hostExists = System.Net.Dns.GetHostAddresses(ri.Computer).Count() != 0; if (!hostExists) { UpdateListViewItem(lvi, 3, "N/A"); } else { MonitorState testState = CollectorEntryRelay.GetRemoteAgentState(ce); if (testState.State == CollectorState.Good) { try { string versionInfo = CollectorEntryRelay.GetRemoteAgentHostVersion(ri.Computer, ri.PortNumber); UpdateListViewItem(lvi, 0, versionInfo); } catch (Exception ex) { if (ex.Message.Contains("ContractFilter")) { UpdateListViewItem(lvi, 2, "Remote host does not support version info query! Check that QuickMon 3.13 or later is installed."); } else { UpdateListViewItem(lvi, 2, ex.Message); } } } else { UpdateListViewItem(lvi, 2, "N/A"); } } } catch (Exception delegateEx) { if (delegateEx.Message.Contains("The formatter threw an exception while trying to deserialize the message")) { UpdateListViewItem(lvi, 3, "Old version of Remote agent host does not support query or format does not match! Please update remote agent host version."); } else { UpdateListViewItem(lvi, 3, delegateEx.Message); } } } catch (Exception riEx) { UpdateListViewItem(lvi, 1, riEx.ToString()); } }