private void UpdateFileSystem() { if (txtDisk.Text.Trim().Length > 0 && !fileSystemUpdated) { if (lvwDisks.SelectedItems.Count == 1) { ListViewItem lvi = lvwDisks.SelectedItems[0]; LinuxDiskIOSubEntry dsse = (LinuxDiskIOSubEntry)lvwDisks.SelectedItems[0].Tag; dsse.Disk = txtDisk.Text; dsse.WarningValue = (double)warningNumericUpDown.Value; dsse.ErrorValue = (double)errorNumericUpDown.Value; lvi.Text = txtDisk.Text; lvi.SubItems[1].Text = warningNumericUpDown.Value.ToString(); lvi.SubItems[2].Text = errorNumericUpDown.Value.ToString(); } else { LinuxDiskIOSubEntry dsse = new LinuxDiskIOSubEntry() { Disk = txtDisk.Text, WarningValue = (double)warningNumericUpDown.Value, ErrorValue = (double)errorNumericUpDown.Value }; ListViewItem lvi = new ListViewItem() { Text = dsse.Disk }; lvi.SubItems.Add(dsse.WarningValue.ToString()); lvi.SubItems.Add(dsse.ErrorValue.ToString()); lvi.Tag = dsse; lvwDisks.Items.Add(lvi); lvwDisks.SelectedItems.Clear(); lvi.Selected = true; } } }
public List <DiskIOState> GetDiskInfos() { List <DiskIOState> diskIOEntries = new List <DiskIOState>(); Renci.SshNet.SshClient sshClient = SSHConnection.GetConnection(); //First see if ANY subentry is for all bool addAll = (from LinuxDiskIOSubEntry d in SubItems where d.Disk == "*" select d).Count() > 0; if (addAll) { LinuxDiskIOSubEntry alertDef = (from LinuxDiskIOSubEntry d in SubItems where d.Disk == "*" select d).FirstOrDefault(); foreach (Linux.DiskIOInfo di in DiskIOInfo.GetCurrentDiskStats(sshClient, 250)) { DiskIOState dis = new DiskIOState() { DiskInfo = di, State = CollectorState.NotAvailable, AlertDefinition = alertDef }; diskIOEntries.Add(dis); } } else { foreach (Linux.DiskIOInfo di in DiskIOInfo.GetCurrentDiskStats(sshClient, 250)) { LinuxDiskIOSubEntry alertDef = (from LinuxDiskIOSubEntry d in SubItems where d.Disk.ToLower() == di.Name.ToLower() select d).FirstOrDefault(); if (alertDef != null) { if (!diskIOEntries.Any(f => f.DiskInfo.Name.ToLower() == di.Name.ToLower())) { DiskIOState dis = new DiskIOState() { DiskInfo = di, State = CollectorState.NotAvailable, AlertDefinition = alertDef }; diskIOEntries.Add(dis); } } } } SSHConnection.CloseConnection(); return(diskIOEntries); }
private void lblAutoAdd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { if (lvwDisks.Items.Count > 0 && (MessageBox.Show("Clear all existing entries?", "Clear", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)) { return; } else { lvwDisks.Items.Clear(); lvwDisks.Items.Add(new ListViewItem("Querying " + sshConnectionDetails.ComputerName + "...")); Application.DoEvents(); } Renci.SshNet.SshClient sshClient = QuickMon.Linux.SshClientTools.GetSSHConnection(sshConnectionDetails); if (sshClient.IsConnected) { lvwDisks.Items.Clear(); foreach (Linux.DiskIOInfo di in QuickMon.Linux.DiskIOInfo.GetCurrentDiskStats(sshClient)) { LinuxDiskIOSubEntry dsse = new LinuxDiskIOSubEntry() { Disk = di.Name, WarningValue = (double)warningNumericUpDown.Value, ErrorValue = (double)errorNumericUpDown.Value }; ListViewItem lvi = new ListViewItem() { Text = dsse.Disk }; lvi.SubItems.Add(dsse.WarningValue.ToString()); lvi.SubItems.Add(dsse.ErrorValue.ToString()); lvi.Tag = dsse; lvwDisks.Items.Add(lvi); } } else { lvwDisks.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 lvwFileSystems_SelectedIndexChanged(object sender, EventArgs e) { if (lvwDisks.SelectedItems.Count == 1) { fileSystemUpdated = true; LinuxDiskIOSubEntry dsse = (LinuxDiskIOSubEntry)lvwDisks.SelectedItems[0].Tag; warningNumericUpDown.SaveValueSet((decimal)dsse.WarningValue); errorNumericUpDown.SaveValueSet((decimal)dsse.ErrorValue); txtDisk.Text = dsse.Disk; fileSystemUpdated = false; } else if (lvwDisks.SelectedItems.Count == 0) { fileSystemUpdated = true; txtDisk.Text = ""; fileSystemUpdated = false; } }
private void cmdOK_Click(object sender, EventArgs e) { LinuxDiskIOEntry selectedEntry; if (SelectedEntry == null) { SelectedEntry = new LinuxDiskIOEntry(); } selectedEntry = (LinuxDiskIOEntry)SelectedEntry; selectedEntry.SSHConnection = sshConnectionDetails; selectedEntry.SubItems = new List <ICollectorConfigSubEntry>(); foreach (ListViewItem lvi in lvwDisks.Items) { LinuxDiskIOSubEntry dsse = (LinuxDiskIOSubEntry)lvi.Tag; selectedEntry.SubItems.Add(dsse); } DialogResult = System.Windows.Forms.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("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); } }