- Timestamp:
- Nov 20, 2023 6:35:00 AM (17 months ago)
- svn:sync-xref-src-repo-rev:
- 160272
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityToolWidget.cpp ¶
r98103 r102147 195 195 if (comMachine.isNull()) 196 196 continue; 197 addTab(new UIVMActivityMonitor (m_enmEmbedding, this, comMachine), comMachine.GetName());197 addTab(new UIVMActivityMonitorLocal(m_enmEmbedding, this, comMachine), comMachine.GetName()); 198 198 } 199 199 } -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp ¶
r101561 r102147 907 907 *********************************************************************************************************************************/ 908 908 909 UIVMActivityMonitor::UIVMActivityMonitor(EmbedTo enmEmbedding, QWidget *pParent, 910 const CMachine &machine) 909 UIVMActivityMonitor::UIVMActivityMonitor(EmbedTo enmEmbedding, QWidget *pParent) 911 910 : QIWithRetranslateUI<QWidget>(pParent) 912 , m_fGuestAdditionsAvailable(false)913 , m_pMainLayout(0)914 911 , m_pTimer(0) 912 , m_iTimeStep(0) 915 913 , m_strCPUMetricName("CPU Load") 916 914 , m_strRAMMetricName("RAM Usage") … … 919 917 , m_strDiskIOMetricName("DiskIO") 920 918 , m_strVMExitMetricName("VMExits") 921 , m_ iTimeStep(0)919 , m_pMainLayout(0) 922 920 , m_enmEmbedding(enmEmbedding) 923 921 { 924 prepareMetrics();925 prepareWidgets();926 prepareActions();927 retranslateUi();928 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, this, &UIVMActivityMonitor::sltMachineStateChange);929 setMachine(machine);930 922 uiCommon().setHelpKeyword(this, "vm-session-information"); 931 923 setContextMenuPolicy(Qt::CustomContextMenu); 932 924 connect(this, &UIVMActivityMonitor::customContextMenuRequested, 933 925 this, &UIVMActivityMonitor::sltCreateContextMenu); 934 connect(&uiCommon(), &UICommon::sigAskToDetachCOM,935 this, &UIVMActivityMonitor::sltClearCOMData);936 }937 938 UIVMActivityMonitor::~UIVMActivityMonitor()939 {940 sltClearCOMData();941 }942 943 void UIVMActivityMonitor::setMachine(const CMachine &comMachine)944 {945 reset();946 if (comMachine.isNull())947 return;948 949 if (!m_comSession.isNull())950 m_comSession.UnlockMachine();951 952 m_comMachine = comMachine;953 954 if (m_comMachine.GetState() == KMachineState_Running)955 {956 setEnabled(true);957 openSession();958 start();959 }960 }961 962 QUuid UIVMActivityMonitor::machineId() const963 {964 if (m_comMachine.isNull())965 return QUuid();966 return m_comMachine.GetId();967 }968 969 QString UIVMActivityMonitor::machineName() const970 {971 if (m_comMachine.isNull())972 return QString();973 return m_comMachine.GetName();974 }975 976 void UIVMActivityMonitor::openSession()977 {978 if (!m_comSession.isNull())979 return;980 m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared);981 AssertReturnVoid(!m_comSession.isNull());982 983 CConsole comConsole = m_comSession.GetConsole();984 AssertReturnVoid(!comConsole.isNull());985 m_comGuest = comConsole.GetGuest();986 987 m_comMachineDebugger = comConsole.GetDebugger();988 926 } 989 927 … … 1029 967 m_strDiskIOInfoLabelReadTotal = QApplication::translate("UIVMInformationDialog", "Total Read"); 1030 968 iMaximum = qMax(iMaximum, m_strDiskIOInfoLabelReadTotal.length()); 1031 m_strVMExitInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "VM Exits");1032 iMaximum = qMax(iMaximum, m_strVMExitInfoLabelTitle.length());1033 m_strVMExitLabelCurrent = QApplication::translate("UIVMInformationDialog", "Current");1034 iMaximum = qMax(iMaximum, m_strVMExitLabelCurrent.length());1035 m_strVMExitLabelTotal = QApplication::translate("UIVMInformationDialog", "Total");1036 iMaximum = qMax(iMaximum, m_strVMExitLabelTotal.length());1037 969 1038 970 /* Compute the maximum label string length and set it as a fixed width to labels to prevent always changing widths: */ … … 1104 1036 if (!m_metrics.contains(strMetricName)) 1105 1037 continue; 1038 1106 1039 QHBoxLayout *pChartLayout = new QHBoxLayout; 1107 1040 pChartLayout->setSpacing(0); … … 1138 1071 void UIVMActivityMonitor::sltTimeout() 1139 1072 { 1140 if (m_performanceCollector.isNull()) 1141 return; 1142 ++m_iTimeStep; 1143 1144 if (m_metrics.contains(m_strRAMMetricName)) 1145 { 1146 quint64 iTotalRAM = 0; 1147 quint64 iFreeRAM = 0; 1148 UIMonitorCommon::getRAMLoad(m_performanceCollector, m_nameList, m_objectList, iTotalRAM, iFreeRAM); 1149 updateRAMGraphsAndMetric(iTotalRAM, iFreeRAM); 1150 } 1151 1152 /* Update the CPU load chart with values we get from IMachineDebugger::getCPULoad(..): */ 1153 if (m_metrics.contains(m_strCPUMetricName)) 1154 { 1155 ULONG aPctExecuting; 1156 ULONG aPctHalted; 1157 ULONG aPctOther; 1158 m_comMachineDebugger.GetCPULoad(0x7fffffff, aPctExecuting, aPctHalted, aPctOther); 1159 updateCPUGraphsAndMetric(aPctExecuting, aPctOther); 1160 } 1161 1162 /* Update the network load chart with values we find under /Public/NetAdapter/: */ 1163 { 1164 quint64 cbNetworkTotalReceived = 0; 1165 quint64 cbNetworkTotalTransmitted = 0; 1166 UIMonitorCommon::getNetworkLoad(m_comMachineDebugger, cbNetworkTotalReceived, cbNetworkTotalTransmitted); 1167 updateNetworkGraphsAndMetric(cbNetworkTotalReceived, cbNetworkTotalTransmitted); 1168 } 1169 1170 /* Update the Disk I/O chart with values we find under /Public/Storage/?/Port?/Bytes*: */ 1171 { 1172 quint64 cbDiskIOTotalWritten = 0; 1173 quint64 cbDiskIOTotalRead = 0; 1174 UIMonitorCommon::getDiskLoad(m_comMachineDebugger, cbDiskIOTotalWritten, cbDiskIOTotalRead); 1175 updateDiskIOGraphsAndMetric(cbDiskIOTotalWritten, cbDiskIOTotalRead); 1176 } 1177 1178 /* Update the VM exit chart with values we find as /PROF/CPU?/EM/RecordedExits: */ 1179 { 1180 quint64 cTotalVMExits = 0; 1181 UIMonitorCommon::getVMMExitCount(m_comMachineDebugger, cTotalVMExits); 1182 updateVMExitMetric(cTotalVMExits); 1183 } 1184 } 1185 1186 void UIVMActivityMonitor::sltMachineStateChange(const QUuid &uId) 1187 { 1188 if (m_comMachine.isNull()) 1189 return; 1190 if (m_comMachine.GetId() != uId) 1191 return; 1192 if (m_comMachine.GetState() == KMachineState_Running) 1193 { 1194 setEnabled(true); 1195 openSession(); 1196 start(); 1197 } 1198 else if (m_comMachine.GetState() == KMachineState_Paused) 1199 { 1200 /* If we are already active then stop: */ 1201 if (!m_comSession.isNull() && m_pTimer && m_pTimer->isActive()) 1202 m_pTimer->stop(); 1203 } 1204 else 1205 reset(); 1073 obtainDataAndUpdate(); 1206 1074 } 1207 1075 … … 1209 1077 { 1210 1078 QString strStartFileName = QString("%1/%2_%3"). 1211 arg(QFileInfo( m_comMachine.GetSettingsFilePath()).absolutePath()).1212 arg(m _comMachine.GetName()).1079 arg(QFileInfo(defaultMachineFolder()).absolutePath()). 1080 arg(machineName()). 1213 1081 arg(QDateTime::currentDateTime().toString("dd-MM-yyyy_hh-mm-ss")); 1214 1082 QString strFileName = QIFileDialog::getSaveFileName(strStartFileName,"",this, 1215 1083 QApplication::translate("UIVMInformationDialog", 1216 1084 "Export activity data of the machine \"%1\"") 1217 .arg(m _comMachine.GetName()));1085 .arg(machineName())); 1218 1086 QFile dataFile(strFileName); 1219 1087 if (dataFile.open(QFile::WriteOnly | QFile::Truncate)) … … 1236 1104 } 1237 1105 1238 void UIVMActivityMonitor::sltGuestAdditionsStateChange()1239 {1240 bool fGuestAdditionsAvailable = guestAdditionsAvailable("6.1");1241 if (m_fGuestAdditionsAvailable == fGuestAdditionsAvailable)1242 return;1243 m_fGuestAdditionsAvailable = fGuestAdditionsAvailable;1244 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable);1245 }1246 1247 void UIVMActivityMonitor::sltClearCOMData()1248 {1249 if (!m_comSession.isNull())1250 {1251 m_comSession.UnlockMachine();1252 m_comSession.detach();1253 }1254 }1255 1256 void UIVMActivityMonitor::prepareMetrics()1257 {1258 m_performanceCollector = uiCommon().virtualBox().GetPerformanceCollector();1259 if (m_performanceCollector.isNull())1260 return;1261 1262 m_nameList << "Guest/RAM/Usage*";1263 m_objectList = QVector<CUnknown>(m_nameList.size(), CUnknown());1264 m_performanceCollector.SetupMetrics(m_nameList, m_objectList, g_iPeriod, g_iMetricSetupCount);1265 {1266 QVector<CPerformanceMetric> metrics = m_performanceCollector.GetMetrics(m_nameList, m_objectList);1267 for (int i = 0; i < metrics.size(); ++i)1268 {1269 QString strName(metrics[i].GetMetricName());1270 if (!strName.contains(':'))1271 {1272 if (strName.contains("RAM", Qt::CaseInsensitive) && strName.contains("Free", Qt::CaseInsensitive))1273 {1274 UIMetric ramMetric(m_strRAMMetricName, metrics[i].GetUnit(), g_iMaximumQueueSize);1275 ramMetric.setDataSeriesName(0, "Free");1276 ramMetric.setDataSeriesName(1, "Used");1277 ramMetric.setRequiresGuestAdditions(true);1278 m_metrics.insert(m_strRAMMetricName, ramMetric);1279 }1280 }1281 }1282 }1283 1284 /* CPU Metric: */1285 UIMetric cpuMetric(m_strCPUMetricName, "%", g_iMaximumQueueSize);1286 cpuMetric.setDataSeriesName(0, "Guest Load");1287 cpuMetric.setDataSeriesName(1, "VMM Load");1288 m_metrics.insert(m_strCPUMetricName, cpuMetric);1289 1290 /* Network metric: */1291 UIMetric networkMetric(m_strNetworkMetricName, "B", g_iMaximumQueueSize);1292 networkMetric.setDataSeriesName(0, "Receive Rate");1293 networkMetric.setDataSeriesName(1, "Transmit Rate");1294 networkMetric.setAutoUpdateMaximum(true);1295 m_metrics.insert(m_strNetworkMetricName, networkMetric);1296 1297 /* Disk IO metric */1298 UIMetric diskIOMetric(m_strDiskIOMetricName, "B", g_iMaximumQueueSize);1299 diskIOMetric.setDataSeriesName(0, "Write Rate");1300 diskIOMetric.setDataSeriesName(1, "Read Rate");1301 diskIOMetric.setAutoUpdateMaximum(true);1302 m_metrics.insert(m_strDiskIOMetricName, diskIOMetric);1303 1304 /* VM exits metric */1305 UIMetric VMExitsMetric(m_strVMExitMetricName, "times", g_iMaximumQueueSize);1306 VMExitsMetric.setAutoUpdateMaximum(true);1307 m_metrics.insert(m_strVMExitMetricName, VMExitsMetric);1308 }1309 1310 1106 void UIVMActivityMonitor::prepareActions() 1311 1107 { 1312 }1313 1314 bool UIVMActivityMonitor::guestAdditionsAvailable(const char *pszMinimumVersion)1315 {1316 if (m_comGuest.isNull() || !pszMinimumVersion)1317 return false;1318 1319 /* Guest control stuff is in userland: */1320 if (!m_comGuest.GetAdditionsStatus(KAdditionsRunLevelType_Userland))1321 return false;1322 1323 if (!m_comGuest.isOk())1324 return false;1325 1326 /* Check the related GA facility: */1327 LONG64 iLastUpdatedIgnored;1328 if (m_comGuest.GetFacilityStatus(KAdditionsFacilityType_VBoxService, iLastUpdatedIgnored) != KAdditionsFacilityStatus_Active)1329 return false;1330 1331 if (!m_comGuest.isOk())1332 return false;1333 1334 QString strGAVersion = m_comGuest.GetAdditionsVersion();1335 if (m_comGuest.isOk())1336 return (RTStrVersionCompare(strGAVersion.toUtf8().constData(), pszMinimumVersion) >= 0);1337 1338 return false;1339 }1340 1341 void UIVMActivityMonitor::enableDisableGuestAdditionDependedWidgets(bool fEnable)1342 {1343 for (QMap<QString, UIMetric>::const_iterator iterator = m_metrics.begin();1344 iterator != m_metrics.end(); ++iterator)1345 {1346 if (!iterator.value().requiresGuestAdditions())1347 continue;1348 if (m_charts.contains(iterator.key()) && m_charts[iterator.key()])1349 m_charts[iterator.key()]->setIsAvailable(fEnable);1350 if (m_infoLabels.contains(iterator.key()) && m_infoLabels[iterator.key()])1351 {1352 m_infoLabels[iterator.key()]->setEnabled(fEnable);1353 m_infoLabels[iterator.key()]->update();1354 }1355 }1356 }1357 1358 void UIVMActivityMonitor::updateCPUGraphsAndMetric(ULONG iExecutingPercentage, ULONG iOtherPercentage)1359 {1360 UIMetric &CPUMetric = m_metrics[m_strCPUMetricName];1361 CPUMetric.addData(0, iExecutingPercentage);1362 CPUMetric.addData(1, iOtherPercentage);1363 CPUMetric.setMaximum(100);1364 if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName])1365 {1366 QString strInfo;1367 1368 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4%5</font><br/><font color=\"%6\">%7: %8%9</font>")1369 .arg(m_strCPUInfoLabelTitle)1370 .arg(dataColorString(m_strCPUMetricName, 0))1371 .arg(m_strCPUInfoLabelGuest).arg(QString::number(iExecutingPercentage)).arg(CPUMetric.unit())1372 .arg(dataColorString(m_strCPUMetricName, 1))1373 .arg(m_strCPUInfoLabelVMM).arg(QString::number(iOtherPercentage)).arg(CPUMetric.unit());1374 m_infoLabels[m_strCPUMetricName]->setText(strInfo);1375 }1376 1377 if (m_charts.contains(m_strCPUMetricName))1378 m_charts[m_strCPUMetricName]->update();1379 }1380 1381 void UIVMActivityMonitor::updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM)1382 {1383 UIMetric &RAMMetric = m_metrics[m_strRAMMetricName];1384 RAMMetric.setMaximum(iTotalRAM);1385 RAMMetric.addData(0, iTotalRAM - iFreeRAM);1386 if (m_infoLabels.contains(m_strRAMMetricName) && m_infoLabels[m_strRAMMetricName])1387 {1388 QString strInfo;1389 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg(UITranslator::formatSize(_1K * iTotalRAM, g_iDecimalCount))1390 .arg(m_strRAMInfoLabelFree).arg(UITranslator::formatSize(_1K * (iFreeRAM), g_iDecimalCount))1391 .arg(m_strRAMInfoLabelUsed).arg(UITranslator::formatSize(_1K * (iTotalRAM - iFreeRAM), g_iDecimalCount));1392 m_infoLabels[m_strRAMMetricName]->setText(strInfo);1393 }1394 if (m_charts.contains(m_strRAMMetricName))1395 m_charts[m_strRAMMetricName]->update();1396 }1397 1398 void UIVMActivityMonitor::updateNetworkGraphsAndMetric(quint64 iReceiveTotal, quint64 iTransmitTotal)1399 {1400 UIMetric &NetMetric = m_metrics[m_strNetworkMetricName];1401 1402 quint64 iReceiveRate = iReceiveTotal - NetMetric.total(0);1403 quint64 iTransmitRate = iTransmitTotal - NetMetric.total(1);1404 1405 NetMetric.setTotal(0, iReceiveTotal);1406 NetMetric.setTotal(1, iTransmitTotal);1407 1408 if (!NetMetric.isInitialized())1409 {1410 NetMetric.setIsInitialized(true);1411 return;1412 }1413 1414 NetMetric.addData(0, iReceiveRate);1415 NetMetric.addData(1, iTransmitRate);1416 1417 if (m_infoLabels.contains(m_strNetworkMetricName) && m_infoLabels[m_strNetworkMetricName])1418 {1419 QString strInfo;1420 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>")1421 .arg(m_strNetworkInfoLabelTitle)1422 .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg(UITranslator::formatSize((quint64)iReceiveRate, g_iDecimalCount))1423 .arg(m_strNetworkInfoLabelReceivedTotal).arg(UITranslator::formatSize((quint64)iReceiveTotal, g_iDecimalCount))1424 .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg(UITranslator::formatSize((quint64)iTransmitRate, g_iDecimalCount))1425 .arg(m_strNetworkInfoLabelTransmittedTotal).arg(UITranslator::formatSize((quint64)iTransmitTotal, g_iDecimalCount));1426 m_infoLabels[m_strNetworkMetricName]->setText(strInfo);1427 }1428 if (m_charts.contains(m_strNetworkMetricName))1429 m_charts[m_strNetworkMetricName]->update();1430 1108 } 1431 1109 … … 1468 1146 } 1469 1147 1470 void UIVMActivityMonitor::resetVMExitInfoLabel()1471 {1472 if (m_infoLabels.contains(m_strVMExitMetricName) && m_infoLabels[m_strVMExitMetricName])1473 {1474 QString strInfo;1475 strInfo = QString("<b>%1</b></b><br/>%2: %3<br/>%4: %5")1476 .arg(m_strVMExitInfoLabelTitle)1477 .arg(m_strVMExitLabelCurrent).arg("--")1478 .arg(m_strVMExitLabelTotal).arg("--");1479 1480 m_infoLabels[m_strVMExitMetricName]->setText(strInfo);1481 }1482 }1483 1484 1148 void UIVMActivityMonitor::resetDiskIOInfoLabel() 1485 1149 { … … 1496 1160 } 1497 1161 1498 void UIVMActivityMonitor::updateDiskIOGraphsAndMetric(quint64 uDiskIOTotalWritten, quint64 uDiskIOTotalRead)1499 {1500 UIMetric &diskMetric = m_metrics[m_strDiskIOMetricName];1501 1502 quint64 iWriteRate = uDiskIOTotalWritten - diskMetric.total(0);1503 quint64 iReadRate = uDiskIOTotalRead - diskMetric.total(1);1504 1505 diskMetric.setTotal(0, uDiskIOTotalWritten);1506 diskMetric.setTotal(1, uDiskIOTotalRead);1507 1508 /* Do not set data and maximum if the metric has not been initialized since we need to initialize totals "(t-1)" first: */1509 if (!diskMetric.isInitialized()){1510 diskMetric.setIsInitialized(true);1511 return;1512 }1513 diskMetric.addData(0, iWriteRate);1514 diskMetric.addData(1, iReadRate);1515 1516 if (m_infoLabels.contains(m_strDiskIOMetricName) && m_infoLabels[m_strDiskIOMetricName])1517 {1518 QString strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>")1519 .arg(m_strDiskIOInfoLabelTitle)1520 .arg(dataColorString(m_strDiskIOMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg(UITranslator::formatSize((quint64)iWriteRate, g_iDecimalCount))1521 .arg(m_strDiskIOInfoLabelWrittenTotal).arg(UITranslator::formatSize((quint64)uDiskIOTotalWritten, g_iDecimalCount))1522 .arg(dataColorString(m_strDiskIOMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg(UITranslator::formatSize((quint64)iReadRate, g_iDecimalCount))1523 .arg(m_strDiskIOInfoLabelReadTotal).arg(UITranslator::formatSize((quint64)uDiskIOTotalRead, g_iDecimalCount));1524 m_infoLabels[m_strDiskIOMetricName]->setText(strInfo);1525 }1526 if (m_charts.contains(m_strDiskIOMetricName))1527 m_charts[m_strDiskIOMetricName]->update();1528 }1529 1530 void UIVMActivityMonitor::updateVMExitMetric(quint64 uTotalVMExits)1531 {1532 if (uTotalVMExits <= 0)1533 return;1534 1535 UIMetric &VMExitMetric = m_metrics[m_strVMExitMetricName];1536 quint64 iRate = uTotalVMExits - VMExitMetric.total(0);1537 VMExitMetric.setTotal(0, uTotalVMExits);1538 /* Do not set data and maximum if the metric has not been initialized since we need to initialize totals "(t-1)" first: */1539 if (!VMExitMetric.isInitialized())1540 {1541 VMExitMetric.setIsInitialized(true);1542 return;1543 }1544 VMExitMetric.addData(0, iRate);1545 if (m_infoLabels.contains(m_strVMExitMetricName) && m_infoLabels[m_strVMExitMetricName])1546 {1547 QString strInfo;1548 strInfo = QString("<b>%1</b></b><br/>%2: %3 %4<br/>%5: %6 %7")1549 .arg(m_strVMExitInfoLabelTitle)1550 .arg(m_strVMExitLabelCurrent).arg(UITranslator::addMetricSuffixToNumber(iRate)).arg(VMExitMetric.unit())1551 .arg(m_strVMExitLabelTotal).arg(UITranslator::addMetricSuffixToNumber(uTotalVMExits)).arg(VMExitMetric.unit());1552 m_infoLabels[m_strVMExitMetricName]->setText(strInfo);1553 }1554 if (m_charts.contains(m_strVMExitMetricName))1555 m_charts[m_strVMExitMetricName]->update();1556 }1557 1558 1162 QString UIVMActivityMonitor::dataColorString(const QString &strChartName, int iDataIndex) 1559 1163 { … … 1566 1170 } 1567 1171 1568 void UIVMActivityMonitor::reset() 1172 void UIVMActivityMonitorLocal::start() 1173 { 1174 if (m_comMachine.isNull() || m_comMachine.GetState() != KMachineState_Running) 1175 return; 1176 1177 m_fGuestAdditionsAvailable = guestAdditionsAvailable("6.1"); 1178 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable); 1179 if (m_pTimer) 1180 m_pTimer->start(1000 * g_iPeriod); 1181 } 1182 1183 UIVMActivityMonitorLocal::UIVMActivityMonitorLocal(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine) 1184 :UIVMActivityMonitor(enmEmbedding, pParent) 1185 , m_fGuestAdditionsAvailable(false) 1186 { 1187 prepareMetrics(); 1188 prepareWidgets(); 1189 prepareActions(); 1190 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, this, &UIVMActivityMonitorLocal::sltMachineStateChange); 1191 connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UIVMActivityMonitorLocal::sltClearCOMData); 1192 setMachine(machine); 1193 } 1194 1195 UIVMActivityMonitorLocal::~UIVMActivityMonitorLocal() 1196 { 1197 sltClearCOMData(); 1198 } 1199 1200 QUuid UIVMActivityMonitorLocal::machineId() const 1201 { 1202 if (m_comMachine.isNull()) 1203 return QUuid(); 1204 return m_comMachine.GetId(); 1205 } 1206 1207 void UIVMActivityMonitorLocal::retranslateUi() 1208 { 1209 UIVMActivityMonitor::retranslateUi(); 1210 m_strVMExitInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "VM Exits"); 1211 //iMaximum = qMax(iMaximum, m_strVMExitInfoLabelTitle.length()); 1212 m_strVMExitLabelCurrent = QApplication::translate("UIVMInformationDialog", "Current"); 1213 //iMaximum = qMax(iMaximum, m_strVMExitLabelCurrent.length()); 1214 m_strVMExitLabelTotal = QApplication::translate("UIVMInformationDialog", "Total"); 1215 //iMaximum = qMax(iMaximum, m_strVMExitLabelTotal.length()); 1216 } 1217 1218 void UIVMActivityMonitorLocal::setMachine(const CMachine &comMachine) 1219 { 1220 reset(); 1221 if (comMachine.isNull()) 1222 return; 1223 1224 if (!m_comSession.isNull()) 1225 m_comSession.UnlockMachine(); 1226 1227 m_comMachine = comMachine; 1228 1229 if (m_comMachine.GetState() == KMachineState_Running) 1230 { 1231 setEnabled(true); 1232 openSession(); 1233 start(); 1234 } 1235 } 1236 1237 QString UIVMActivityMonitorLocal::machineName() const 1238 { 1239 if (m_comMachine.isNull()) 1240 return QString(); 1241 return m_comMachine.GetName(); 1242 } 1243 1244 void UIVMActivityMonitorLocal::openSession() 1245 { 1246 if (!m_comSession.isNull()) 1247 return; 1248 m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared); 1249 AssertReturnVoid(!m_comSession.isNull()); 1250 1251 CConsole comConsole = m_comSession.GetConsole(); 1252 AssertReturnVoid(!comConsole.isNull()); 1253 m_comGuest = comConsole.GetGuest(); 1254 1255 m_comMachineDebugger = comConsole.GetDebugger(); 1256 } 1257 1258 void UIVMActivityMonitorLocal::obtainDataAndUpdate() 1259 { 1260 if (m_performanceCollector.isNull()) 1261 return; 1262 ++m_iTimeStep; 1263 1264 if (m_metrics.contains(m_strRAMMetricName)) 1265 { 1266 quint64 iTotalRAM = 0; 1267 quint64 iFreeRAM = 0; 1268 UIMonitorCommon::getRAMLoad(m_performanceCollector, m_nameList, m_objectList, iTotalRAM, iFreeRAM); 1269 updateRAMGraphsAndMetric(iTotalRAM, iFreeRAM); 1270 } 1271 1272 /* Update the CPU load chart with values we get from IMachineDebugger::getCPULoad(..): */ 1273 if (m_metrics.contains(m_strCPUMetricName)) 1274 { 1275 ULONG aPctExecuting; 1276 ULONG aPctHalted; 1277 ULONG aPctOther; 1278 m_comMachineDebugger.GetCPULoad(0x7fffffff, aPctExecuting, aPctHalted, aPctOther); 1279 updateCPUGraphsAndMetric(aPctExecuting, aPctOther); 1280 } 1281 1282 /* Update the network load chart with values we find under /Public/NetAdapter/: */ 1283 { 1284 quint64 cbNetworkTotalReceived = 0; 1285 quint64 cbNetworkTotalTransmitted = 0; 1286 UIMonitorCommon::getNetworkLoad(m_comMachineDebugger, cbNetworkTotalReceived, cbNetworkTotalTransmitted); 1287 updateNetworkGraphsAndMetric(cbNetworkTotalReceived, cbNetworkTotalTransmitted); 1288 } 1289 1290 /* Update the Disk I/O chart with values we find under /Public/Storage/?/Port?/Bytes*: */ 1291 { 1292 quint64 cbDiskIOTotalWritten = 0; 1293 quint64 cbDiskIOTotalRead = 0; 1294 UIMonitorCommon::getDiskLoad(m_comMachineDebugger, cbDiskIOTotalWritten, cbDiskIOTotalRead); 1295 updateDiskIOGraphsAndMetric(cbDiskIOTotalWritten, cbDiskIOTotalRead); 1296 } 1297 1298 /* Update the VM exit chart with values we find as /PROF/CPU?/EM/RecordedExits: */ 1299 { 1300 quint64 cTotalVMExits = 0; 1301 UIMonitorCommon::getVMMExitCount(m_comMachineDebugger, cTotalVMExits); 1302 updateVMExitMetric(cTotalVMExits); 1303 } 1304 } 1305 1306 void UIVMActivityMonitorLocal::sltMachineStateChange(const QUuid &uId) 1307 { 1308 if (m_comMachine.isNull()) 1309 return; 1310 if (m_comMachine.GetId() != uId) 1311 return; 1312 if (m_comMachine.GetState() == KMachineState_Running) 1313 { 1314 setEnabled(true); 1315 openSession(); 1316 start(); 1317 } 1318 else if (m_comMachine.GetState() == KMachineState_Paused) 1319 { 1320 /* If we are already active then stop: */ 1321 if (!m_comSession.isNull() && m_pTimer && m_pTimer->isActive()) 1322 m_pTimer->stop(); 1323 } 1324 else 1325 reset(); 1326 } 1327 1328 QString UIVMActivityMonitorLocal::defaultMachineFolder() const 1329 { 1330 if (m_comMachine.isOk()) 1331 return m_comMachine.GetSettingsFilePath(); 1332 else 1333 return QString(); 1334 } 1335 1336 void UIVMActivityMonitorLocal::sltGuestAdditionsStateChange() 1337 { 1338 bool fGuestAdditionsAvailable = guestAdditionsAvailable("6.1"); 1339 if (m_fGuestAdditionsAvailable == fGuestAdditionsAvailable) 1340 return; 1341 m_fGuestAdditionsAvailable = fGuestAdditionsAvailable; 1342 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable); 1343 } 1344 1345 void UIVMActivityMonitorLocal::sltClearCOMData() 1346 { 1347 if (!m_comSession.isNull()) 1348 { 1349 m_comSession.UnlockMachine(); 1350 m_comSession.detach(); 1351 } 1352 } 1353 1354 void UIVMActivityMonitorLocal::reset() 1569 1355 { 1570 1356 m_fGuestAdditionsAvailable = false; … … 1591 1377 } 1592 1378 1593 void UIVMActivityMonitor::start() 1594 { 1595 if (m_comMachine.isNull() || m_comMachine.GetState() != KMachineState_Running) 1596 return; 1597 1598 m_fGuestAdditionsAvailable = guestAdditionsAvailable("6.1"); 1599 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable); 1600 if (m_pTimer) 1601 m_pTimer->start(1000 * g_iPeriod); 1379 void UIVMActivityMonitorLocal::prepareMetrics() 1380 { 1381 m_performanceCollector = uiCommon().virtualBox().GetPerformanceCollector(); 1382 if (m_performanceCollector.isNull()) 1383 return; 1384 1385 m_nameList << "Guest/RAM/Usage*"; 1386 m_objectList = QVector<CUnknown>(m_nameList.size(), CUnknown()); 1387 m_performanceCollector.SetupMetrics(m_nameList, m_objectList, g_iPeriod, g_iMetricSetupCount); 1388 { 1389 QVector<CPerformanceMetric> metrics = m_performanceCollector.GetMetrics(m_nameList, m_objectList); 1390 for (int i = 0; i < metrics.size(); ++i) 1391 { 1392 QString strName(metrics[i].GetMetricName()); 1393 if (!strName.contains(':')) 1394 { 1395 if (strName.contains("RAM", Qt::CaseInsensitive) && strName.contains("Free", Qt::CaseInsensitive)) 1396 { 1397 UIMetric ramMetric(m_strRAMMetricName, metrics[i].GetUnit(), g_iMaximumQueueSize); 1398 ramMetric.setDataSeriesName(0, "Free"); 1399 ramMetric.setDataSeriesName(1, "Used"); 1400 ramMetric.setRequiresGuestAdditions(true); 1401 m_metrics.insert(m_strRAMMetricName, ramMetric); 1402 } 1403 } 1404 } 1405 } 1406 1407 /* CPU Metric: */ 1408 UIMetric cpuMetric(m_strCPUMetricName, "%", g_iMaximumQueueSize); 1409 cpuMetric.setDataSeriesName(0, "Guest Load"); 1410 cpuMetric.setDataSeriesName(1, "VMM Load"); 1411 m_metrics.insert(m_strCPUMetricName, cpuMetric); 1412 1413 /* Network metric: */ 1414 UIMetric networkMetric(m_strNetworkMetricName, "B", g_iMaximumQueueSize); 1415 networkMetric.setDataSeriesName(0, "Receive Rate"); 1416 networkMetric.setDataSeriesName(1, "Transmit Rate"); 1417 networkMetric.setAutoUpdateMaximum(true); 1418 m_metrics.insert(m_strNetworkMetricName, networkMetric); 1419 1420 /* Disk IO metric */ 1421 UIMetric diskIOMetric(m_strDiskIOMetricName, "B", g_iMaximumQueueSize); 1422 diskIOMetric.setDataSeriesName(0, "Write Rate"); 1423 diskIOMetric.setDataSeriesName(1, "Read Rate"); 1424 diskIOMetric.setAutoUpdateMaximum(true); 1425 m_metrics.insert(m_strDiskIOMetricName, diskIOMetric); 1426 1427 /* VM exits metric */ 1428 UIMetric VMExitsMetric(m_strVMExitMetricName, "times", g_iMaximumQueueSize); 1429 VMExitsMetric.setAutoUpdateMaximum(true); 1430 m_metrics.insert(m_strVMExitMetricName, VMExitsMetric); 1431 } 1432 1433 bool UIVMActivityMonitorLocal::guestAdditionsAvailable(const char *pszMinimumVersion) 1434 { 1435 if (m_comGuest.isNull() || !pszMinimumVersion) 1436 return false; 1437 1438 /* Guest control stuff is in userland: */ 1439 if (!m_comGuest.GetAdditionsStatus(KAdditionsRunLevelType_Userland)) 1440 return false; 1441 1442 if (!m_comGuest.isOk()) 1443 return false; 1444 1445 /* Check the related GA facility: */ 1446 LONG64 iLastUpdatedIgnored; 1447 if (m_comGuest.GetFacilityStatus(KAdditionsFacilityType_VBoxService, iLastUpdatedIgnored) != KAdditionsFacilityStatus_Active) 1448 return false; 1449 1450 if (!m_comGuest.isOk()) 1451 return false; 1452 1453 QString strGAVersion = m_comGuest.GetAdditionsVersion(); 1454 if (m_comGuest.isOk()) 1455 return (RTStrVersionCompare(strGAVersion.toUtf8().constData(), pszMinimumVersion) >= 0); 1456 1457 return false; 1458 } 1459 1460 void UIVMActivityMonitorLocal::enableDisableGuestAdditionDependedWidgets(bool fEnable) 1461 { 1462 for (QMap<QString, UIMetric>::const_iterator iterator = m_metrics.begin(); 1463 iterator != m_metrics.end(); ++iterator) 1464 { 1465 if (!iterator.value().requiresGuestAdditions()) 1466 continue; 1467 if (m_charts.contains(iterator.key()) && m_charts[iterator.key()]) 1468 m_charts[iterator.key()]->setIsAvailable(fEnable); 1469 if (m_infoLabels.contains(iterator.key()) && m_infoLabels[iterator.key()]) 1470 { 1471 m_infoLabels[iterator.key()]->setEnabled(fEnable); 1472 m_infoLabels[iterator.key()]->update(); 1473 } 1474 } 1475 } 1476 1477 void UIVMActivityMonitorLocal::updateVMExitMetric(quint64 uTotalVMExits) 1478 { 1479 if (uTotalVMExits <= 0) 1480 return; 1481 1482 UIMetric &VMExitMetric = m_metrics[m_strVMExitMetricName]; 1483 quint64 iRate = uTotalVMExits - VMExitMetric.total(0); 1484 VMExitMetric.setTotal(0, uTotalVMExits); 1485 /* Do not set data and maximum if the metric has not been initialized since we need to initialize totals "(t-1)" first: */ 1486 if (!VMExitMetric.isInitialized()) 1487 { 1488 VMExitMetric.setIsInitialized(true); 1489 return; 1490 } 1491 VMExitMetric.addData(0, iRate); 1492 if (m_infoLabels.contains(m_strVMExitMetricName) && m_infoLabels[m_strVMExitMetricName]) 1493 { 1494 QString strInfo; 1495 strInfo = QString("<b>%1</b></b><br/>%2: %3 %4<br/>%5: %6 %7") 1496 .arg(m_strVMExitInfoLabelTitle) 1497 .arg(m_strVMExitLabelCurrent).arg(UITranslator::addMetricSuffixToNumber(iRate)).arg(VMExitMetric.unit()) 1498 .arg(m_strVMExitLabelTotal).arg(UITranslator::addMetricSuffixToNumber(uTotalVMExits)).arg(VMExitMetric.unit()); 1499 m_infoLabels[m_strVMExitMetricName]->setText(strInfo); 1500 } 1501 if (m_charts.contains(m_strVMExitMetricName)) 1502 m_charts[m_strVMExitMetricName]->update(); 1503 } 1504 1505 void UIVMActivityMonitorLocal::updateCPUGraphsAndMetric(ULONG iExecutingPercentage, ULONG iOtherPercentage) 1506 { 1507 UIMetric &CPUMetric = m_metrics[m_strCPUMetricName]; 1508 CPUMetric.addData(0, iExecutingPercentage); 1509 CPUMetric.addData(1, iOtherPercentage); 1510 CPUMetric.setMaximum(100); 1511 if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName]) 1512 { 1513 QString strInfo; 1514 1515 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4%5</font><br/><font color=\"%6\">%7: %8%9</font>") 1516 .arg(m_strCPUInfoLabelTitle) 1517 .arg(dataColorString(m_strCPUMetricName, 0)) 1518 .arg(m_strCPUInfoLabelGuest).arg(QString::number(iExecutingPercentage)).arg(CPUMetric.unit()) 1519 .arg(dataColorString(m_strCPUMetricName, 1)) 1520 .arg(m_strCPUInfoLabelVMM).arg(QString::number(iOtherPercentage)).arg(CPUMetric.unit()); 1521 m_infoLabels[m_strCPUMetricName]->setText(strInfo); 1522 } 1523 1524 if (m_charts.contains(m_strCPUMetricName)) 1525 m_charts[m_strCPUMetricName]->update(); 1526 } 1527 1528 void UIVMActivityMonitorLocal::updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM) 1529 { 1530 UIMetric &RAMMetric = m_metrics[m_strRAMMetricName]; 1531 RAMMetric.setMaximum(iTotalRAM); 1532 RAMMetric.addData(0, iTotalRAM - iFreeRAM); 1533 if (m_infoLabels.contains(m_strRAMMetricName) && m_infoLabels[m_strRAMMetricName]) 1534 { 1535 QString strInfo; 1536 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg(UITranslator::formatSize(_1K * iTotalRAM, g_iDecimalCount)) 1537 .arg(m_strRAMInfoLabelFree).arg(UITranslator::formatSize(_1K * (iFreeRAM), g_iDecimalCount)) 1538 .arg(m_strRAMInfoLabelUsed).arg(UITranslator::formatSize(_1K * (iTotalRAM - iFreeRAM), g_iDecimalCount)); 1539 m_infoLabels[m_strRAMMetricName]->setText(strInfo); 1540 } 1541 if (m_charts.contains(m_strRAMMetricName)) 1542 m_charts[m_strRAMMetricName]->update(); 1543 } 1544 1545 void UIVMActivityMonitorLocal::updateNetworkGraphsAndMetric(quint64 iReceiveTotal, quint64 iTransmitTotal) 1546 { 1547 UIMetric &NetMetric = m_metrics[m_strNetworkMetricName]; 1548 1549 quint64 iReceiveRate = iReceiveTotal - NetMetric.total(0); 1550 quint64 iTransmitRate = iTransmitTotal - NetMetric.total(1); 1551 1552 NetMetric.setTotal(0, iReceiveTotal); 1553 NetMetric.setTotal(1, iTransmitTotal); 1554 1555 if (!NetMetric.isInitialized()) 1556 { 1557 NetMetric.setIsInitialized(true); 1558 return; 1559 } 1560 1561 NetMetric.addData(0, iReceiveRate); 1562 NetMetric.addData(1, iTransmitRate); 1563 1564 if (m_infoLabels.contains(m_strNetworkMetricName) && m_infoLabels[m_strNetworkMetricName]) 1565 { 1566 QString strInfo; 1567 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1568 .arg(m_strNetworkInfoLabelTitle) 1569 .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg(UITranslator::formatSize((quint64)iReceiveRate, g_iDecimalCount)) 1570 .arg(m_strNetworkInfoLabelReceivedTotal).arg(UITranslator::formatSize((quint64)iReceiveTotal, g_iDecimalCount)) 1571 .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg(UITranslator::formatSize((quint64)iTransmitRate, g_iDecimalCount)) 1572 .arg(m_strNetworkInfoLabelTransmittedTotal).arg(UITranslator::formatSize((quint64)iTransmitTotal, g_iDecimalCount)); 1573 m_infoLabels[m_strNetworkMetricName]->setText(strInfo); 1574 } 1575 if (m_charts.contains(m_strNetworkMetricName)) 1576 m_charts[m_strNetworkMetricName]->update(); 1577 } 1578 1579 void UIVMActivityMonitorLocal::updateDiskIOGraphsAndMetric(quint64 uDiskIOTotalWritten, quint64 uDiskIOTotalRead) 1580 { 1581 UIMetric &diskMetric = m_metrics[m_strDiskIOMetricName]; 1582 1583 quint64 iWriteRate = uDiskIOTotalWritten - diskMetric.total(0); 1584 quint64 iReadRate = uDiskIOTotalRead - diskMetric.total(1); 1585 1586 diskMetric.setTotal(0, uDiskIOTotalWritten); 1587 diskMetric.setTotal(1, uDiskIOTotalRead); 1588 1589 /* Do not set data and maximum if the metric has not been initialized since we need to initialize totals "(t-1)" first: */ 1590 if (!diskMetric.isInitialized()){ 1591 diskMetric.setIsInitialized(true); 1592 return; 1593 } 1594 diskMetric.addData(0, iWriteRate); 1595 diskMetric.addData(1, iReadRate); 1596 1597 if (m_infoLabels.contains(m_strDiskIOMetricName) && m_infoLabels[m_strDiskIOMetricName]) 1598 { 1599 QString strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1600 .arg(m_strDiskIOInfoLabelTitle) 1601 .arg(dataColorString(m_strDiskIOMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg(UITranslator::formatSize((quint64)iWriteRate, g_iDecimalCount)) 1602 .arg(m_strDiskIOInfoLabelWrittenTotal).arg(UITranslator::formatSize((quint64)uDiskIOTotalWritten, g_iDecimalCount)) 1603 .arg(dataColorString(m_strDiskIOMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg(UITranslator::formatSize((quint64)iReadRate, g_iDecimalCount)) 1604 .arg(m_strDiskIOInfoLabelReadTotal).arg(UITranslator::formatSize((quint64)uDiskIOTotalRead, g_iDecimalCount)); 1605 m_infoLabels[m_strDiskIOMetricName]->setText(strInfo); 1606 } 1607 if (m_charts.contains(m_strDiskIOMetricName)) 1608 m_charts[m_strDiskIOMetricName]->update(); 1609 } 1610 1611 void UIVMActivityMonitorLocal::resetVMExitInfoLabel() 1612 { 1613 if (m_infoLabels.contains(m_strVMExitMetricName) && m_infoLabels[m_strVMExitMetricName]) 1614 { 1615 QString strInfo; 1616 strInfo = QString("<b>%1</b></b><br/>%2: %3<br/>%4: %5") 1617 .arg(m_strVMExitInfoLabelTitle) 1618 .arg(m_strVMExitLabelCurrent).arg("--") 1619 .arg(m_strVMExitLabelTotal).arg("--"); 1620 1621 m_infoLabels[m_strVMExitMetricName]->setText(strInfo); 1622 } 1602 1623 } 1603 1624 -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h ¶
r100174 r102147 134 134 public: 135 135 136 /** Constructs information-tab passing @a pParent to the QWidget base-class constructor. 137 * @param machine is machine reference. */ 138 UIVMActivityMonitor(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine); 139 ~UIVMActivityMonitor(); 140 void setMachine(const CMachine &machine); 141 QUuid machineId() const; 142 QString machineName() const; 143 144 public slots: 145 146 /** @name These functions are connected to API events and implement necessary updates. 147 * @{ */ 148 void sltGuestAdditionsStateChange(); 149 /** @} */ 136 UIVMActivityMonitor(EmbedTo enmEmbedding, QWidget *pParent); 137 virtual QUuid machineId() const = 0; 138 virtual QString machineName() const = 0; 139 140 public slots: 141 150 142 void sltExportMetricsToFile(); 151 143 … … 154 146 virtual void retranslateUi() RT_OVERRIDE; 155 147 virtual bool eventFilter(QObject *pObj, QEvent *pEvent) RT_OVERRIDE; 156 157 private slots: 158 159 /** Reads the metric values for several sources and calls corresponding update functions. */ 160 void sltTimeout(); 161 /** Stop updating the charts if/when the machine state changes something other than KMachineState_Running. */ 162 void sltMachineStateChange(const QUuid &uId); 163 void sltCreateContextMenu(const QPoint &point); 164 void sltClearCOMData(); 165 166 private: 167 168 void prepareWidgets(); 169 void prepareMetrics(); 170 void prepareActions(); 171 bool guestAdditionsAvailable(const char *pszMinimumVersion); 172 void enableDisableGuestAdditionDependedWidgets(bool fEnable); 148 virtual void obtainDataAndUpdate() = 0; 149 virtual QString defaultMachineFolder() const = 0; 150 virtual void reset() = 0; 151 virtual void start() = 0; 173 152 174 153 /** @name The following functions update corresponding metric charts and labels with new values 175 154 * @{ */ 176 void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage); 177 void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM); 178 void updateNetworkGraphsAndMetric(quint64 iReceiveTotal, quint64 iTransmitTotal); 179 void updateDiskIOGraphsAndMetric(quint64 uDiskIOTotalWritten, quint64 uDiskIOTotalRead); 180 void updateVMExitMetric(quint64 uTotalVMExits); 181 /** @} */ 155 virtual void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage) = 0; 156 virtual void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM) = 0; 157 virtual void updateNetworkGraphsAndMetric(quint64 iReceiveTotal, quint64 iTransmitTotal) = 0; 158 virtual void updateDiskIOGraphsAndMetric(quint64 uDiskIOTotalWritten, quint64 uDiskIOTotalRead) = 0; 159 /** @} */ 160 161 /** Returns a QColor for the chart with @p strChartName and data series with @p iDataIndex. */ 162 QString dataColorString(const QString &strChartName, int iDataIndex); 182 163 183 164 /** @name The following functions reset corresponding info labels … … 187 168 void resetNetworkInfoLabel(); 188 169 void resetDiskIOInfoLabel(); 189 void resetVMExitInfoLabel(); 190 /** @} */ 191 192 /** Returns a QColor for the chart with @p strChartName and data series with @p iDataIndex. */ 193 QString dataColorString(const QString &strChartName, int iDataIndex); 194 /* Starts the timer which in return collects data and updates charts/graphs. */ 195 void start(); 196 void reset(); 197 void openSession(); 198 199 bool m_fGuestAdditionsAvailable; 200 CMachine m_comMachine; 201 CSession m_comSession; 202 CGuest m_comGuest; 203 204 CPerformanceCollector m_performanceCollector; 205 CMachineDebugger m_comMachineDebugger; 206 /** Holds the instance of layout we create. */ 207 QVBoxLayout *m_pMainLayout; 208 QTimer *m_pTimer; 209 210 /** @name The following are used during UIPerformanceCollector::QueryMetricsData(..) 211 * @{ */ 212 QVector<QString> m_nameList; 213 QVector<CUnknown> m_objectList; 214 /** @} */ 215 170 /** @} */ 171 172 void prepareWidgets(); 173 void prepareActions(); 174 175 QTimer *m_pTimer; 176 quint64 m_iTimeStep; 216 177 QMap<QString, UIMetric> m_metrics; 217 QMap<QString,UIChart*> m_charts;218 /** Stores the QLabel instances which we show next to each UIChart. The value is the name of the metric. */219 QMap<QString,QLabel*> m_infoLabels;220 178 221 179 /** @name These metric names are used for map keys to identify metrics. They are not translated. … … 228 186 QString m_strVMExitMetricName; 229 187 /** @} */ 188 189 /** @name The following are used during UIPerformanceCollector::QueryMetricsData(..) 190 * @{ */ 191 QVector<QString> m_nameList; 192 QVector<CUnknown> m_objectList; 193 /** @} */ 194 QMap<QString,UIChart*> m_charts; 195 /** Stores the QLabel instances which we show next to each UIChart. The value is the name of the metric. */ 196 QMap<QString,QLabel*> m_infoLabels; 230 197 231 198 /** @name Cached translated strings. … … 252 219 QString m_strDiskIOInfoLabelWrittenTotal; 253 220 QString m_strDiskIOInfoLabelReadTotal; 254 /** VM Exit info label strings. */ 255 QString m_strVMExitInfoLabelTitle; 256 QString m_strVMExitLabelCurrent; 257 QString m_strVMExitLabelTotal; 258 /** @} */ 259 quint64 m_iTimeStep; 221 /** @} */ 222 223 224 private slots: 225 226 /** Reads the metric values for several sources and calls corresponding update functions. */ 227 void sltTimeout(); 228 void sltCreateContextMenu(const QPoint &point); 229 230 private: 231 232 bool guestAdditionsAvailable(const char *pszMinimumVersion); 233 234 /** Holds the instance of layout we create. */ 235 QVBoxLayout *m_pMainLayout; 236 260 237 EmbedTo m_enmEmbedding; 261 238 }; 262 239 240 class SHARED_LIBRARY_STUFF UIVMActivityMonitorLocal : public UIVMActivityMonitor 241 { 242 243 Q_OBJECT; 244 245 public: 246 247 /** Constructs information-tab passing @a pParent to the QWidget base-class constructor. 248 * @param machine is machine reference. */ 249 UIVMActivityMonitorLocal(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine); 250 ~UIVMActivityMonitorLocal(); 251 virtual QUuid machineId() const RT_OVERRIDE; 252 virtual QString machineName() const RT_OVERRIDE; 253 254 public slots: 255 256 /** @name These functions are connected to API events and implement necessary updates. 257 * @{ */ 258 void sltGuestAdditionsStateChange(); 259 /** @} */ 260 261 protected: 262 263 virtual void retranslateUi() RT_OVERRIDE; 264 virtual void obtainDataAndUpdate() RT_OVERRIDE; 265 virtual QString defaultMachineFolder() const RT_OVERRIDE; 266 virtual void reset() RT_OVERRIDE; 267 virtual void start() RT_OVERRIDE; 268 269 private slots: 270 271 /** Stop updating the charts if/when the machine state changes something other than KMachineState_Running. */ 272 void sltMachineStateChange(const QUuid &uId); 273 void sltClearCOMData(); 274 275 private: 276 277 void setMachine(const CMachine &machine); 278 void openSession(); 279 void prepareMetrics(); 280 bool guestAdditionsAvailable(const char *pszMinimumVersion); 281 void enableDisableGuestAdditionDependedWidgets(bool fEnable); 282 void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage); 283 void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM); 284 void updateNetworkGraphsAndMetric(quint64 iReceiveTotal, quint64 iTransmitTotal); 285 void updateDiskIOGraphsAndMetric(quint64 uDiskIOTotalWritten, quint64 uDiskIOTotalRead); 286 void updateVMExitMetric(quint64 uTotalVMExits); 287 void resetVMExitInfoLabel(); 288 289 bool m_fGuestAdditionsAvailable; 290 CMachine m_comMachine; 291 CSession m_comSession; 292 CGuest m_comGuest; 293 294 CPerformanceCollector m_performanceCollector; 295 CMachineDebugger m_comMachineDebugger; 296 /** VM Exit info label strings. */ 297 QString m_strVMExitInfoLabelTitle; 298 QString m_strVMExitLabelCurrent; 299 QString m_strVMExitLabelTotal; 300 }; 301 302 class SHARED_LIBRARY_STUFF UIVMActivityMonitorCloud : public QIWithRetranslateUI<UIVMActivityMonitor> 303 { 304 305 Q_OBJECT; 306 307 public: 308 309 310 }; 263 311 #endif /* !FEQT_INCLUDED_SRC_activity_vmactivity_UIVMActivityMonitor_h */ -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp ¶
r100896 r102147 220 220 221 221 /* Create Performance Monitor tab: */ 222 UIVMActivityMonitor *pVMActivityMonitorWidget =223 new UIVMActivityMonitor (EmbedTo_Dialog, this, gpMachine->uisession()->machine());222 UIVMActivityMonitorLocal *pVMActivityMonitorWidget = 223 new UIVMActivityMonitorLocal(EmbedTo_Dialog, this, gpMachine->uisession()->machine()); 224 224 if (pVMActivityMonitorWidget) 225 225 { 226 226 connect(gpMachine, &UIMachine::sigAdditionsStateChange, 227 pVMActivityMonitorWidget, &UIVMActivityMonitor ::sltGuestAdditionsStateChange);227 pVMActivityMonitorWidget, &UIVMActivityMonitorLocal::sltGuestAdditionsStateChange); 228 228 m_tabs.insert(Tabs_ActivityMonitor, pVMActivityMonitorWidget); 229 229 m_pTabWidget->addTab(m_tabs.value(Tabs_ActivityMonitor), QString());
Note:
See TracChangeset
for help on using the changeset viewer.