Ejemplo n.º 1
0
        private void cmdTest_Click(object sender, EventArgs e)
        {
            LinuxProcessEntry testEntry = new LinuxProcessEntry();

            testEntry.SSHConnection       = sshConnectionDetails;
            testEntry.Name                = txtName.Text;
            testEntry.ProcessCheckOption  = (ProcessCheckOption)cboProcessCheckOption.SelectedIndex;
            testEntry.TopProcessCount     = (int)topProcessCountUpDown.Value;
            testEntry.CPUPercWarningValue = (int)topXCPUPercWarnNumericUpDown.Value;
            testEntry.CPUPercErrorValue   = (int)topXCPUPercErrNumericUpDown.Value;
            testEntry.MemPercWarningValue = (int)topXMemPercWarnNumericUpDown.Value;
            testEntry.MemPercErrorValue   = (int)topXMemPercErrNumericUpDown.Value;
            testEntry.SubItems.Clear();

            foreach (ListViewItem lvi in lvwProcesses.Items)
            {
                LinuxProcessSubEntry dsse = (LinuxProcessSubEntry)lvi.Tag;
                testEntry.SubItems.Add(dsse);
            }

            try
            {
                List <ProcessInfoState> states = testEntry.GetStates();
                MessageBox.Show(string.Format("Test succeeded!\r\nGood: {0}\r\nWarning: {1}\r\nError: {2}",
                                              states.Count <ProcessInfoState>(s => s.State == CollectorState.Good),
                                              states.Count <ProcessInfoState>(s => s.State == CollectorState.Warning),
                                              states.Count <ProcessInfoState>(s => s.State == CollectorState.Error)
                                              )
                                , "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Test failed!\r\n" + ex.Message, "Test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 2
0
        private void LoadEntryDetails()
        {
            LinuxProcessEntry currentEntry = (LinuxProcessEntry)SelectedEntry;

            if (currentEntry == null)
            {
                currentEntry = new LinuxProcessEntry();
            }
            sshConnectionDetails  = currentEntry.SSHConnection;
            txtSSHConnection.Text = Linux.SSHConnectionDetails.FormatSSHConnection(sshConnectionDetails);

            txtName.Text = currentEntry.Name;
            cboProcessCheckOption.SelectedIndex = (int)currentEntry.ProcessCheckOption;
            topProcessCountUpDown.SaveValueSet(currentEntry.TopProcessCount);
            topXCPUPercWarnNumericUpDown.SaveValueSet(currentEntry.CPUPercWarningValue);
            topXCPUPercErrNumericUpDown.SaveValueSet(currentEntry.CPUPercErrorValue);
            topXMemPercWarnNumericUpDown.SaveValueSet(currentEntry.MemPercWarningValue);
            topXMemPercErrNumericUpDown.SaveValueSet(currentEntry.MemPercErrorValue);

            lvwProcesses.Items.Clear();
            if (currentEntry.SubItems != null && currentEntry.SubItems.Count > 0)
            {
                foreach (LinuxProcessSubEntry specific in currentEntry.SubItems)
                {
                    ListViewItem lvi = new ListViewItem(specific.ProcessName);
                    lvi.SubItems.Add(specific.CPUPercWarningValue.ToString());
                    lvi.SubItems.Add(specific.CPUPercErrorValue.ToString());
                    lvi.SubItems.Add(specific.MemPercWarningValue.ToString());
                    lvi.SubItems.Add(specific.MemPercErrorValue.ToString());
                    lvi.Tag = specific;
                    lvwProcesses.Items.Add(lvi);
                }
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }