Exemple #1
0
        public static string hostNetworkUsageStringByMetric(Host host, MetricUpdater MetricUpdater)
        {
            double sum = 0;
            double max = 0;
            int    i   = 0;

            foreach (PIF pif in host.Connection.ResolveAll(host.PIFs))
            {
                if (!pif.physical)
                {
                    continue;
                }

                double value = MetricUpdater.GetValue(host, String.Format("pif_{0}_rx", pif.device)) + MetricUpdater.GetValue(host, String.Format("vbd_{0}_tx", pif.device));
                sum += value;
                if (value > max)
                {
                    max = value;
                }
                i++;
            }
            if (Double.IsNaN(sum))
            {
                return(Messages.HYPHEN);
            }
            return(i == 0 ? Messages.HYPHEN : String.Format(Messages.QUERY_DATA_AVG_MAX, (sum / (Util.BINARY_KILO * i)).ToString("0."), (max / Util.BINARY_KILO).ToString("0.")));
        }
Exemple #2
0
        public static string vmCpuUsageStringByMetric(VM vm, MetricUpdater MetricUpdater)
        {
            VM_metrics metrics = vm.Connection.Resolve(vm.metrics);

            if (metrics == null)
            {
                return("");
            }
            double sum   = 0;
            int    total = (int)metrics.VCPUs_number;

            for (int i = 0; i < total; i++)
            {
                sum += MetricUpdater.GetValue(vm, String.Format("cpu{0}", i.ToString()));
            }

            if (total == 0 || Double.IsNaN(sum))
            {
                return(Messages.HYPHEN);
            }
            if (total == 1)
            {
                return(String.Format(Messages.QUERY_PERCENT_OF_CPU, (sum * 100).ToString("0.")));
            }
            return(String.Format(Messages.QUERY_PERCENT_OF_CPUS, ((sum * 100) / total).ToString("0."), total));
        }
Exemple #3
0
        public static string hostMemoryUsagePercentageStringByMetric(Host host, MetricUpdater MetricUpdater)
        {
            double free  = MetricUpdater.GetValue(host, "memory_free_kib");
            double total = MetricUpdater.GetValue(host, "memory_total_kib");

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
            {
                return(Messages.HYPHEN);
            }

            return(String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - free) / total * 100.0).ToString("0."), Util.MemorySizeString(total * Util.BINARY_KILO)));
        }
Exemple #4
0
        public static string hostMemoryUsageStringByMetric(Host host, MetricUpdater MetricUpdater)
        {
            double free  = MetricUpdater.GetValue(host, "memory_free_kib");
            double total = MetricUpdater.GetValue(host, "memory_total_kib");

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
            {
                return(Messages.HYPHEN);
            }

            return(String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - free) * Util.BINARY_KILO), Util.MemorySizeString(total * Util.BINARY_KILO)));
        }
Exemple #5
0
 public QueryPanel()
 {
     this.SuspendLayout();
     MetricUpdater = PropertyAccessorHelper.MetricUpdater; // new MetricUpdater();
     MetricUpdater.MetricsUpdated += MetricsUpdated;
     this.ResumeLayout(false);
     base.HasLeftExpanders = false;
     VerticalScroll.Visible = true;
     SetupHeaderRow();
     CustomFieldsManager.CustomFieldsChanged += CustomFields_CustomFieldsChanged;
     listUpdateManager.Update += listUpdateManager_Update;
 }
Exemple #6
0
        public static string vmMemoryUsagePercentageStringByMetric(VM vm, MetricUpdater MetricUpdater)
        {
            double free  = MetricUpdater.GetValue(vm, "memory_internal_free");
            double total = MetricUpdater.GetValue(vm, "memory");

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
            {
                return(Messages.HYPHEN);
            }

            return(String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - (free * Util.BINARY_KILO)) / total * 100.0).ToString("0."), Util.MemorySizeString(total)));
        }
Exemple #7
0
        public static string vmMemoryUsageStringByMetric(VM vm, MetricUpdater MetricUpdater)
        {
            double free  = MetricUpdater.GetValue(vm, "memory_internal_free");
            double total = MetricUpdater.GetValue(vm, "memory");

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free) || total < (free * Util.BINARY_KILO))
            {
                return(Messages.HYPHEN);
            }

            return(String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - (free * Util.BINARY_KILO))), Util.MemorySizeString(total)));
        }
 /// <summary> 
 /// used for generate resource report
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="filename"></param>
 public ExportResourceReportAction(IXenConnection connection, string filename, int fileType)
     : base(connection, string.Format(Messages.ACTION_EXPORT_POOL_RESOURCE_LIST_FROM_X, Helpers.GetName(connection)),
     Messages.ACTION_EXPORT_DESCRIPTION_PREPARING)
 {
     Pool = Helpers.GetPool(connection);
     _filename = filename;
     _fileType = fileType;
     MetricUpdater = new MetricUpdater();
     MetricUpdater.SetXenObjects(connection.Cache.Hosts);
     MetricUpdater.SetXenObjects(connection.Cache.VMs);
     MetricUpdater.UpdateMetricsOnce();
     itemCount = connection.Cache.Hosts.Length + connection.Cache.Networks.Length + connection.Cache.SRs.Length + connection.Cache.VMs.Length;
 }
Exemple #9
0
        public static string PGPUUtilisationString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI    pci         = pGpu.Connection.Resolve(pGpu.PCI);
            Host   host        = pGpu.Connection.Resolve(pGpu.host);
            string pci_id      = pci.pci_id.Replace(@":", "/");
            double utilisation = MetricUpdater.GetValue(host, String.Format("gpu_utilisation_computer_{0}", pci_id));

            if (utilisation == 0 || Double.IsNaN(utilisation) || Double.IsNaN(utilisation))
            {
                return(Messages.HYPHEN);
            }
            else
            {
                return(utilisation.ToString());
            }
        }
Exemple #10
0
        public static string PGPUPowerUsageString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI    pci        = pGpu.Connection.Resolve(pGpu.PCI);
            string pci_id     = pci.pci_id.Replace(@":", "/");
            Host   host       = pGpu.Connection.Resolve(pGpu.host);
            double powerUsage = MetricUpdater.GetValue(host, String.Format("gpu_power_usage_{0}", pci_id));

            if (powerUsage == 0 || Double.IsNaN(powerUsage) || Double.IsNaN(powerUsage))
            {
                return(Messages.HYPHEN);
            }
            else
            {
                return(powerUsage.ToString());
            }
        }
Exemple #11
0
        public static string PGPUMemoryUsageString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI    pci    = pGpu.Connection.Resolve(pGpu.PCI);
            string pci_id = pci.pci_id.Replace(@":", "/");
            Host   host   = pGpu.Connection.Resolve(pGpu.host);
            double free   = MetricUpdater.GetValue(host, String.Format("gpu_memory_free_{0}", pci_id));
            double used   = MetricUpdater.GetValue(host, String.Format("gpu_memory_used_{0}", pci_id));
            double total  = free + used;

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
            {
                return(Messages.HYPHEN);
            }
            else
            {
                return(String.Format(Messages.QUERY_MEMORY_USAGE, (used / (free + used) * 100).ToString("0.") + "%", Util.MemorySizeString(free + used)));
            }
        }
Exemple #12
0
        public static string hostCpuUsageStringByMetric(Host host, MetricUpdater MetricUpdater)
        {
            double sum = 0;

            if (host.host_CPUs == null)
            {
                return(Messages.HYPHEN);
            }
            int total = host.host_CPUs.Count;

            for (int i = 0; i < total; i++)
            {
                sum += MetricUpdater.GetValue(host, String.Format("cpu{0}", i.ToString()));
            }
            if (total == 0 || Double.IsNaN(sum))
            {
                return(Messages.HYPHEN);
            }
            if (total == 1)
            {
                return(String.Format(Messages.QUERY_PERCENT_OF_CPU, (sum * 100).ToString("0.")));
            }
            return(String.Format(Messages.QUERY_PERCENT_OF_CPUS, ((sum * 100) / total).ToString("0."), total));
        }
 static PropertyAccessorHelper()
 {
     MetricUpdater = new MetricUpdater();
 }
        public static string vmMemoryUsageStringByMetric(VM vm, MetricUpdater MetricUpdater)
        {
            double free = MetricUpdater.GetValue(vm, "memory_internal_free");
            double total = MetricUpdater.GetValue(vm, "memory");

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free) || total < (free * Util.BINARY_KILO))
                return Messages.HYPHEN;

            return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - (free * Util.BINARY_KILO))), Util.MemorySizeString(total));
        }
        public static string vmMemoryUsagePercentageStringByMetric(VM vm, MetricUpdater MetricUpdater)
        {
            double free = MetricUpdater.GetValue(vm, "memory_internal_free");
            double total = MetricUpdater.GetValue(vm, "memory");

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
                return Messages.HYPHEN;

            return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - (free * Util.BINARY_KILO))/total * 100.0).ToString("0."), Util.MemorySizeString(total));
        }
        public static string vmCpuUsageStringByMetric(VM vm, MetricUpdater MetricUpdater)
        {
            VM_metrics metrics = vm.Connection.Resolve(vm.metrics);
            if (metrics == null)
                return "";
            double sum = 0;
            int total = (int)metrics.VCPUs_number;
            for (int i = 0; i < total; i++)
            {
                sum += MetricUpdater.GetValue(vm, String.Format("cpu{0}", i.ToString()));
            }

            if (total == 0||Double.IsNaN(sum))
                return Messages.HYPHEN;
            if (total == 1)
                return String.Format(Messages.QUERY_PERCENT_OF_CPU, (sum * 100).ToString("0."));
            return String.Format(Messages.QUERY_PERCENT_OF_CPUS, ((sum * 100) / total).ToString("0."), total);
        }
        public static string PGPUUtilisationString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI pci = pGpu.Connection.Resolve(pGpu.PCI);
            Host host = pGpu.Connection.Resolve(pGpu.host);
            string pci_id = pci.pci_id.Replace(@":", "/");
            double utilisation = MetricUpdater.GetValue(host, String.Format("gpu_utilisation_computer_{0}", pci_id));

            if (utilisation == 0 || Double.IsNaN(utilisation) || Double.IsNaN(utilisation))
                return Messages.HYPHEN;
            else
                return utilisation.ToString();
        }
 public static string PGPUTemperatureString(PGPU pGpu, MetricUpdater MetricUpdater)
 {
     PCI pci = pGpu.Connection.Resolve(pGpu.PCI);
     Host host = pGpu.Connection.Resolve(pGpu.host);
     string pci_id = pci.pci_id.Replace(@":", "/");
     double temperture = MetricUpdater.GetValue(host, String.Format("gpu_temperature_{0}", pci_id));
     if (temperture == 0 || Double.IsNaN(temperture) || Double.IsNaN(temperture))
         return Messages.HYPHEN;
     else
         return temperture.ToString();
 }
        public static string PGPUMemoryUsageString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI pci = pGpu.Connection.Resolve(pGpu.PCI);
            string pci_id = pci.pci_id.Replace(@":", "/");
            Host host = pGpu.Connection.Resolve(pGpu.host);
            double free = MetricUpdater.GetValue(host, String.Format("gpu_memory_free_{0}", pci_id));
            double used = MetricUpdater.GetValue(host, String.Format("gpu_memory_used_{0}", pci_id));
            double total = free + used;

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
                return Messages.HYPHEN;
            else
                return String.Format(Messages.QUERY_MEMORY_USAGE, (used / (free + used) * 100).ToString("0.") + "%", Util.MemorySizeString(free + used));
        }
        public static string hostNetworkUsageStringByMetric(Host host, MetricUpdater MetricUpdater)
        {
            double sum = 0;
            double max = 0;
            int i = 0;
            foreach (PIF pif in host.Connection.ResolveAll(host.PIFs))
            {
                if (!pif.physical)
                    continue;

                double value = MetricUpdater.GetValue(host, String.Format("pif_{0}_rx", pif.device)) + MetricUpdater.GetValue(host, String.Format("vbd_{0}_tx", pif.device));
                sum += value;
                if (value > max)
                    max = value;
                i++;
            }
            if (Double.IsNaN(sum))
                return Messages.HYPHEN;
            return i == 0 ? Messages.HYPHEN : String.Format(Messages.QUERY_DATA_AVG_MAX, (sum / (Util.BINARY_KILO * i)).ToString("0."), (max / Util.BINARY_KILO).ToString("0."));
        }
        public static string hostMemoryUsageStringByMetric(Host host, MetricUpdater MetricUpdater)
        {
            double free = MetricUpdater.GetValue(host, "memory_free_kib");
            double total = MetricUpdater.GetValue(host, "memory_total_kib");

            if (total == 0 || Double.IsNaN(total)|| Double.IsNaN(free))
                return Messages.HYPHEN;

            return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - free) * Util.BINARY_KILO), Util.MemorySizeString(total * Util.BINARY_KILO));
        }
        public static string hostMemoryUsagePercentageStringByMetric(Host host, MetricUpdater MetricUpdater)
        {
            double free = MetricUpdater.GetValue(host, "memory_free_kib");
            double total = MetricUpdater.GetValue(host, "memory_total_kib");

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
                return Messages.HYPHEN;

            return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - free) / total * 100.0).ToString("0."), Util.MemorySizeString(total * Util.BINARY_KILO));
        }
 public static string hostCpuUsageStringByMetric(Host host, MetricUpdater MetricUpdater)
 {
     double sum = 0;
     if (host.host_CPUs == null)
         return Messages.HYPHEN;
     int total = host.host_CPUs.Count;
     for (int i = 0; i < total; i++)
     {
         sum += MetricUpdater.GetValue(host, String.Format("cpu{0}", i.ToString()));
     }
     if (total == 0 || Double.IsNaN(sum))
         return Messages.HYPHEN;
     if (total == 1)
         return String.Format(Messages.QUERY_PERCENT_OF_CPU, (sum * 100).ToString("0."));
     return String.Format(Messages.QUERY_PERCENT_OF_CPUS, ((sum * 100) / total).ToString("0."), total);
 }
Exemple #24
0
 static PropertyAccessorHelper()
 {
     MetricUpdater = new MetricUpdater();
 }