- Timestamp:
- Jan 16, 2024 11:56:05 AM (13 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
r102888 r102893 1190 1190 , m_strCPUMetricName("CPU Load") 1191 1191 , m_strRAMMetricName("RAM Usage") 1192 , m_strDiskIOMetricName("DiskIO")1193 1192 , m_iMaximumQueueSize(iMaximumQueueSize) 1194 1193 , m_pMainLayout(0) … … 1374 1373 , m_strVMExitMetricName("VMExits") 1375 1374 , m_strNetworkMetricName("Network") 1375 , m_strDiskIOMetricName("DiskIO") 1376 1376 , m_fGuestAdditionsAvailable(false) 1377 1377 { … … 1935 1935 , m_strNetworkInMetricName("Network Receive") 1936 1936 , m_strNetworkOutMetricName("Network Transmit") 1937 , m_strDiskIOReadMetricName("Disk Written") 1938 , m_strDiskIOWrittenMetricName("Disk Read") 1937 1939 , m_pMachineStateUpdateTimer(0) 1938 1940 , m_enmMachineState(KCloudMachineState_Invalid) … … 1940 1942 m_metricTypeNames[KMetricType_CpuUtilization] = m_strCPUMetricName; 1941 1943 m_metricTypeNames[KMetricType_MemoryUtilization] = m_strRAMMetricName; 1942 m_metricTypeNames[KMetricType_DiskBytesRead] = m_strDiskIO MetricName;1943 m_metricTypeNames[KMetricType_DiskBytesWritten] = m_strDiskIO MetricName;1944 m_metricTypeNames[KMetricType_DiskBytesRead] = m_strDiskIOReadMetricName; 1945 m_metricTypeNames[KMetricType_DiskBytesWritten] = m_strDiskIOWrittenMetricName; 1944 1946 m_metricTypeNames[KMetricType_NetworksBytesIn] = m_strNetworkInMetricName; 1945 1947 m_metricTypeNames[KMetricType_NetworksBytesOut] = m_strNetworkOutMetricName; … … 1959 1961 resetNetworkInInfoLabel(); 1960 1962 resetNetworkOutInfoLabel(); 1961 resetDiskIOInfoLabel(); 1963 resetDiskIOWrittenInfoLabel(); 1964 resetDiskIOReadInfoLabel(); 1962 1965 resetRAMInfoLabel(); 1963 1966 … … 2106 2109 2107 2110 if (enmMetricType == KMetricType_NetworksBytesIn) 2108 {2109 m_networkReceiveCache.clear();2110 2111 m_metrics[m_strNetworkInMetricName].reset(); 2111 }2112 2112 else if (enmMetricType == KMetricType_NetworksBytesOut) 2113 {2114 m_networkTransmitCache.clear();2115 2113 m_metrics[m_strNetworkOutMetricName].reset(); 2116 }2117 2114 else if (enmMetricType == KMetricType_DiskBytesRead) 2118 { 2119 m_diskReadCache.clear(); 2120 m_metrics[m_strDiskIOMetricName].reset(); 2121 } 2115 m_metrics[m_strDiskIOReadMetricName].reset(); 2122 2116 else if (enmMetricType == KMetricType_DiskBytesWritten) 2123 { 2124 m_diskWriteCache.clear(); 2125 m_metrics[m_strDiskIOMetricName].reset(); 2126 2127 } 2117 m_metrics[m_strDiskIOWrittenMetricName].reset(); 2128 2118 else if (enmMetricType == KMetricType_CpuUtilization) 2129 2119 m_metrics[m_strCPUMetricName].reset(); … … 2142 2132 else if (enmMetricType == KMetricType_NetworksBytesIn) 2143 2133 updateNetworkInChart(newData[i], newTimeStamps[i]); 2144 //else if (enmMetricType == KMetricType_DiskBytesRead)2145 2146 //else if (enmMetricType == KMetricType_DiskBytesWritten)2147 // cacheDiskWrite(newTimeStamps[i], newData[i]);2134 else if (enmMetricType == KMetricType_DiskBytesRead) 2135 updateDiskIOReadChart(newData[i], newTimeStamps[i]); 2136 else if (enmMetricType == KMetricType_DiskBytesWritten) 2137 updateDiskIOWrittenChart(newData[i], newTimeStamps[i]); 2148 2138 else if (enmMetricType == KMetricType_MemoryUtilization) 2149 2139 { … … 2245 2235 resetNetworkInInfoLabel(); 2246 2236 resetNetworkOutInfoLabel(); 2247 resetDiskIOInfoLabel(); 2248 2249 m_diskWriteCache.clear(); 2250 m_diskReadCache.clear(); 2251 2252 m_networkReceiveCache.clear(); 2253 m_networkTransmitCache.clear(); 2237 resetDiskIOWrittenInfoLabel(); 2238 resetDiskIOReadInfoLabel(); 2254 2239 2255 2240 update(); … … 2322 2307 } 2323 2308 2324 void UIVMActivityMonitorCloud::updateDiskIO Chart(quint64 uWriteRate, quint64 uReadRate, const QString &strLabel)2325 { 2326 UIMetric &diskMetric = m_metrics[m_strDiskIO MetricName];2309 void UIVMActivityMonitorCloud::updateDiskIOWrittenChart(quint64 uWriteRate, const QString &strLabel) 2310 { 2311 UIMetric &diskMetric = m_metrics[m_strDiskIOWrittenMetricName]; 2327 2312 2328 2313 diskMetric.addData(0, uWriteRate, strLabel); 2329 diskMetric.addData(1, uReadRate); 2330 2331 if (m_infoLabels.contains(m_strDiskIO MetricName) && m_infoLabels[m_strDiskIOMetricName])2332 { 2333 QString strInfo = QString("<b>%1</b></b><br/> <font color=\"%2\">%3: %4</font> <br/> <font color=\"%5\">%6: %7</font>")2314 2315 2316 if (m_infoLabels.contains(m_strDiskIOWrittenMetricName) && m_infoLabels[m_strDiskIOWrittenMetricName]) 2317 { 2318 QString strInfo = QString("<b>%1</b></b><br/> <font color=\"%2\">%3: %4</font>") 2334 2319 .arg(m_strDiskIOInfoLabelTitle) 2335 .arg(dataColorString(m_strDiskIOMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg(UITranslator::formatSize(uWriteRate, g_iDecimalCount)) 2336 .arg(dataColorString(m_strDiskIOMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg(UITranslator::formatSize(uReadRate, g_iDecimalCount)); 2337 2338 m_infoLabels[m_strDiskIOMetricName]->setText(strInfo); 2339 } 2340 2341 if (m_charts.contains(m_strDiskIOMetricName)) 2342 m_charts[m_strDiskIOMetricName]->update(); 2343 } 2320 .arg(dataColorString(m_strDiskIOWrittenMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg(UITranslator::formatSize(uWriteRate, g_iDecimalCount)); 2321 2322 m_infoLabels[m_strDiskIOWrittenMetricName]->setText(strInfo); 2323 } 2324 2325 if (m_charts.contains(m_strDiskIOWrittenMetricName)) 2326 m_charts[m_strDiskIOWrittenMetricName]->update(); 2327 } 2328 2329 void UIVMActivityMonitorCloud::updateDiskIOReadChart(quint64 uReadRate, const QString &strLabel) 2330 { 2331 UIMetric &diskMetric = m_metrics[m_strDiskIOReadMetricName]; 2332 2333 diskMetric.addData(0, uReadRate, strLabel); 2334 2335 2336 if (m_infoLabels.contains(m_strDiskIOReadMetricName) && m_infoLabels[m_strDiskIOReadMetricName]) 2337 { 2338 QString strInfo = QString("<b>%1</b></b><br/> <font color=\"%2\">%3: %4</font>") 2339 .arg(m_strDiskIOInfoLabelTitle) 2340 .arg(dataColorString(m_strDiskIOReadMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg(UITranslator::formatSize(uReadRate, g_iDecimalCount)); 2341 2342 m_infoLabels[m_strDiskIOReadMetricName]->setText(strInfo); 2343 } 2344 2345 if (m_charts.contains(m_strDiskIOReadMetricName)) 2346 m_charts[m_strDiskIOReadMetricName]->update(); 2347 } 2348 2344 2349 2345 2350 void UIVMActivityMonitorCloud::updateRAMChart(quint64 iUsedRAM, const QString &strLabel) … … 2409 2414 m_metrics.insert(m_strNetworkOutMetricName, networkOutMetric); 2410 2415 2411 /* Disk IO metric */ 2412 UIMetric diskIOMetric(m_strDiskIOMetricName, "B", m_iMaximumQueueSize); 2413 diskIOMetric.setDataSeriesName(0, "Write Rate"); 2414 diskIOMetric.setDataSeriesName(1, "Read Rate"); 2415 diskIOMetric.setAutoUpdateMaximum(true); 2416 m_metrics.insert(m_strDiskIOMetricName, diskIOMetric); 2416 /* Disk write metric */ 2417 UIMetric diskIOWrittenMetric(m_strDiskIOWrittenMetricName, "B", m_iMaximumQueueSize); 2418 diskIOWrittenMetric.setDataSeriesName(0, "Write Rate"); 2419 diskIOWrittenMetric.setAutoUpdateMaximum(true); 2420 m_metrics.insert(m_strDiskIOWrittenMetricName, diskIOWrittenMetric); 2421 2422 /* Disk read metric */ 2423 UIMetric diskIOReadMetric(m_strDiskIOReadMetricName, "B", m_iMaximumQueueSize); 2424 diskIOReadMetric.setDataSeriesName(0, "Read Rate"); 2425 diskIOReadMetric.setAutoUpdateMaximum(true); 2426 m_metrics.insert(m_strDiskIOReadMetricName, diskIOReadMetric); 2417 2427 2418 2428 } … … 2424 2434 QStringList chartOrder; 2425 2435 chartOrder << m_strCPUMetricName << m_strRAMMetricName << 2426 m_strNetworkInMetricName << m_strNetworkOutMetricName << m_strDiskIO MetricName;2436 m_strNetworkInMetricName << m_strNetworkOutMetricName << m_strDiskIOWrittenMetricName << m_strDiskIOReadMetricName; 2427 2437 int iRow = 0; 2428 2438 foreach (const QString &strMetricName, chartOrder) … … 2502 2512 } 2503 2513 2504 void UIVMActivityMonitorCloud::resetDiskIO InfoLabel()2505 { 2506 if (m_infoLabels.contains(m_strDiskIO MetricName) && m_infoLabels[m_strDiskIOMetricName])2507 { 2508 QString strInfo = QString("<b>%1</b></b><br/>%2: %3 <br/>%4: %5")2514 void UIVMActivityMonitorCloud::resetDiskIOWrittenInfoLabel() 2515 { 2516 if (m_infoLabels.contains(m_strDiskIOWrittenMetricName) && m_infoLabels[m_strDiskIOWrittenMetricName]) 2517 { 2518 QString strInfo = QString("<b>%1</b></b><br/>%2: %3") 2509 2519 .arg(m_strDiskIOInfoLabelTitle) 2510 .arg(m_strDiskIOInfoLabelWritten).arg("--") 2511 .arg(m_strDiskIOInfoLabelRead).arg("--"); 2512 m_infoLabels[m_strDiskIOMetricName]->setText(strInfo); 2513 } 2514 } 2515 2516 void UIVMActivityMonitorCloud::cacheDiskWrite(const QString &strTimeStamp, quint64 iValue) 2517 { 2518 /* Make sure this is the first time we receieve write for this time stap: */ 2519 AssertReturnVoid(!m_diskWriteCache.contains(strTimeStamp)); 2520 /* If we have read rate for this time stamp just update the chart and remove related data from the cache: */ 2521 if (m_diskReadCache.contains(strTimeStamp)) 2522 { 2523 updateDiskIOChart((quint64) iValue, (quint64) m_diskReadCache[strTimeStamp], strTimeStamp); 2524 m_diskReadCache[strTimeStamp]; 2525 } 2526 else 2527 m_diskWriteCache[strTimeStamp] = iValue; 2528 } 2529 2530 void UIVMActivityMonitorCloud::cacheDiskRead(const QString &strTimeStamp, quint64 iValue) 2531 { 2532 /* Make sure this is the first time we receieve read for this time stap: */ 2533 AssertReturnVoid(!m_diskReadCache.contains(strTimeStamp)); 2534 /* If we have write rate for this time stamp just update the chart and remove related data from the cache: */ 2535 if (m_diskWriteCache.contains(strTimeStamp)) 2536 { 2537 updateDiskIOChart((quint64) m_diskWriteCache[strTimeStamp], (quint64) iValue, strTimeStamp); 2538 m_diskWriteCache.remove(strTimeStamp); 2539 } 2540 else 2541 m_diskReadCache[strTimeStamp] = iValue; 2542 } 2543 2544 void UIVMActivityMonitorCloud::cacheNetworkReceive(const QString &, quint64 ) 2545 { 2546 // AssertReturnVoid(!m_networkReceiveCache.contains(strTimeStamp)); 2547 2548 // if (m_networkTransmitCache.contains(strTimeStamp)) 2520 .arg(m_strDiskIOInfoLabelWritten).arg("--"); 2521 m_infoLabels[m_strDiskIOWrittenMetricName]->setText(strInfo); 2522 } 2523 } 2524 2525 void UIVMActivityMonitorCloud::resetDiskIOReadInfoLabel() 2526 { 2527 // if (m_infoLabels.contains(m_strDiskIOMetricName) && m_infoLabels[m_strDiskIOMetricName]) 2549 2528 // { 2550 // updateNetworkChart((quint64) iValue, (quint64) m_networkTransmitCache[strTimeStamp], strTimeStamp); 2551 // m_networkTransmitCache.remove(strTimeStamp); 2529 // QString strInfo = QString("<b>%1</b></b><br/>%2: %3<br/>%4: %5") 2530 // .arg(m_strDiskIOInfoLabelTitle) 2531 // .arg(m_strDiskIOInfoLabelWritten).arg("--") 2532 // .arg(m_strDiskIOInfoLabelRead).arg("--"); 2533 // m_infoLabels[m_strDiskIOMetricName]->setText(strInfo); 2552 2534 // } 2553 // else2554 // m_networkReceiveCache[strTimeStamp] = iValue;2555 }2556 2557 void UIVMActivityMonitorCloud::cacheNetworkTransmit(const QString &, quint64 )2558 {2559 // AssertReturnVoid(!m_networkTransmitCache.contains(strTimeStamp));2560 2561 // if (m_networkReceiveCache.contains(strTimeStamp))2562 // {2563 // updateNetworkChart((quint64) m_networkReceiveCache[strTimeStamp], (quint64) iValue, strTimeStamp);2564 // m_networkReceiveCache.remove(strTimeStamp);2565 // }2566 // else2567 // m_networkTransmitCache[strTimeStamp] = iValue;2568 2535 } 2569 2536 -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h
r102888 r102893 174 174 * @{ */ 175 175 virtual void resetCPUInfoLabel() = 0; 176 virtual void resetDiskIOInfoLabel() = 0;177 176 void resetRAMInfoLabel(); 178 177 /** @} */ … … 190 189 QString m_strCPUMetricName; 191 190 QString m_strRAMMetricName; 192 QString m_strDiskIOMetricName;193 191 /** @} */ 194 192 … … 294 292 virtual void resetCPUInfoLabel(); 295 293 void resetNetworkInfoLabel(); 296 v irtual void resetDiskIOInfoLabel();294 void resetDiskIOInfoLabel(); 297 295 virtual void prepareWidgets() RT_OVERRIDE; 298 296 299 297 QString m_strVMExitMetricName; 300 298 QString m_strNetworkMetricName; 299 QString m_strDiskIOMetricName; 301 300 302 301 bool m_fGuestAdditionsAvailable; … … 348 347 void updateNetworkInChart(quint64 uReceive, const QString &strLabel); 349 348 void updateNetworkOutChart(quint64 uTransmit, const QString &strLabel); 350 void updateDiskIOChart(quint64 uWriteRate, quint64 uReadRate, const QString &strLabel); 349 void updateDiskIOReadChart(quint64 uReadRate, const QString &strLabel); 350 void updateDiskIOWrittenChart(quint64 uWriteRate, const QString &strLabel); 351 351 void updateRAMChart(quint64 iUsagePercentage, const QString &strLabel); 352 352 /** @} */ … … 354 354 void resetNetworkInInfoLabel(); 355 355 void resetNetworkOutInfoLabel(); 356 virtual void resetDiskIOInfoLabel(); 357 358 /* Since we have a single UIMetric instance for disk IO we cache write and/or read until the other value arrives. Then update 359 * the corresponding chart. */ 360 void cacheDiskWrite(const QString &strTimeStamp, quint64 iValue); 361 void cacheDiskRead(const QString &strTimeStamp, quint64 iValue); 362 363 void cacheNetworkReceive(const QString &strTimeStamp, quint64 iValue); 364 void cacheNetworkTransmit(const QString &strTimeStamp, quint64 iValue); 356 void resetDiskIOWrittenInfoLabel(); 357 void resetDiskIOReadInfoLabel(); 365 358 366 359 bool findMetric(KMetricType enmMetricType, UIMetric &metric, int &iDataSeriesIndex) const; … … 370 363 QString m_strNetworkInMetricName; 371 364 QString m_strNetworkOutMetricName; 365 QString m_strDiskIOReadMetricName; 366 QString m_strDiskIOWrittenMetricName; 372 367 373 368 CCloudMachine m_comMachine; … … 378 373 QHash<KMetricType, QString> m_metricTypeNames; 379 374 380 /* Key is time stamp we get from our Main API, value is disk write or read values. */381 QMap<QString, quint64> m_diskWriteCache;382 QMap<QString, quint64> m_diskReadCache;383 384 QMap<QString, quint64> m_networkReceiveCache;385 QMap<QString, quint64> m_networkTransmitCache;386 375 /** Total amount of RAM in kb. */ 387 376 quint64 m_iTotalRAM;
Note:
See TracChangeset
for help on using the changeset viewer.