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 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 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 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 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 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 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 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 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()); } }
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)); }
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); }
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 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 int vmCpuUsageRank(VM vm) { VM_metrics metrics = vm.Connection.Resolve(vm.metrics); if (metrics == null) { return(0); } 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())); } return((int)Math.Round((sum * 100.0) / (double)total)); }