private void LoadEntryDetails() { SSHCommandCollectorConfigEntry currentEntry; if (SelectedEntry != null) { currentEntry = (SSHCommandCollectorConfigEntry)SelectedEntry; sshConnectionDetails = currentEntry.SSHConnection; txtSSHConnection.Text = SSHConnectionDetails.FormatSSHConnection(sshConnectionDetails); txtName.Text = currentEntry.Name; txtCommandText.Text = currentEntry.CommandString; cboReturnType.SelectedIndex = (int)currentEntry.ValueReturnType; cboReturnCheckSequence.SelectedIndex = (int)currentEntry.ReturnCheckSequence; txtSuccess.Text = currentEntry.GoodValue; cboSuccessMatchType.SelectedIndex = (int)currentEntry.GoodResultMatchType; if (currentEntry.WarningValue != null && currentEntry.WarningValue.Length > 0) { txtWarning.Text = currentEntry.WarningValue; } cboWarningMatchType.SelectedIndex = (int)currentEntry.WarningResultMatchType; if (currentEntry.ErrorValue != null && currentEntry.ErrorValue.Length > 0) { txtError.Text = currentEntry.ErrorValue; } cboErrorMatchType.SelectedIndex = (int)currentEntry.ErrorResultMatchType; cboOutputValueUnit.Text = currentEntry.OutputValueUnit; } else { currentEntry = new SSHCommandCollectorConfigEntry(); } }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement pcNode in root.SelectNodes("nixDiskSpaces")) { NIXDiskSpaceEntry entry = new NIXDiskSpaceEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); entry.SubItems = new List <ICollectorConfigSubEntry>(); foreach (XmlElement fileSystemNode in pcNode.SelectNodes("fileSystem")) { NIXDiskSpaceSubEntry fse = new NIXDiskSpaceSubEntry(); fse.FileSystemName = fileSystemNode.ReadXmlElementAttr("name", ""); fse.WarningValue = fileSystemNode.ReadXmlElementAttr("warningValue", 10.0d); fse.ErrorValue = fileSystemNode.ReadXmlElementAttr("errorValue", 5.0d); fse.PrimaryUIValue = fileSystemNode.ReadXmlElementAttr("primaryUIValue", false); entry.SubItems.Add(fse); } Entries.Add(entry); } }
private void cmdSetFromFile_Click(object sender, EventArgs e) { string connectionFile = ApplyConfigVarsOnField(txtConnectionString.Text); SSHConnectionDetails = SSHConnectionDetails.FromConnectionString(connectionFile); LoadEntryDetails(); }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement pcNode in root.SelectNodes("linux/memory")) { LinuxMemoryEntry entry = new LinuxMemoryEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); //entry.SSHConnection.SSHSecurityOption = SSHSecurityOptionTypeConverter.FromString(pcNode.ReadXmlElementAttr("sshSecOpt", "password")); //entry.SSHConnection.ComputerName = pcNode.ReadXmlElementAttr("machine", "."); //entry.SSHConnection.SSHPort = pcNode.ReadXmlElementAttr("sshPort", 22); //entry.SSHConnection.UserName = pcNode.ReadXmlElementAttr("userName", ""); //entry.SSHConnection.Password = pcNode.ReadXmlElementAttr("password", ""); //entry.SSHConnection.PrivateKeyFile = pcNode.ReadXmlElementAttr("privateKeyFile", ""); //entry.SSHConnection.PassPhrase = pcNode.ReadXmlElementAttr("passPhrase", ""); entry.LinuxMemoryType = LinuxMemoryTypeTypeConverter.FromString(pcNode.ReadXmlElementAttr("memoryType", "MemAvailable")); entry.WarningValue = float.Parse(pcNode.ReadXmlElementAttr("warningValue", "20")); entry.ErrorValue = float.Parse(pcNode.ReadXmlElementAttr("errorValue", "10")); Entries.Add(entry); } }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement pcNode in root.SelectNodes("nixNICs")) { NIXNICEntry entry = new NIXNICEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); entry.SubItems = new List <ICollectorConfigSubEntry>(); entry.MeasuringDelayMS = pcNode.ReadXmlElementAttr("measuringDelayMS", 250); foreach (XmlElement nicNode in pcNode.SelectNodes("nic")) { NIXNICSubEntry fse = new NIXNICSubEntry(); fse.NICName = nicNode.ReadXmlElementAttr("name", ""); fse.WarningValueKB = nicNode.ReadXmlElementAttr("warningValueKB", 1024); fse.ErrorValueKB = nicNode.ReadXmlElementAttr("errorValueKB", 5120); fse.PrimaryUIValue = nicNode.ReadXmlElementAttr("primaryUIValue", false); entry.SubItems.Add(fse); } Entries.Add(entry); } }
private void txtConnectionString_Leave(object sender, EventArgs e) { if (txtMachineName.Text.Length == 0 && System.IO.File.Exists(txtConnectionString.Text)) { SSHConnectionDetails = SSHConnectionDetails.FromConnectionString(txtConnectionString.Text); LoadEntryDetails(); } }
public SSHBaseConfigEntry() { SSHConnection = new SSHConnectionDetails() { SSHSecurityOption = SSHSecurityOption.Password, SSHPort = 22 }; SubItems = new List <ICollectorConfigSubEntry>(); }
private void lblAutoAdd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { SSHConnectionDetails sshConnection = sshConnectionDetails.Clone(); sshConnection.ComputerName = ApplyConfigVarsOnField(sshConnection.ComputerName); sshConnection.UserName = ApplyConfigVarsOnField(sshConnection.UserName); sshConnection.Password = ApplyConfigVarsOnField(sshConnection.Password); sshConnection.PrivateKeyFile = ApplyConfigVarsOnField(sshConnection.PrivateKeyFile); sshConnection.PassPhrase = ApplyConfigVarsOnField(sshConnection.PassPhrase); sshConnection.ConnectionName = ApplyConfigVarsOnField(sshConnection.ConnectionName); sshConnection.ConnectionString = ApplyConfigVarsOnField(sshConnection.ConnectionString); if (lvwNICs.Items.Count > 0 && (MessageBox.Show("Clear all existing entries?", "Clear", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)) { return; } else { lvwNICs.Items.Clear(); lvwNICs.Items.Add(new ListViewItem("Querying " + sshConnection.ComputerName + "...")); Application.DoEvents(); } Renci.SshNet.SshClient sshClient = SshClientTools.GetSSHConnection(sshConnection); if (sshClient.IsConnected) { lvwNICs.Items.Clear(); foreach (NicInfo di in NicInfo.GetCurrentNicStats(sshClient)) { NIXNICSubEntry dsse = new NIXNICSubEntry() { NICName = di.Name, WarningValueKB = (long)warningNumericUpDown.Value, ErrorValueKB = (long)errorNumericUpDown.Value }; ListViewItem lvi = new ListViewItem() { Text = dsse.NICName }; lvi.SubItems.Add(dsse.WarningValueKB.ToString()); lvi.SubItems.Add(dsse.ErrorValueKB.ToString()); lvi.Tag = dsse; lvwNICs.Items.Add(lvi); } } else { lvwNICs.Items.Clear(); MessageBox.Show("Could not connect to computer!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void EditSSHConnection() { EditSSHConnection editor = new Collectors.EditSSHConnection(); editor.SSHConnectionDetails = sshConnectionDetails; if (editor.ShowDialog() == System.Windows.Forms.DialogResult.OK) { sshConnectionDetails = editor.SSHConnectionDetails; txtSSHConnection.Text = SSHConnectionDetails.FormatSSHConnection(sshConnectionDetails); } }
private void cmdTest_Click(object sender, EventArgs e) { try { string commandText = ApplyConfigVarsOnField(txtCommandText.Text); string successText = ApplyConfigVarsOnField(txtSuccess.Text); string warningText = ApplyConfigVarsOnField(txtWarning.Text); string errorText = ApplyConfigVarsOnField(txtError.Text); string connectionString = ApplyConfigVarsOnField(sshConnectionDetails.ConnectionString); SSHConnectionDetails sshConnection; if (connectionString.Length > 0) { sshConnection = SSHConnectionDetails.FromConnectionString(connectionString); } else { sshConnection = sshConnectionDetails.Clone(); sshConnection.ComputerName = ApplyConfigVarsOnField(sshConnection.ComputerName); sshConnection.UserName = ApplyConfigVarsOnField(sshConnection.UserName); sshConnection.Password = ApplyConfigVarsOnField(sshConnection.Password); sshConnection.PrivateKeyFile = ApplyConfigVarsOnField(sshConnection.PrivateKeyFile); sshConnection.PassPhrase = ApplyConfigVarsOnField(sshConnection.PassPhrase); sshConnection.ConnectionName = ApplyConfigVarsOnField(sshConnection.ConnectionName); } SSHCommandCollectorConfigEntry testEntry = new SSHCommandCollectorConfigEntry() { SSHConnection = sshConnection }; testEntry.CommandString = commandText; testEntry.ValueReturnType = (SSHCommandValueReturnType)cboReturnType.SelectedIndex; testEntry.ReturnCheckSequence = (CollectorAgentReturnValueCheckSequence)cboReturnCheckSequence.SelectedIndex; testEntry.GoodResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboSuccessMatchType.SelectedIndex; testEntry.GoodValue = successText; testEntry.WarningResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboWarningMatchType.SelectedIndex; testEntry.WarningValue = warningText; testEntry.ErrorResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboErrorMatchType.SelectedIndex; testEntry.ErrorValue = errorText; testEntry.OutputValueUnit = cboOutputValueUnit.Text; string value = testEntry.ExecuteCommand(); CollectorState currentState = CollectorAgentReturnValueCompareEngine.GetState(testEntry.ReturnCheckSequence, testEntry.GoodResultMatchType, testEntry.GoodValue, testEntry.WarningResultMatchType, testEntry.WarningValue, testEntry.ErrorResultMatchType, testEntry.ErrorValue, value); MessageBox.Show(string.Format("Returned state: {0}\r\nOutput: {1}", currentState, value), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void EditSSHConnection() { EditSSHConnection editor = new Collectors.EditSSHConnection(); editor.SSHConnectionDetails = sshConnectionDetails; editor.ConfigVariables = ConfigVariables; if (editor.ShowDialog() == DialogResult.OK) { sshConnectionDetails = editor.SSHConnectionDetails; txtSSHConnection.Text = SSHConnectionDetails.FormatSSHConnection(sshConnectionDetails); } }
private void cmdOpenConnectionStringFile_Click(object sender, EventArgs e) { if (txtConnectionString.Text.Trim().Length > 0) { connectionStringFileOpenFileDialog.FileName = txtConnectionString.Text; connectionStringFileOpenFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(txtConnectionString.Text); } if (connectionStringFileOpenFileDialog.ShowDialog() == DialogResult.OK) { SSHConnectionDetails = SSHConnectionDetails.FromConnectionString(connectionStringFileOpenFileDialog.FileName); LoadEntryDetails(); } }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement cmndNode in root.SelectNodes("linux/sshCommand")) { LinuxSSHCommandEntry entry = new LinuxSSHCommandEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(cmndNode); //entry.SSHConnection.SSHSecurityOption = SSHSecurityOptionTypeConverter.FromString(cmndNode.ReadXmlElementAttr("sshSecOpt", "password")); //entry.SSHConnection.ComputerName = cmndNode.ReadXmlElementAttr("machine", "."); //entry.SSHConnection.SSHPort = cmndNode.ReadXmlElementAttr("sshPort", 22); //entry.SSHConnection.UserName = cmndNode.ReadXmlElementAttr("userName", ""); //entry.SSHConnection.Password = cmndNode.ReadXmlElementAttr("password", ""); //entry.SSHConnection.PrivateKeyFile = cmndNode.ReadXmlElementAttr("privateKeyFile", ""); //entry.SSHConnection.PassPhrase = cmndNode.ReadXmlElementAttr("passPhrase", ""); //entry.SSHConnection.Persistent = cmndNode.ReadXmlElementAttr("persistent", false); entry.Name = cmndNode.ReadXmlElementAttr("name", ""); XmlNode commandStringNode = cmndNode.SelectSingleNode("commandString"); entry.CommandString = cmndNode.InnerText; XmlNode alertTriggersNode = cmndNode.SelectSingleNode("alertTriggers"); entry.ValueReturnType = SSHCommandValueReturnTypeConverter.FromString(alertTriggersNode.ReadXmlElementAttr("valueReturnType", "RawValue")); entry.ValueReturnCheckSequence = CollectorAgentReturnValueCompareEngine.CheckSequenceTypeFromString(alertTriggersNode.ReadXmlElementAttr("checkSequence", "EWG")); XmlNode successNode = alertTriggersNode.SelectSingleNode("success"); entry.SuccessMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(successNode.ReadXmlElementAttr("matchType", "Match")); entry.SuccessValueOrMacro = successNode.ReadXmlElementAttr("value", "[any]"); XmlNode warningNode = alertTriggersNode.SelectSingleNode("warning"); entry.WarningMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(warningNode.ReadXmlElementAttr("matchType", "Match")); entry.WarningValueOrMacro = warningNode.ReadXmlElementAttr("value", "0"); XmlNode errorNode = alertTriggersNode.SelectSingleNode("error"); entry.ErrorMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(errorNode.ReadXmlElementAttr("matchType", "Match")); entry.ErrorValueOrMacro = errorNode.ReadXmlElementAttr("value", "[null]"); Entries.Add(entry); } }
private void LoadEntryDetails() { NixMemoryEntry currentEntry = (NixMemoryEntry)SelectedEntry; if (currentEntry == null) { currentEntry = new NixMemoryEntry(); } sshConnectionDetails = currentEntry.SSHConnection; txtSSHConnection.Text = SSHConnectionDetails.FormatSSHConnection(sshConnectionDetails); cboLinuxMemoryType.SelectedIndex = (int)currentEntry.MemoryType; warningNumericUpDown.SaveValueSet((decimal)currentEntry.WarningValue); errorNumericUpDown.SaveValueSet((decimal)currentEntry.ErrorValue); }
private void txtConnectionString_Leave(object sender, EventArgs e) { try { if (txtMachineName.Text.Length == 0 && System.IO.File.Exists(txtConnectionString.Text)) { SSHConnectionDetails = SSHConnectionDetails.FromConnectionString(txtConnectionString.Text); LoadEntryDetails(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement procNode in root.SelectNodes("linuxProcess")) { LinuxProcessEntry entry = new LinuxProcessEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(procNode); //entry.SSHConnection.SSHSecurityOption = SSHSecurityOptionTypeConverter.FromString(procNode.ReadXmlElementAttr("sshSecOpt", "password")); //entry.SSHConnection.ComputerName = procNode.ReadXmlElementAttr("machine", "."); //entry.SSHConnection.SSHPort = procNode.ReadXmlElementAttr("sshPort", 22); //entry.SSHConnection.UserName = procNode.ReadXmlElementAttr("userName", ""); //entry.SSHConnection.Password = procNode.ReadXmlElementAttr("password", ""); //entry.SSHConnection.PrivateKeyFile = procNode.ReadXmlElementAttr("privateKeyFile", ""); //entry.SSHConnection.PassPhrase = procNode.ReadXmlElementAttr("passPhrase", ""); entry.Name = procNode.ReadXmlElementAttr("name", ""); entry.ProcessCheckOption = ProcessCheckOptionTypeConverter.FromString(procNode.ReadXmlElementAttr("processCheckOption", "")); entry.TopProcessCount = procNode.ReadXmlElementAttr("topProcessCount", 10); entry.CPUPercWarningValue = procNode.ReadXmlElementAttr("cpuPercWarningValue", 80); entry.CPUPercErrorValue = procNode.ReadXmlElementAttr("cpuPercErrorValue", 90); entry.MemPercWarningValue = procNode.ReadXmlElementAttr("memPercWarningValue", 80); entry.MemPercErrorValue = procNode.ReadXmlElementAttr("memPercErrorValue", 90); entry.SubItems = new List <ICollectorConfigSubEntry>(); foreach (XmlElement fileSystemNode in procNode.SelectNodes("specificEntry")) { LinuxProcessSubEntry fse = new LinuxProcessSubEntry(); fse.ProcessName = fileSystemNode.ReadXmlElementAttr("name", ""); fse.CPUPercWarningValue = fileSystemNode.ReadXmlElementAttr("cpuPercWarningValue", 80); fse.CPUPercErrorValue = fileSystemNode.ReadXmlElementAttr("cpuPercErrorValue", 90); fse.MemPercWarningValue = fileSystemNode.ReadXmlElementAttr("memPercWarningValue", 80); fse.MemPercErrorValue = fileSystemNode.ReadXmlElementAttr("memPercErrorValue", 90); entry.SubItems.Add(fse); } Entries.Add(entry); } }
private void LoadEntryDetails() { NixCPUEntry currentEntry = (NixCPUEntry)SelectedEntry; if (currentEntry == null) { currentEntry = new NixCPUEntry(); } sshConnectionDetails = currentEntry.SSHConnection; txtSSHConnection.Text = SSHConnectionDetails.FormatSSHConnection(sshConnectionDetails); chkUseOnlyTotalCPUvalue.Checked = currentEntry.UseOnlyTotalCPUvalue; nudMSSampleDelay.SaveValueSet(currentEntry.MSSampleDelay); warningNumericUpDown.SaveValueSet((decimal)currentEntry.WarningValue); errorNumericUpDown.SaveValueSet((decimal)currentEntry.ErrorValue); }
private void txtConnectionString_Leave(object sender, EventArgs e) { try { string connectionFile = ApplyConfigVarsOnField(txtConnectionString.Text); if (connectionFile.Length == 0 && System.IO.File.Exists(connectionFile)) { SSHConnectionDetails = SSHConnectionDetails.FromConnectionString(connectionFile); LoadEntryDetails(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public void FromXml(string configurationString) { XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); Entries.Clear(); XmlElement root = config.DocumentElement; //version 5 config foreach (XmlElement carvceEntryNode in root.SelectNodes("carvcesEntries/carvceEntry")) { XmlNode dataSourceNode = carvceEntryNode.SelectSingleNode("dataSource"); SSHCommandCollectorConfigEntry sshEntry = new SSHCommandCollectorConfigEntry(); sshEntry.Name = dataSourceNode.ReadXmlElementAttr("name", ""); sshEntry.PrimaryUIValue = dataSourceNode.ReadXmlElementAttr("primaryUIValue", false); sshEntry.OutputValueUnit = dataSourceNode.ReadXmlElementAttr("outputValueUnit", ""); sshEntry.SSHConnection = SSHConnectionDetails.FromXmlElement((XmlElement)dataSourceNode); XmlNode stateQueryNode = dataSourceNode.SelectSingleNode("stateQuery"); sshEntry.ValueReturnType = SSHCommandValueReturnTypeConverter.FromString(stateQueryNode.ReadXmlElementAttr("valueReturnType", "RawValue")); sshEntry.CommandString = stateQueryNode.InnerText; XmlNode testConditionsNode = carvceEntryNode.SelectSingleNode("testConditions"); if (testConditionsNode != null) { sshEntry.ReturnCheckSequence = CollectorAgentReturnValueCompareEngine.CheckSequenceTypeFromString(testConditionsNode.ReadXmlElementAttr("testSequence", "gwe")); XmlNode goodScriptNode = testConditionsNode.SelectSingleNode("success"); sshEntry.GoodResultMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(goodScriptNode.ReadXmlElementAttr("testType", "match")); sshEntry.GoodValue = goodScriptNode.InnerText; XmlNode warningScriptNode = testConditionsNode.SelectSingleNode("warning"); sshEntry.WarningResultMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(warningScriptNode.ReadXmlElementAttr("testType", "match")); sshEntry.WarningValue = warningScriptNode.InnerText; XmlNode errorScriptNode = testConditionsNode.SelectSingleNode("error"); sshEntry.ErrorResultMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(errorScriptNode.ReadXmlElementAttr("testType", "match")); sshEntry.ErrorValue = errorScriptNode.InnerText; } else { sshEntry.ReturnCheckSequence = CollectorAgentReturnValueCheckSequence.GWE; } Entries.Add(sshEntry); } }
private void cmdOK_Click(object sender, EventArgs e) { SSHConnectionDetails.ComputerName = txtMachineName.Text; SSHConnectionDetails.SSHPort = (int)sshPortNumericUpDown.Value; SSHConnectionDetails.SSHSecurityOption = optPrivateKey.Checked ? SSHSecurityOption.PrivateKey : optPassword.Checked ? SSHSecurityOption.Password : SSHSecurityOption.KeyboardInteractive; SSHConnectionDetails.UserName = txtUsername.Text; SSHConnectionDetails.Password = txtPassword.Text; SSHConnectionDetails.PrivateKeyFile = txtPrivateKeyFile.Text; SSHConnectionDetails.PassPhrase = txtPassPhrase.Text; SSHConnectionDetails.Persistent = chkPersistent.Checked; SSHConnectionDetails.ConnectionString = ""; SSHConnectionDetails.ConnectionString = SSHConnectionDetails.FormatSSHConnection(SSHConnectionDetails); if (txtConnectionString.Text.Trim().Length > 0) { if (changed) { try { DialogResult overwriteChoice = DialogResult.Yes; if (System.IO.File.Exists(txtConnectionString.Text)) { overwriteChoice = MessageBox.Show("Overwrite the connection file?", "Connection file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (overwriteChoice == DialogResult.Cancel) { return; } } if (overwriteChoice == DialogResult.Yes) { System.IO.File.WriteAllText(txtConnectionString.Text, SSHConnectionDetails.ConnectionString); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Saving connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } SSHConnectionDetails.ConnectionString = txtConnectionString.Text; } DialogResult = DialogResult.OK; Close(); }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) return; XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement pcNode in root.SelectNodes("nixMems/nixMem")) { NixMemoryEntry entry = new NixMemoryEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); entry.MemoryType = NuxMemoryTypeTypeConverter.FromString(pcNode.ReadXmlElementAttr("memoryType", "MemAvailable")); entry.WarningValue = float.Parse(pcNode.ReadXmlElementAttr("warningValue", "20")); entry.ErrorValue = float.Parse(pcNode.ReadXmlElementAttr("errorValue", "10")); Entries.Add(entry); } }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); /*System.Xml.Linq.XDocument configDoc = System.Xml.Linq.XDocument.Load(configurationString); * foreach(var nixCpu in configDoc.Root.Descendants("nixCpu")){ * nixCpu.Attribute["msSampleDelay"] * } */ foreach (XmlElement pcNode in root.SelectNodes("nixCpus/nixCpu")) { NixCPUEntry entry = new NixCPUEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); entry.MSSampleDelay = pcNode.ReadXmlElementAttr("msSampleDelay", 200); entry.UseOnlyTotalCPUvalue = pcNode.ReadXmlElementAttr("totalCPU", true); entry.WarningValue = float.Parse(pcNode.ReadXmlElementAttr("warningValue", "80")); entry.ErrorValue = float.Parse(pcNode.ReadXmlElementAttr("errorValue", "99")); Entries.Add(entry); } foreach (XmlElement pcNode in root.SelectNodes("nixCpu")) { NixCPUEntry entry = new NixCPUEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); entry.MSSampleDelay = pcNode.ReadXmlElementAttr("msSampleDelay", 200); entry.UseOnlyTotalCPUvalue = pcNode.ReadXmlElementAttr("totalCPU", true); entry.WarningValue = float.Parse(pcNode.ReadXmlElementAttr("warningValue", "80")); entry.ErrorValue = float.Parse(pcNode.ReadXmlElementAttr("errorValue", "99")); Entries.Add(entry); } }
private void LoadEntryDetails() { if (SSHConnectionDetails.ConnectionString != null && !SSHConnectionDetails.ConnectionString.Contains(';')) { txtConnectionString.Text = SSHConnectionDetails.ConnectionString; SSHConnectionDetails = SSHConnectionDetails.FromConnectionString(txtConnectionString.Text); } txtMachineName.Text = SSHConnectionDetails.ComputerName; sshPortNumericUpDown.SaveValueSet(SSHConnectionDetails.SSHPort); optPrivateKey.Checked = SSHConnectionDetails.SSHSecurityOption == SSHSecurityOption.PrivateKey; optKeyboardInteractive.Checked = SSHConnectionDetails.SSHSecurityOption == SSHSecurityOption.KeyboardInteractive; txtUsername.Text = SSHConnectionDetails.UserName; txtPassword.Text = SSHConnectionDetails.Password; txtPrivateKeyFile.Text = SSHConnectionDetails.PrivateKeyFile; txtPassPhrase.Text = SSHConnectionDetails.PassPhrase; chkPersistent.Checked = SSHConnectionDetails.Persistent; changed = false; }
private void LoadEntryDetails() { NIXDiskIOEntry currentEntry = (NIXDiskIOEntry)SelectedEntry; if (currentEntry == null) { currentEntry = new NIXDiskIOEntry(); } sshConnectionDetails = currentEntry.SSHConnection; txtSSHConnection.Text = SSHConnectionDetails.FormatSSHConnection(sshConnectionDetails); foreach (NIXDiskIOSubEntry dsse in currentEntry.SubItems) { ListViewItem lvi = new ListViewItem() { Text = dsse.DiskName }; lvi.SubItems.Add(dsse.WarningValueKB.ToString()); lvi.SubItems.Add(dsse.ErrorValueKB.ToString()); lvi.Tag = dsse; lvwDisks.Items.Add(lvi); } }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement pcNode in root.SelectNodes("linux/diskIO")) { LinuxDiskIOEntry entry = new LinuxDiskIOEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); //entry.SSHConnection.SSHSecurityOption = SSHSecurityOptionTypeConverter.FromString(pcNode.ReadXmlElementAttr("sshSecOpt", "password")); //entry.SSHConnection.ComputerName = pcNode.ReadXmlElementAttr("machine", "."); //entry.SSHConnection.SSHPort = pcNode.ReadXmlElementAttr("sshPort", 22); //entry.SSHConnection.UserName = pcNode.ReadXmlElementAttr("userName", ""); //entry.SSHConnection.Password = pcNode.ReadXmlElementAttr("password", ""); //entry.SSHConnection.PrivateKeyFile = pcNode.ReadXmlElementAttr("privateKeyFile", ""); //entry.SSHConnection.PassPhrase = pcNode.ReadXmlElementAttr("passPhrase", ""); entry.SubItems = new List <ICollectorConfigSubEntry>(); foreach (XmlElement fileSystemNode in pcNode.SelectNodes("disk")) { LinuxDiskIOSubEntry fse = new LinuxDiskIOSubEntry(); fse.Disk = fileSystemNode.ReadXmlElementAttr("name", ""); fse.WarningValue = fileSystemNode.ReadXmlElementAttr("warningValue", 10.0d); fse.ErrorValue = fileSystemNode.ReadXmlElementAttr("errorValue", 5.0d); entry.SubItems.Add(fse); } Entries.Add(entry); } }
public void FromXml(string configurationString) { if (configurationString == null || configurationString.Length == 0) { return; } XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement pcNode in root.SelectNodes("linux/cpu")) { LinuxCPUEntry entry = new LinuxCPUEntry(); entry.SSHConnection = SSHConnectionDetails.FromXmlElement(pcNode); entry.MSSampleDelay = pcNode.ReadXmlElementAttr("msSampleDelay", 200); entry.UseOnlyTotalCPUvalue = pcNode.ReadXmlElementAttr("totalCPU", true); entry.WarningValue = float.Parse(pcNode.ReadXmlElementAttr("warningValue", "80")); entry.ErrorValue = float.Parse(pcNode.ReadXmlElementAttr("errorValue", "99")); Entries.Add(entry); } }