Пример #1
0
 void client_DataChanged(object sender, MonitorClient.DataChangedEventArgs e)
 {
     try
     {
         RedisPerformanceCounter.PCHelper.CheckPCCategory(e.Data);
     }
     catch (Exception ex)
     {
     }
 }
Пример #2
0
        void prepairListBox(MonitorClient.DataChangedEventArgs e)
        {
            bool flushedCombobox = false;

            if (comboBox1.Items.Count == 0)
            {
                foreach (var item in e.Data)
                {
                    comboBox1.Items.Add(item.Key);
                }
                flushedCombobox         = true;
                comboBox1.SelectedIndex = 0;
                listBox1.Items.Clear();
            }

            if (listBox1.Items.Count == 0)
            {
                foreach (var item in e.Data[comboBox1.Text])
                {
                    listBox1.Items.Add(item.Key);
                }
            }
        }
Пример #3
0
        void client_DataChanged(object sender, MonitorClient.DataChangedEventArgs e)
        {
            if (testdata == true)
            {
                //testdata = false;
                try
                {
                    RedisPerformanceCounter.PCHelper.CheckPCCategory(e.Data);
                }
                catch (Exception ex)
                {
                }
            }
            var a = new Action(() =>
            {
                prepairListBox(e);

                //var sv = e.Data["# Stats"]["total_commands_processed"];
                if (comboBox1.SelectedIndex < 0)
                {
                    return;
                }
                if (listBox1.SelectedIndex < 0)
                {
                    return;
                }
                if (!e.Data[comboBox1.Text].ContainsKey(listBox1.Text))
                {
                    return;
                }
                var sv = e.Data[comboBox1.Text][listBox1.Text];

                var arr = sv.Split(SPLITOR2);
                if (arr.Length > 1)
                {
                    //db0:keys=13,expires=13,avg_ttl=158233845
                    var subItems = MonitorClient.InfoClient.GetSubItems(sv);
                    if (chart1.Series.Count == 0)
                    {
                        PrepareChart(subItems.Select(o => o.Key));
                    }
                    for (int i = 0; i < subItems.Count; i++)
                    {
                        var kv = subItems[i];

                        double v;
                        bool isNum = MonitorClient.InfoClient.StringToNumber(kv.Value, out v);
                        var series = chart1.Series[i];
                        if (!isNum)
                        {
                            series.LegendText = kv.Value;
                            return;
                        }
                        series.IsValueShownAsLabel = checkBox1.Checked;
                        ////series.CustomProperties = "LabelStyle=Top";
                        //series.Label = "#VAL";
                        DateTime date = DateTime.Now;
                        series.Points.AddXY(date.ToShortTimeString(), (float)v);
                        while (series.Points.Count > (int)numericUpDown1.Value)
                        {
                            series.Points.RemoveAt(0);
                            chart1.ResetAutoValues();
                        }
                    }
                }
                else
                {
                    if (chart1.Series.Count == 0)
                    {
                        PrepareChart(new string[] { listBox1.Text });
                    }
                    double v;
                    bool isNum = MonitorClient.InfoClient.StringToNumber(sv, out v);
                    var series = chart1.Series[0];
                    if (!isNum)
                    {
                        series.LegendText = sv;
                        return;
                    }
                    series.IsValueShownAsLabel = checkBox1.Checked;
                    //series.ResetIsValueShownAsLabel();
                    //series.CustomProperties = "LabelStyle=Top";
                    //series.Label = "#VAL";
                    //series.Label = null;
                    DateTime date = DateTime.Now;
                    series.Points.AddXY(date.ToShortTimeString(), (float)v);
                    while (series.Points.Count > (int)numericUpDown1.Value)
                    {
                        series.Points.RemoveAt(0);
                        chart1.ResetAutoValues();
                    }
                }
            });

            try
            {
                this.Invoke(a);
            }
            catch
            {
                client.Stop();
            }
        }