Exemple #1
0
        /// <summary>
        /// Random Thread
        /// </summary>
        void pool_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "gui_config")
            {
                Dictionary <string, string> gui_config = Helpers.GetGuiConfig((IXenObject)sender);
                string uuid = Helpers.GetUuid(XenObject);

                foreach (string key in gui_config.Keys)
                {
                    if (!Palette.OtherConfigUUIDRegex.IsMatch(key) || !key.Contains(uuid))
                    {
                        continue;
                    }

                    string value = gui_config[key];
                    int    argb;
                    if (!Int32.TryParse(value, out argb))
                    {
                        continue;
                    }

                    string[] strs = key.Split('.');

                    // just set the color, we dont care what it is
                    Palette.SetCustomColor(Palette.GetUuid(strs[strs.Length - 1], XenObject), Color.FromArgb(argb));
                }
                OnArchivesUpdated();
            }
        }
Exemple #2
0
        public static List <DataSourceItem> BuildList(IXenObject xenObject, List <Data_source> dataSources)
        {
            List <DataSourceItem> dataSourceItems = new List <DataSourceItem>();

            foreach (Data_source dataSource in dataSources)
            {
                if (dataSource.name_label == "memory_total_kib" || dataSource.name_label == "memory")
                {
                    continue;
                }

                string friendlyName;
                if (dataSource.name_label == "memory_free_kib" && xenObject is Host)
                {
                    friendlyName = Helpers.GetFriendlyDataSourceName("memory_used_kib", xenObject);
                }
                else if (dataSource.name_label == "memory_internal_free" && xenObject is VM)
                {
                    friendlyName = Helpers.GetFriendlyDataSourceName("memory_internal_used", xenObject);
                }
                else
                {
                    friendlyName = Helpers.GetFriendlyDataSourceName(dataSource.name_label, xenObject);
                }

                string itemUuid = Palette.GetUuid(dataSource.name_label, xenObject);
                dataSourceItems.Add(new DataSourceItem(dataSource, friendlyName, Palette.GetColour(itemUuid), itemUuid, xenObject));
            }

            return(dataSourceItems);
        }
Exemple #3
0
        private static Regex sr_rw_regex            = new Regex("^(read|write)_([a-f0-9]{8})$");               // replacement SR read/write datasources

        public static List <DataSourceItem> BuildList(IXenObject xenObject, List <Data_source> dataSources)
        {
            List <DataSourceItem> dataSourceItems = new List <DataSourceItem>();

            foreach (Data_source dataSource in dataSources)
            {
                if (dataSource.name_label == "memory_total_kib" || dataSource.name_label == "memory" || dataSource.name_label == "xapi_open_fds" || dataSource.name_label == "pool_task_count" || dataSource.name_label == "pool_session_count")
                {
                    continue;
                }

                string friendlyName;
                if (dataSource.name_label == "memory_free_kib" && xenObject is Host)
                {
                    friendlyName = Helpers.GetFriendlyDataSourceName("memory_used_kib", xenObject);
                }
                else if (dataSource.name_label == "memory_internal_free" && xenObject is VM)
                {
                    friendlyName = Helpers.GetFriendlyDataSourceName("memory_internal_used", xenObject);
                }
                else
                {
                    friendlyName = Helpers.GetFriendlyDataSourceName(dataSource.name_label, xenObject);
                }

                string itemUuid = Palette.GetUuid(dataSource.name_label, xenObject);
                dataSourceItems.Add(new DataSourceItem(dataSource, friendlyName, Palette.GetColour(itemUuid), itemUuid, xenObject));
            }

            // Filter old datasources only if we have their replacement ones
            if (dataSourceItems.Any(dsi => sr_rw_regex.IsMatch(dsi.DataSource.name_label)))
            {
                // Remove any old style data sources
                dataSourceItems.RemoveAll(dsi => io_throughput_rw_regex.IsMatch(dsi.DataSource.name_label));
            }

            return(dataSourceItems);
        }
Exemple #4
0
        public void AddPoint(string str, long currentTime, List <DataSet> setsAdded)
        {
            double value           = Helpers.StringToDouble(str);
            bool   isNanOrInfinity = double.IsNaN(value) || double.IsInfinity(value);
            double yValue          = isNanOrInfinity ? NegativeValue : value * MultiplyingFactor;

            #region cpu

            var matchDelegate = new Func <string, bool>(s => Helpers.CpuRegex.IsMatch(s) &&
                                                        !Helpers.CpuStateRegex.IsMatch(s));

            if (matchDelegate(TypeString))
            {
                DataSet other = setsAdded.FirstOrDefault(s => s.TypeString == "avg_cpu");
                if (other == null)
                {
                    other = Create(Palette.GetUuid("avg_cpu", XenObject), XenObject, true, "avg_cpu");
                    setsAdded.Add(other);
                }

                DataPoint pt = other.GetPointAt(currentTime);
                if (pt == null)
                {
                    pt = new DataPoint(currentTime, 0);
                    other.AddPoint(pt);
                }

                if (isNanOrInfinity || pt.Y < 0)
                {
                    pt.Y = NegativeValue;
                }
                else
                {
                    double cpu_vals_added = 0d;

                    foreach (DataSet s in setsAdded)
                    {
                        if (matchDelegate(s.TypeString) && s.GetPointAt(currentTime) != null && s != this)
                        {
                            cpu_vals_added++;
                        }
                    }

                    pt.Y = (((pt.Y * cpu_vals_added) + (value * 100d)) / (cpu_vals_added + 1d)); // update average in the usual way
                }
            }

            #endregion

            #region memory

            if (TypeString == "memory_total_kib")
            {
                DataSet other = setsAdded.FirstOrDefault(s => s.TypeString == "memory_free_kib");
                if (other != null && other.Points.Count - 1 == Points.Count)
                {
                    yValue = isNanOrInfinity || other.Points[other.Points.Count - 1].Y < 0
                                 ? NegativeValue
                                 : (value * MultiplyingFactor) - other.Points[other.Points.Count - 1].Y;
                    other.Points[other.Points.Count - 1].Y = yValue;
                }
            }
            else if (TypeString == "memory_free_kib")
            {
                DataSet other = setsAdded.FirstOrDefault(s => s.TypeString == "memory_total_kib");
                if (other != null && other.Points.Count - 1 == Points.Count)
                {
                    yValue = isNanOrInfinity || other.Points[other.Points.Count - 1].Y < 0
                                 ? NegativeValue
                                 : other.Points[other.Points.Count - 1].Y - (value * MultiplyingFactor);
                }
            }
            else if (TypeString == "memory")
            {
                DataSet other = setsAdded.FirstOrDefault(s => s.TypeString == "memory_internal_free");
                if (other != null && other.Points.Count - 1 == Points.Count)
                {
                    yValue = isNanOrInfinity || other.Points[other.Points.Count - 1].Y < 0
                                 ? NegativeValue
                                 : (value * MultiplyingFactor) - other.Points[other.Points.Count - 1].Y;
                    other.Points[other.Points.Count - 1].Y = yValue;
                }
            }
            else if (TypeString == "memory_internal_free")
            {
                DataSet other = setsAdded.FirstOrDefault(s => s.TypeString == "memory");
                if (other != null && other.Points.Count - 1 == Points.Count)
                {
                    yValue = isNanOrInfinity || other.Points[other.Points.Count - 1].Y < 0
                                 ? NegativeValue
                                 : other.Points[other.Points.Count - 1].Y - (value * MultiplyingFactor);
                }
            }

            #endregion

            AddPoint(new DataPoint(currentTime, yValue));
        }