private void LoadCollectorEntry(CollectorEntry ce, TreeNode parentNode) { TreeNode ceNode; if (ce.IsFolder) { ceNode = new TreeNode(ce.Name, 6, 6); } else { ceNode = new TreeNode(ce.CollectorRegistrationName + ": " + ce.Name, 1, 1); } ceNode.Tag = ce; parentNode.Nodes.Add(ceNode); if (!ce.IsFolder && (monitorPack.AgentRegistrations == null || (from cr in monitorPack.AgentRegistrations where cr.IsCollector && cr.Name == ce.CollectorRegistrationName select cr).Count() != 1)) { ceNode.ForeColor = Color.Red; } else if (!ce.Enabled) { ceNode.ForeColor = Color.Gray; } foreach (CollectorEntry childCollector in monitorPack.GetChildCollectors(ce)) { LoadCollectorEntry(childCollector, ceNode); } }
private void configureToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode currentNode = tvwMonPack.SelectedNode; if (currentNode.Tag != null && currentNode.Tag is CollectorEntry) { CollectorEntry ce = (CollectorEntry)currentNode.Tag; EditCollectorEntry editCollectorEntry = new EditCollectorEntry(); string oldParent = ce.ParentCollectorId; editCollectorEntry.SelectedEntry = ce; if (editCollectorEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { ce = editCollectorEntry.SelectedEntry; string uniqueId = ce.UniqueId; RefreshMonitorPack(); TreeNode collectorRootNode = (from TreeNode n in tvwMonPack.Nodes[0].Nodes where n.Name == "Collectors" select n).First(); SelectCollectorNodeById(uniqueId, collectorRootNode); } } else if (currentNode.Tag != null && currentNode.Tag is NotifierEntry) { NotifierEntry ne = (NotifierEntry)currentNode.Tag;; EditNotifierEntry editNotifierEntry = new EditNotifierEntry(); editNotifierEntry.SelectedEntry = ne; if (editNotifierEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { RefreshMonitorPack(); } } }
private void LoadCollectors(CollectorEntry collector, string indentation) { foreach (CollectorEntry childCollector in (from c in monitorPack.Collectors where c.ParentCollectorId == collector.UniqueId select c)) { ListViewItem lvi = new ListViewItem(indentation + childCollector.Name); lvi.SubItems.Add(childCollector.CollectorRegistrationName); lvi.Tag = childCollector; if (SelectedCollectors.Contains(childCollector.Name)) { lvi.Checked = true; } if (childCollector.IsFolder) { lvi.ImageIndex = folderImgIndex; } else { lvi.ImageIndex = collectorImgIndex; } lvwCollectors.Items.Add(lvi); LoadCollectors(childCollector, indentation + indentationChars); } }
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 llblCollectorType_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (MessageBox.Show("Are you sure you want to change the Collector type?\r\n\r\nIf you continue this will reset any existing configuration.", "Collector type", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes) { List <ConfigVariable> configVars = new List <ConfigVariable>(); foreach (ConfigVariable cv in currentEditingEntry.ConfigVariables) { configVars.Add(cv.Clone()); } CollectorEntry newCollector = AgentHelper.CreateNewCollector((from c in monitorPack.Collectors where c.UniqueId == currentEditingEntry.ParentCollectorId select c).FirstOrDefault()); if (newCollector != null) { currentEditingEntry = null; currentEditingEntry = newCollector; currentEditingEntry.ConfigVariables = configVars; llblCollectorType.Text = currentEditingEntry.CollectorRegistrationDisplayName; ApplyConfigToControls(); if (AgentHelper.LastShowRawEditOnStartOption) { llblRawEdit_LinkClicked(sender, e); } } } }
private void LoadParentCollectorList(CollectorEntry parentEntry = null, int indent = 0) { if (cboParentCollector.Items.Count == 0) { cboParentCollector.Items.Add("<None>"); cboParentCollector.SelectedIndex = 0; } if (monitorPack != null) { foreach (CollectorEntry ce in (from c in monitorPack.Collectors where (parentEntry == null && (c.ParentCollectorId == null || c.ParentCollectorId == "")) || (parentEntry != null && parentEntry.UniqueId == c.ParentCollectorId) select c)) { CollectorEntryDisplay ceDisplay = new CollectorEntryDisplay() { Ident = indent, CE = ce }; if (IsNotInCurrentDependantTree(currentEditingEntry.UniqueId, ce)) { cboParentCollector.Items.Add(ceDisplay); } if (ce.UniqueId == currentEditingEntry.ParentCollectorId) { cboParentCollector.SelectedItem = ceDisplay; } LoadParentCollectorList(ce, indent + 1); } } }
private void cmdConfig_Click(object sender, EventArgs e) { if (cboCollector.SelectedItem != null) { try { AgentRegistration ar = (AgentRegistration)cboCollector.SelectedItem; ICollector col = CollectorEntry.CreateCollectorEntry(ar.AssemblyPath, ar.ClassName); if (col != null) { SelectedEntry.Collector = col; if (SelectedEntry.Configuration == null) { SelectedEntry.Configuration = ""; } string newConfig = col.ConfigureAgent(SelectedEntry.Configuration); if (newConfig.Length > 0) { SelectedEntry.Configuration = newConfig; CheckOkEnable(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public EditCollectorEntry() { InitializeComponent(); SelectedEntry = new CollectorEntry(); SelectedEntry.Enabled = true; SelectedEntry.UniqueId = Guid.NewGuid().ToString(); SelectedEntry.ServiceWindows = new ServiceWindows(); }
private void RemoveCollector(TreeNode parentNode) { foreach (TreeNode collectorNode in parentNode.Nodes) { RemoveCollector(collectorNode); } CollectorEntry ce = (CollectorEntry)parentNode.Tag; monitorPack.Collectors.Remove(ce); }
public DialogResult ShowDialog(MonitorPack monitorPack) { this.monitorPack = monitorPack; editingCollectorEntry = CollectorEntry.FromConfig(SelectedEntry.ToConfig()); if (SelectedEntry.Collector != null) { monitorPack.ApplyCollectorConfig(editingCollectorEntry); } return(ShowDialog()); }
private void configureEditButton1_ImportConfigurationClicked(object sender, EventArgs e) { ImportCollectorConfig importCollectorConfig = new ImportCollectorConfig(); importCollectorConfig.IsCollector = true; importCollectorConfig.MonitorPackPath = monitorPack.MonitorPackPath; importCollectorConfig.AgentType = ((RegisteredAgent)cboCollector.SelectedItem).Name; if (importCollectorConfig.ShowDialog() == System.Windows.Forms.DialogResult.OK) { editingCollectorEntry.InitialConfiguration = importCollectorConfig.SelectedConfig; RegisteredAgent ar = (RegisteredAgent)cboCollector.SelectedItem; editingCollectorEntry.Collector = CollectorEntry.CreateCollectorEntry(ar); editingCollectorEntry.Collector.SetConfigurationFromXmlString(importCollectorConfig.SelectedConfig); editingCollectorEntry.CollectorRegistrationName = ar.Name; } }
private void cmdOK_Click(object sender, EventArgs e) { SelectedCollectors = new List <string>(); foreach (ListViewItem lvi in lvwCollectors.Items) { if (lvi.Checked) { CollectorEntry col = (CollectorEntry)lvi.Tag; if (!col.IsFolder) { SelectedCollectors.Add(col.Name); } } } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }
private bool IsNotInCurrentDependantTree(string uniqueId, CollectorEntry ce) { if (ce.UniqueId != uniqueId) { if (ce.ParentCollectorId != null) { CollectorEntry parentCe = (from pce in monitorPack.Collectors where pce.UniqueId == ce.ParentCollectorId select pce).FirstOrDefault(); if (parentCe != null) { return(IsNotInCurrentDependantTree(uniqueId, parentCe)); } } return(true); } return(false); }
private void cmdConfig_Click(object sender, EventArgs e) { if (cboCollector.SelectedItem != null) { try { RegisteredAgent ar = (RegisteredAgent)cboCollector.SelectedItem; ICollector tmpcollector; if (editingCollectorEntry == null) { editingCollectorEntry = new CollectorEntry(); } tmpcollector = CollectorEntry.CreateCollectorEntry(ar); if (tmpcollector != null) { if (editingCollectorEntry.Collector != null && (ar.Name == editingCollectorEntry.CollectorRegistrationName)) { tmpcollector.SetConfigurationFromXmlString(editingCollectorEntry.Collector.AgentConfig.ToConfig()); } else { tmpcollector.SetConfigurationFromXmlString(tmpcollector.GetDefaultOrEmptyConfigString()); } if (txtName.Text.Length == 0) { txtName.Text = "No Name"; } if (tmpcollector.ShowEditConfiguration("Edit '" + txtName.Text + "' Config")) { editingCollectorEntry.Collector = tmpcollector; editingCollectorEntry.InitialConfiguration = tmpcollector.AgentConfig.ToConfig(); editingCollectorEntry.CollectorRegistrationName = ar.Name; } } CheckOkEnable(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void cmdSaveConfig_Click(object sender, EventArgs e) { XmlDocument testXml = new XmlDocument(); try { testXml.LoadXml(txtConfig.Text); editingCollectorEntry.InitialConfiguration = txtConfig.Text; RegisteredAgent ar = (RegisteredAgent)cboCollector.SelectedItem; ICollector tmpcollector = CollectorEntry.CreateCollectorEntry(ar); editingCollectorEntry.Collector = tmpcollector; editingCollectorEntry.Collector.SetConfigurationFromXmlString(txtConfig.Text); editingCollectorEntry.CollectorRegistrationName = ar.Name; HideManualConfig(); } catch (Exception ex) { MessageBox.Show(string.Format("Error parsing xml\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void cmdManualConfig_Click(object sender, EventArgs e) { try { if ((editingCollectorEntry.Collector == null || editingCollectorEntry.Collector.AgentConfig == null) && cboCollector.SelectedItem != null) // || SelectedEntry.Collector.AgentConfig.to .Configuration == null || SelectedEntry.Configuration.Length == 0) && cboCollector.SelectedItem != null) { RegisteredAgent ar = (RegisteredAgent)cboCollector.SelectedItem; ICollector col = CollectorEntry.CreateCollectorEntry(ar); txtConfig.Text = XmlFormattingUtils.NormalizeXML(col.GetDefaultOrEmptyConfigString()); } else { txtConfig.Text = XmlFormattingUtils.NormalizeXML(editingCollectorEntry.Collector.AgentConfig.ToConfig()); } } catch (Exception ex) { MessageBox.Show(string.Format("Error getting new/existing configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } ShowManualConfig(); }
private void ShowEdit() { System.Threading.ThreadPool.QueueUserWorkItem(delegate { this.Invoke((MethodInvoker) delegate { if (tvwMonPack.SelectedNode != null) { TreeNode currentNode = tvwMonPack.SelectedNode; if (currentNode.Tag != null && currentNode.Tag is CollectorEntry) { CollectorEntry ce = (CollectorEntry)currentNode.Tag; EditCollectorEntry editCollectorEntry = new EditCollectorEntry(); string oldParent = ce.ParentCollectorId; editCollectorEntry.SelectedEntry = ce; if (editCollectorEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { ce = editCollectorEntry.SelectedEntry; string uniqueId = ce.UniqueId; RefreshMonitorPack(); TreeNode collectorRootNode = (from TreeNode n in tvwMonPack.Nodes[0].Nodes where n.Name == "Collectors" select n).First(); SelectCollectorNodeById(uniqueId, collectorRootNode); } } else if (currentNode.Tag != null && currentNode.Tag is NotifierEntry) { NotifierEntry ne = (NotifierEntry)currentNode.Tag;; EditNotifierEntry editNotifierEntry = new EditNotifierEntry(); editNotifierEntry.SelectedEntry = ne; if (editNotifierEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { RefreshMonitorPack(); } } } }); }); }
private void enableToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode currentNode = tvwMonPack.SelectedNode; if (currentNode.Tag != null) { if (currentNode.Tag is CollectorEntry) { CollectorEntry ce = (CollectorEntry)currentNode.Tag; ce.Enabled = !ce.Enabled; currentNode.Tag = ce; enableToolStripMenuItem.Text = ce.Enabled ? "Disable" : "Enable"; if (!ce.Enabled) { currentNode.ForeColor = Color.Gray; } else { currentNode.ForeColor = SystemColors.WindowText; } } else if (currentNode.Tag is NotifierEntry) { NotifierEntry ne = (NotifierEntry)currentNode.Tag; ne.Enabled = !ne.Enabled; currentNode.Tag = ne; enableToolStripMenuItem.Text = ne.Enabled ? "Disable" : "Enable"; if (!ne.Enabled) { currentNode.ForeColor = Color.Gray; } else { currentNode.ForeColor = SystemColors.WindowText; } } } }
public abstract void RecordMessage(AlertLevel alertLevel, CollectorEntry collectorEntry);
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()); } }
public DialogResult ShowDialog(MonitorPack monitorPack) { if (KnownRemoteHosts == null) { KnownRemoteHosts = new List <string>(); } if (SelectedEntry == null) { return(System.Windows.Forms.DialogResult.Cancel); } else { this.monitorPack = monitorPack; currentEditingEntry = CollectorEntry.FromConfig(SelectedEntry.ToConfig()); try { //Create Collector instance but do not apply Config Variables! currentEditingEntry.CreateAndConfigureEntry(currentEditingEntry.CollectorRegistrationName, "", false, false); ApplyConfigToControls(); txtName.Text = currentEditingEntry.Name; chkEnabled.Checked = currentEditingEntry.Enabled; chkExpandOnStart.Checked = currentEditingEntry.ExpandOnStart; lblId.Text = currentEditingEntry.UniqueId; llblCollectorType.Text = currentEditingEntry.CollectorRegistrationDisplayName; chkRemoteAgentEnabled.Checked = currentEditingEntry.EnableRemoteExecute; chkForceRemoteExcuteOnChildCollectors.Checked = currentEditingEntry.ForceRemoteExcuteOnChildCollectors; txtRemoteAgentServer.Text = currentEditingEntry.RemoteAgentHostAddress; remoteportNumericUpDown.SaveValueSet(currentEditingEntry.RemoteAgentHostPort); chkBlockParentRHOverride.Checked = currentEditingEntry.BlockParentOverrideRemoteAgentHostSettings; chkRunLocalOnRemoteHostConnectionFailure.Checked = currentEditingEntry.RunLocalOnRemoteHostConnectionFailure; try { chkEnablePollingOverride.Checked = currentEditingEntry.EnabledPollingOverride; onlyAllowUpdateOncePerXSecNumericUpDown.SaveValueSet(currentEditingEntry.OnlyAllowUpdateOncePerXSec); chkEnablePollingFrequencySliding.Checked = currentEditingEntry.EnablePollFrequencySliding; pollSlideFrequencyAfterThirdRepeatSecNumericUpDown.SaveValueSet(currentEditingEntry.PollSlideFrequencyAfterThirdRepeatSec); pollSlideFrequencyAfterSecondRepeatSecNumericUpDown.SaveValueSet(currentEditingEntry.PollSlideFrequencyAfterSecondRepeatSec); pollSlideFrequencyAfterFirstRepeatSecNumericUpDown.SaveValueSet(currentEditingEntry.PollSlideFrequencyAfterFirstRepeatSec); } catch { } PollingOverrideControlsEnable(); numericUpDownRepeatAlertInXMin.SaveValueSet(currentEditingEntry.RepeatAlertInXMin); numericUpDownRepeatAlertInXPolls.SaveValueSet(currentEditingEntry.RepeatAlertInXPolls); AlertOnceInXMinNumericUpDown.SaveValueSet(currentEditingEntry.AlertOnceInXMin); AlertOnceInXPollsNumericUpDown.SaveValueSet(currentEditingEntry.AlertOnceInXPolls); delayAlertSecNumericUpDown.SaveValueSet(currentEditingEntry.DelayErrWarnAlertForXSec); delayAlertPollsNumericUpDown.SaveValueSet(currentEditingEntry.DelayErrWarnAlertForXPolls); chkCollectOnParentWarning.Checked = currentEditingEntry.CollectOnParentWarning; chkAlertsPaused.Checked = currentEditingEntry.AlertsPaused; chkCorrectiveScriptDisabled.Checked = currentEditingEntry.CorrectiveScriptDisabled; txtCorrectiveScriptOnWarning.Text = currentEditingEntry.CorrectiveScriptOnWarningPath; txtCorrectiveScriptOnError.Text = currentEditingEntry.CorrectiveScriptOnErrorPath; txtRestorationScript.Text = currentEditingEntry.RestorationScriptPath; chkOnlyRunCorrectiveScriptsOnStateChange.Checked = currentEditingEntry.CorrectiveScriptsOnlyOnStateChange; linkLabelServiceWindows.Text = currentEditingEntry.ServiceWindows.ToString(); LoadParentCollectorList(); CheckOkEnabled(); return(ShowDialog()); } catch (Exception ex) { MessageBox.Show(ex.Message, "Loading", MessageBoxButtons.OK, MessageBoxIcon.Error); return(System.Windows.Forms.DialogResult.Cancel); } } }
private void cmdOK_Click(object sender, EventArgs e) { if (SelectedEntry == null) { SelectedEntry = new CollectorEntry(); } SelectedEntry.Name = txtName.Text; SelectedEntry.Enabled = chkEnabled.Checked; SelectedEntry.ExpandOnStart = chkExpandOnStart.Checked; SelectedEntry.IsFolder = currentEditingEntry.IsFolder; if (cboParentCollector.SelectedIndex > 0) { CollectorEntryDisplay ced = (CollectorEntryDisplay)cboParentCollector.SelectedItem; SelectedEntry.ParentCollectorId = ced.CE.UniqueId; } else { SelectedEntry.ParentCollectorId = ""; } SelectedEntry.CollectOnParentWarning = chkCollectOnParentWarning.Checked && !SelectedEntry.IsFolder; //Collector type SelectedEntry.CollectorRegistrationName = currentEditingEntry.CollectorRegistrationName; SelectedEntry.CollectorRegistrationDisplayName = currentEditingEntry.CollectorRegistrationDisplayName; //Remote agents SelectedEntry.EnableRemoteExecute = chkRemoteAgentEnabled.Checked; SelectedEntry.ForceRemoteExcuteOnChildCollectors = chkForceRemoteExcuteOnChildCollectors.Checked; SelectedEntry.RemoteAgentHostAddress = txtRemoteAgentServer.Text; SelectedEntry.RemoteAgentHostPort = (int)remoteportNumericUpDown.Value; SelectedEntry.BlockParentOverrideRemoteAgentHostSettings = chkBlockParentRHOverride.Checked && !chkRemoteAgentEnabled.Checked; SelectedEntry.RunLocalOnRemoteHostConnectionFailure = chkRunLocalOnRemoteHostConnectionFailure.Checked; if (chkRemoteAgentEnabled.Checked && SelectedEntry.RemoteAgentHostAddress.Length > 0) { if (KnownRemoteHosts == null) { KnownRemoteHosts = new List <string>(); } if ((from string rh in KnownRemoteHosts where rh.ToLower() == SelectedEntry.RemoteAgentHostAddress.ToLower() + ":" + SelectedEntry.RemoteAgentHostPort.ToString() select rh).Count() == 0 ) { KnownRemoteHosts.Add(SelectedEntry.RemoteAgentHostAddress + ":" + SelectedEntry.RemoteAgentHostPort.ToString()); } } //Polling overrides if (onlyAllowUpdateOncePerXSecNumericUpDown.Value >= pollSlideFrequencyAfterFirstRepeatSecNumericUpDown.Value) { pollSlideFrequencyAfterFirstRepeatSecNumericUpDown.Value = onlyAllowUpdateOncePerXSecNumericUpDown.Value + 1; } if (pollSlideFrequencyAfterFirstRepeatSecNumericUpDown.Value >= pollSlideFrequencyAfterSecondRepeatSecNumericUpDown.Value) { pollSlideFrequencyAfterSecondRepeatSecNumericUpDown.Value = pollSlideFrequencyAfterFirstRepeatSecNumericUpDown.Value + 1; } if (pollSlideFrequencyAfterSecondRepeatSecNumericUpDown.Value >= pollSlideFrequencyAfterThirdRepeatSecNumericUpDown.Value) { pollSlideFrequencyAfterThirdRepeatSecNumericUpDown.Value = pollSlideFrequencyAfterSecondRepeatSecNumericUpDown.Value + 1; } SelectedEntry.EnabledPollingOverride = chkEnablePollingOverride.Checked; SelectedEntry.OnlyAllowUpdateOncePerXSec = (int)onlyAllowUpdateOncePerXSecNumericUpDown.Value; SelectedEntry.EnablePollFrequencySliding = chkEnablePollingFrequencySliding.Checked; SelectedEntry.PollSlideFrequencyAfterFirstRepeatSec = (int)pollSlideFrequencyAfterFirstRepeatSecNumericUpDown.Value; SelectedEntry.PollSlideFrequencyAfterSecondRepeatSec = (int)pollSlideFrequencyAfterSecondRepeatSecNumericUpDown.Value; SelectedEntry.PollSlideFrequencyAfterThirdRepeatSec = (int)pollSlideFrequencyAfterThirdRepeatSecNumericUpDown.Value; //Alert suppresion SelectedEntry.AlertsPaused = chkAlertsPaused.Checked; SelectedEntry.RepeatAlertInXMin = (int)numericUpDownRepeatAlertInXMin.Value; SelectedEntry.RepeatAlertInXPolls = (int)numericUpDownRepeatAlertInXPolls.Value; SelectedEntry.AlertOnceInXMin = (int)AlertOnceInXMinNumericUpDown.Value; SelectedEntry.AlertOnceInXPolls = (int)AlertOnceInXPollsNumericUpDown.Value; SelectedEntry.DelayErrWarnAlertForXSec = (int)delayAlertSecNumericUpDown.Value; SelectedEntry.DelayErrWarnAlertForXPolls = (int)delayAlertPollsNumericUpDown.Value; //Corrective scripts SelectedEntry.CorrectiveScriptDisabled = chkCorrectiveScriptDisabled.Checked; SelectedEntry.CorrectiveScriptOnWarningPath = txtCorrectiveScriptOnWarning.Text; SelectedEntry.CorrectiveScriptOnErrorPath = txtCorrectiveScriptOnError.Text; SelectedEntry.RestorationScriptPath = txtRestorationScript.Text; SelectedEntry.CorrectiveScriptsOnlyOnStateChange = chkOnlyRunCorrectiveScriptsOnStateChange.Checked; //Service windows SelectedEntry.ServiceWindows.CreateFromConfig(currentEditingEntry.ServiceWindows.ToConfig()); SelectedEntry.ConfigVariables = new List <ConfigVariable>(); SelectedEntry.ConfigVariables.AddRange((from ConfigVariable cv in currentEditingEntry.ConfigVariables select cv.Clone()).ToArray()); if (SelectedEntry.IsFolder) { SelectedEntry.Collector = null; } else { SelectedEntry.InitialConfiguration = currentEditingEntry.InitialConfiguration; RegisteredAgent currentRA = null; currentRA = RegisteredAgentCache.GetRegisteredAgentByClassName("." + SelectedEntry.CollectorRegistrationName); if (currentRA != null) { try { SelectedEntry.CreateAndConfigureEntry(currentRA, monitorPack.ConfigVariables); } catch (Exception ex) { SelectedEntry.LastMonitorState.State = CollectorState.ConfigurationError; SelectedEntry.Enabled = false; SelectedEntry.LastMonitorState.RawDetails = ex.Message; } } else { SelectedEntry.LastMonitorState.State = CollectorState.ConfigurationError; SelectedEntry.Enabled = false; SelectedEntry.LastMonitorState.RawDetails = string.Format("Collector '{0}' cannot be loaded as the type '{1}' is not registered!", SelectedEntry.Name, SelectedEntry.CollectorRegistrationName); } } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }