示例#1
0
        public List<PerfCounter> loadCounters()
        {
            List<PerfCounter> perfCounters = new List<PerfCounter>();

            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.File.OpenRead(filePath));

                while(!sr.EndOfStream)
                {
                    string counterRow = sr.ReadLine();
                    string[] valuesTable = counterRow.Split(',');

                    bool isAbove = Int32.Parse(valuesTable[5]) == 1 ? true : false;
                    PerfCounter perfCounter = new PerfCounter(valuesTable[0], valuesTable[1], valuesTable[2], Int32.Parse(valuesTable[3]), float.Parse(valuesTable[4]), isAbove);
                    perfCounters.Add(perfCounter);
                }
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                // Nothing to do
            }
            catch (System.IO.FileNotFoundException)
            {
                // Nothing to do
            }

            return perfCounters;
        }
示例#2
0
        public List <PerfCounter> loadCounters()
        {
            List <PerfCounter> perfCounters = new List <PerfCounter>();

            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.File.OpenRead(filePath));

                while (!sr.EndOfStream)
                {
                    string   counterRow  = sr.ReadLine();
                    string[] valuesTable = counterRow.Split(',');

                    bool        isAbove     = Int32.Parse(valuesTable[5]) == 1 ? true : false;
                    PerfCounter perfCounter = new PerfCounter(valuesTable[0], valuesTable[1], valuesTable[2], Int32.Parse(valuesTable[3]), float.Parse(valuesTable[4]), isAbove);
                    perfCounters.Add(perfCounter);
                }
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                // Nothing to do
            }
            catch (System.IO.FileNotFoundException)
            {
                // Nothing to do
            }

            return(perfCounters);
        }
示例#3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            List <string> criticalCounters = new List <string>();

            for (int i = 0; i < counters.Count; i++)
            {
                PerfCounter counter = counters[i];

                if (counter.check() && isSendMode)
                {
                    criticalCounters.Add(counter.getCategory() + "=1");
                }
                else
                {
                    dataGridView1.Rows[i].Cells[3].Value = counter.getLastValue();
                    dataGridView1.Rows[i].Cells[4].Value = counter.getAvg();
                }
            }

            if (criticalCounters.Count > 0)
            {
                sendReportRequest(string.Join(" ", criticalCounters.ToArray()));
                clearCountersValues();
            }
        }
示例#4
0
        private void clearCountersValues()
        {
            for (int i = 0; i < counters.Count; i++)
            {
                PerfCounter counter = counters[i];

                counter.reset();
                dataGridView1.Rows[i].Cells[3].Value = counter.getLastValue();
                dataGridView1.Rows[i].Cells[4].Value = counter.getAvg();
            }
        }
示例#5
0
        private void addCounterBtn_Click(object sender, EventArgs e)
        {
            String  category      = categoryCb.Text.ToString();
            String  instance      = instanceCb.Text.ToString();
            String  name          = nameCb.Text.ToString();
            decimal criticalValue = numericUpDown1.Value;
            decimal sampleAmount  = numericUpDown3.Value;
            bool    isAbove       = isAboveRadio.Checked;

            if (String.IsNullOrEmpty(category) || String.IsNullOrEmpty(name) || criticalValue == 0)
            {
                MessageBox.Show("Proszę wybrać wszystkie wartości");
                return;
            }
            else
            {
                try
                {
                    PerfCounter newCounter = new PerfCounter(category, instance, name, (int)sampleAmount, (float)criticalValue, isAbove);
                    counters.Add(newCounter);
                    categoryCb.Text      = "";
                    instanceCb.Text      = "";
                    nameCb.Text          = "";
                    numericUpDown1.Value = 0;

                    instanceCb.Enabled = false;
                    nameCb.Enabled     = false;

                    addCounterToDataView(newCounter.getName(), newCounter.getQueueSize(), newCounter.getCritivalValue(), isAbove);
                }
                catch (System.InvalidOperationException ex)
                {
                    MessageBox.Show("Nie udało się dodać licznika: " + ex.Message);
                }
            }
        }