public string GetVmNote(System.Management.ManagementPath sysPath) { uint[] requestedInfo = new uint[] { 3 }; System.Management.ManagementPath[] vmPaths = new System.Management.ManagementPath[] { sysPath }; var vmsvc = GetVirtualisationSystemManagementService(); System.Management.ManagementBaseObject[] sysSummary; vmsvc.GetSummaryInformation(requestedInfo, vmPaths, out sysSummary); foreach (var summary in sysSummary) { var summaryInfo = new SummaryInformation(summary); return summaryInfo.Notes; } return null; }
public void GetSummaryInfo(Dictionary<string, VmStatsEntry> vmProcessorInfo, List<System.Management.ManagementPath> vmsToInspect) { // Process info available from WMI, // See http://msdn.microsoft.com/en-us/library/hh850062(v=vs.85).aspx uint[] requestedInfo = new uint[] { // TODO: correct? 0, // Name 1, // ElementName 4, // Number of processes 101 // ProcessorLoad }; System.Management.ManagementBaseObject[] sysSummary; var vmsvc = GetVirtualisationSystemManagementService(); System.Management.ManagementPath[] vmPaths = vmsToInspect.ToArray(); vmsvc.GetSummaryInformation(requestedInfo, vmPaths, out sysSummary); foreach (var summary in sysSummary) { var summaryInfo = new SummaryInformation(summary); logger.Debug("VM " + summaryInfo.Name + "(elementName " + summaryInfo.ElementName + ") has " + summaryInfo.NumberOfProcessors + " CPUs, and load of " + summaryInfo.ProcessorLoad); var vmInfo = new VmStatsEntry { cpuUtilization = summaryInfo.ProcessorLoad, numCPUs = summaryInfo.NumberOfProcessors, networkReadKBs = 1, networkWriteKBs = 1, entityType = "vm" }; vmProcessorInfo.Add(summaryInfo.ElementName, vmInfo); } }