Changeset 102746 in vbox
- Timestamp:
- Jan 2, 2024 4:47:48 PM (11 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r102655 r102746 51 51 /* COM includes: */ 52 52 #include "CConsole.h" 53 #include "CForm.h" 54 #include "CFormValue.h" 53 55 #include "CGuest.h" 54 56 #include "CPerformanceCollector.h" 55 57 #include "CPerformanceMetric.h" 56 58 #include "CStringArray.h" 59 #include "CRangedIntegerFormValue.h" 57 60 #include <iprt/string.h> 61 #include <VBox/com/VirtualBox.h> 58 62 59 63 /* External includes: */ … … 725 729 return QString::number(iValue).append("%"); 726 730 if (m_pMetric->unit().compare("kb", Qt::CaseInsensitive) == 0) 727 return UITranslator::formatSize(_1K * (quint64)iValue, g_iDecimalCount);731 return UITranslator::formatSize(_1K * iValue, g_iDecimalCount); 728 732 if ( m_pMetric->unit().compare("b", Qt::CaseInsensitive) == 0 729 733 || m_pMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0) … … 731 735 if (m_pMetric->unit().compare("times", Qt::CaseInsensitive) == 0) 732 736 return UITranslator::addMetricSuffixToNumber(iValue); 737 if (m_pMetric->unit().compare("gb", Qt::CaseInsensitive) == 0) 738 return QString::number(iValue).append(" GB"); 733 739 return QString(); 734 740 } … … 1044 1050 1045 1051 addData(iDataSeriesIndex, iData); 1046 1047 1052 if (iDataSeriesIndex == 0) 1048 1053 { … … 1931 1936 m_metricTypeNames[KMetricType_NetworksBytesOut] = m_strNetworkMetricName; 1932 1937 1938 setMachine(machine); 1939 determineTotalRAMAmount(); 1940 1933 1941 prepareMetrics(); 1934 1942 prepareWidgets(); 1935 1943 retranslateUi(); 1936 1944 prepareActions(); 1937 setMachine(machine);1938 1945 resetCPUInfoLabel(); 1939 1946 resetNetworkInfoLabel(); … … 1941 1948 } 1942 1949 1950 void UIVMActivityMonitorCloud::determineTotalRAMAmount() 1951 { 1952 CForm comForm = m_comMachine.GetDetailsForm(); 1953 /* Ignore cloud machine errors: */ 1954 if (m_comMachine.isOk()) 1955 { 1956 /* Common anchor for all fields: */ 1957 const QString strAnchorType = "cloud"; 1958 1959 /* For each form value: */ 1960 const QVector<CFormValue> values = comForm.GetValues(); 1961 foreach (const CFormValue &comIteratedValue, values) 1962 { 1963 /* Ignore invisible values: */ 1964 if (!comIteratedValue.GetVisible()) 1965 continue; 1966 1967 /* Acquire label: */ 1968 const QString strLabel = comIteratedValue.GetLabel(); 1969 if (strLabel != "RAM") 1970 continue; 1971 1972 AssertReturnVoid((comIteratedValue.GetType() == KFormValueType_RangedInteger)); 1973 1974 CRangedIntegerFormValue comValue(comIteratedValue); 1975 m_iTotalRAM = comValue.GetInteger(); 1976 QString strRAMUnit = comValue.GetSuffix(); 1977 if (strRAMUnit.compare("gb", Qt::CaseInsensitive) == 0) 1978 m_iTotalRAM *= _1G / _1K; 1979 else if (strRAMUnit.compare("mb", Qt::CaseInsensitive) == 0) 1980 m_iTotalRAM *= _1M / _1K; 1981 if (!comValue.isOk()) 1982 m_iTotalRAM = 0; 1983 } 1984 } 1985 } 1943 1986 1944 1987 void UIVMActivityMonitorCloud::setMachine(const CCloudMachine &comMachine) … … 1988 2031 else if (enmMetricType == KMetricType_DiskBytesWritten) 1989 2032 cacheDiskWrite(timeStamps[i], (int)data[i].toFloat()); 2033 else if (enmMetricType == KMetricType_MemoryUtilization) 2034 { 2035 if (m_iTotalRAM != 0) 2036 { 2037 /* calculate used RAM amount in kb: */ 2038 quint64 iUsedRAM = data[i].toFloat() * (m_iTotalRAM / 100.f); 2039 updateRAMChart(iUsedRAM, timeStamps[i]); 2040 } 2041 } 1990 2042 } 1991 2043 sender()->deleteLater(); … … 2089 2141 m_infoLabels[m_strNetworkMetricName]->setText(strInfo); 2090 2142 } 2143 if (m_charts.contains(m_strNetworkMetricName)) 2144 m_charts[m_strNetworkMetricName]->update(); 2091 2145 } 2092 2146 … … 2110 2164 if (m_charts.contains(m_strDiskIOMetricName)) 2111 2165 m_charts[m_strDiskIOMetricName]->update(); 2166 } 2167 2168 void UIVMActivityMonitorCloud::updateRAMChart(quint64 iUsedRAM, const QString &strLabel) 2169 { 2170 UIMetric &RAMMetric = m_metrics[m_strRAMMetricName]; 2171 RAMMetric.setMaximum(m_iTotalRAM); 2172 RAMMetric.addData(0, iUsedRAM, strLabel); 2173 2174 if (m_infoLabels.contains(m_strRAMMetricName) && m_infoLabels[m_strRAMMetricName]) 2175 { 2176 QString strInfo; 2177 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle) 2178 .arg(m_strRAMInfoLabelTotal).arg(UITranslator::formatSize(_1K * m_iTotalRAM, g_iDecimalCount)) 2179 .arg(m_strRAMInfoLabelFree).arg(UITranslator::formatSize(_1K * (m_iTotalRAM - iUsedRAM), g_iDecimalCount)) 2180 .arg(m_strRAMInfoLabelUsed).arg(UITranslator::formatSize(_1K * iUsedRAM, g_iDecimalCount)); 2181 m_infoLabels[m_strRAMMetricName]->setText(strInfo); 2182 } 2183 2184 if (m_charts.contains(m_strRAMMetricName)) 2185 m_charts[m_strRAMMetricName]->update(); 2112 2186 } 2113 2187 … … 2132 2206 void UIVMActivityMonitorCloud::prepareMetrics() 2133 2207 { 2134 // UIMetric ramMetric(m_strRAMMetricName, metrics[i].GetUnit(), m_iMaximumQueueSize); 2135 // ramMetric.setDataSeriesName(0, "Free"); 2136 // ramMetric.setDataSeriesName(1, "Used"); 2137 // ramMetric.setRequiresGuestAdditions(true); 2138 // m_metrics.insert(m_strRAMMetricName, ramMetric); 2208 /* RAM Metric: */ 2209 if (m_iTotalRAM != 0) 2210 { 2211 UIMetric ramMetric(m_strRAMMetricName, "kb", m_iMaximumQueueSize); 2212 ramMetric.setDataSeriesName(0, "Used"); 2213 m_metrics.insert(m_strRAMMetricName, ramMetric); 2214 } 2139 2215 2140 2216 /* CPU Metric: */ -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h
r102655 r102746 338 338 /** @name The following functions update corresponding metric charts and labels with new values 339 339 * @{ */ 340 virtual void updateCPUChart(ULONG iLoadPercentage, const QString &strLabel); 341 virtual void updateNetworkChart(quint64 uReceive, quint64 uTransmit, const QString &strLabel); 342 virtual void updateDiskIOChart(quint64 uWriteRate, quint64 uReadRate, const QString &strLabel); 340 void updateCPUChart(ULONG iLoadPercentage, const QString &strLabel); 341 void updateNetworkChart(quint64 uReceive, quint64 uTransmit, const QString &strLabel); 342 void updateDiskIOChart(quint64 uWriteRate, quint64 uReadRate, const QString &strLabel); 343 void updateRAMChart(quint64 iUsagePercentage, const QString &strLabel); 343 344 /** @} */ 344 345 virtual void resetCPUInfoLabel(); … … 356 357 bool findMetric(KMetricType enmMetricType, UIMetric &metric, int &iDataSeriesIndex) const; 357 358 void prepareMetrics(); 359 void determineTotalRAMAmount(); 358 360 359 361 CCloudMachine m_comMachine; … … 370 372 QMap<QString, quint64> m_networkReceiveCache; 371 373 QMap<QString, quint64> m_networkTransmitCache; 372 374 /** Total amount of RAM in kb. */ 375 quint64 m_iTotalRAM; 373 376 }; 374 377 #endif /* !FEQT_INCLUDED_SRC_activity_vmactivity_UIVMActivityMonitor_h */
Note:
See TracChangeset
for help on using the changeset viewer.