- Timestamp:
- Mar 31, 2020 9:04:49 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp
r83491 r83493 134 134 135 135 /********************************************************************************************************************************* 136 * Class UIVMResouceMonitorHostStats definition. * 137 *********************************************************************************************************************************/ 138 139 class UIVMResouceMonitorHostStats 140 { 141 142 public: 143 144 UIVMResouceMonitorHostStats(); 145 quint64 m_fCPUUserLoad; 146 quint64 m_fCPUKernelLoad; 147 quint64 m_iTotalRAM; 148 quint64 m_iFreeRAM; 149 }; 150 151 /********************************************************************************************************************************* 136 152 * Class UIVMResouceMonitorCheckBox definition. * 137 153 *********************************************************************************************************************************/ 154 138 155 class UIVMResouceMonitorCheckBox : public QCheckBox 139 156 { … … 209 226 void initializeItems(); 210 227 void setupPerformanceCollector(); 211 void query RAMLoad();228 void queryPerformanceCollector(); 212 229 void addItem(const QUuid& uMachineId, const QString& strMachineName); 213 230 void removeItem(const QUuid& uMachineId); 231 void getHostRAMStats(); 214 232 215 233 QVector<UIResourceMonitorItem> m_itemList; … … 228 246 * when the widget is visible in the main UI. */ 229 247 bool m_fShouldUpdate; 248 UIVMResouceMonitorHostStats m_hostStats; 230 249 }; 231 250 … … 396 415 397 416 /********************************************************************************************************************************* 417 * Class UIVMResouceMonitorHostStats implementation. * 418 *********************************************************************************************************************************/ 419 420 UIVMResouceMonitorHostStats::UIVMResouceMonitorHostStats() 421 : m_fCPUUserLoad(0) 422 , m_fCPUKernelLoad(0) 423 , m_iTotalRAM(0) 424 , m_iFreeRAM(0) 425 { 426 } 427 428 429 /********************************************************************************************************************************* 398 430 * Class UIVMResouceMonitorCheckBox implementation. * 399 431 *********************************************************************************************************************************/ … … 595 627 } 596 628 629 void UIResourceMonitorModel::getHostRAMStats() 630 { 631 CHost comHost = uiCommon().host(); 632 m_hostStats.m_iTotalRAM = _1M * (quint64)comHost.GetMemorySize(); 633 m_hostStats.m_iFreeRAM = _1M * (quint64)comHost.GetMemoryAvailable(); 634 } 635 597 636 void UIResourceMonitorModel::sltTimeout() 598 637 { … … 603 642 ULONG aPctVMM; 604 643 605 bool fRAMColumns = columnVisible(VMResouceMonitorColumn_RAMUsedAndTotal)606 || columnVisible(VMResouceMonitorColumn_RAMUsedPercentage);644 // bool fRAMColumns = columnVisible(VMResouceMonitorColumn_RAMUsedAndTotal) 645 // || columnVisible(VMResouceMonitorColumn_RAMUsedPercentage); 607 646 bool fCPUColumns = columnVisible(VMResouceMonitorColumn_CPUVMMLoad) || columnVisible(VMResouceMonitorColumn_CPUGuestLoad); 608 647 bool fNetworkColumns = columnVisible(VMResouceMonitorColumn_NetworkUpRate) … … 616 655 bool fVMExitColumn = columnVisible(VMResouceMonitorColumn_VMExits); 617 656 618 /* RAM usage: */ 619 if (!m_performanceMonitor.isNull() && fRAMColumns) 620 queryRAMLoad(); 657 getHostRAMStats(); 658 659 /* RAM usage and Host CPU: */ 660 //if (!m_performanceMonitor.isNull() && fRAMColumns) 661 queryPerformanceCollector(); 621 662 622 663 for (int i = 0; i < m_itemList.size(); ++i) … … 677 718 for (int i = 0; i < m_itemList.size(); ++i) 678 719 m_nameList << "Guest/RAM/Usage*"; 720 /* This is for the host: */ 721 m_nameList << "CPU/Load/User:avg"; 722 m_nameList << "CPU/Load/Kernel:avg"; 679 723 m_objectList = QVector<CUnknown>(m_nameList.size(), CUnknown()); 680 724 m_performanceMonitor.SetupMetrics(m_nameList, m_objectList, iPeriod, iMetricSetupCount); 681 725 } 682 726 683 void UIResourceMonitorModel::query RAMLoad()727 void UIResourceMonitorModel::queryPerformanceCollector() 684 728 { 685 729 QVector<QString> aReturnNames; … … 690 734 QVector<ULONG> aReturnDataIndices; 691 735 QVector<ULONG> aReturnDataLengths; 692 /* Make a query to CPerformanceCollector to fetch some metrics (e.g RAM usage): */ 736 693 737 QVector<LONG> returnData = m_performanceMonitor.QueryMetricsData(m_nameList, 694 738 m_objectList, … … 708 752 float fData = returnData[aReturnDataIndices[i] + aReturnDataLengths[i] - 1] / (float)aReturnScales[i]; 709 753 if (aReturnNames[i].contains("RAM", Qt::CaseInsensitive) && !aReturnNames[i].contains(":")) 754 { 710 755 if (aReturnNames[i].contains("Total", Qt::CaseInsensitive) || aReturnNames[i].contains("Free", Qt::CaseInsensitive)) 711 756 { … … 723 768 } 724 769 } 770 } 771 else if (aReturnNames[i].contains("CPU/Load/User", Qt::CaseInsensitive)) 772 { 773 CHost comHost = (CHost)aReturnObjects[i]; 774 if (!comHost.isNull()) 775 m_hostStats.m_fCPUUserLoad = fData; 776 } 777 else if (aReturnNames[i].contains("CPU/Load/Kernel", Qt::CaseInsensitive)) 778 { 779 CHost comHost = (CHost)aReturnObjects[i]; 780 if (!comHost.isNull()) 781 m_hostStats.m_fCPUKernelLoad = fData; 782 } 725 783 } 726 784 for (int i = 0; i < m_itemList.size(); ++i)
Note:
See TracChangeset
for help on using the changeset viewer.