Changeset 36067 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Feb 24, 2011 9:10:09 AM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r35238 r36067 137 137 "Commands:\n" 138 138 "\n" 139 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s "139 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" 140 140 "WARNING: This is a development tool and shall only be used to analyse\n" 141 141 " problems. It is completely unsupported and will change in\n" … … 242 242 " Generates a password hash.\n" 243 243 "\n" 244 : 245 "" 244 : "", 245 (u64Cmd & USAGE_GUESTSTATS) 246 ? " gueststats <vmname>|<uuid> [--interval <seconds>]\n" 247 " Obtains and prints internal guest statistics.\n" 248 " Sets the update interval if specified.\n" 249 "\n" 250 : "" 246 251 ); 247 252 } … … 2018 2023 2019 2024 /** 2025 * Print internal guest statistics or 2026 * set internal guest statistics update interval if specified 2027 */ 2028 int CmdGuestStats(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 2029 { 2030 /* one parameter, guest name */ 2031 if (argc < 1) 2032 return errorSyntax(USAGE_GUESTSTATS, "Missing VM name/UUID"); 2033 2034 /* 2035 * Parse the command. 2036 */ 2037 ULONG aUpdateInterval = 0; 2038 2039 static const RTGETOPTDEF s_aOptions[] = 2040 { 2041 { "--interval", 'i', RTGETOPT_REQ_UINT32 } 2042 }; 2043 2044 int ch; 2045 RTGETOPTUNION ValueUnion; 2046 RTGETOPTSTATE GetState; 2047 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0); 2048 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 2049 { 2050 switch (ch) 2051 { 2052 case 'i': 2053 aUpdateInterval = ValueUnion.u32; 2054 break; 2055 2056 default: 2057 return errorGetOpt(USAGE_GUESTSTATS , ch, &ValueUnion); 2058 } 2059 } 2060 2061 if (argc > 1 && aUpdateInterval == 0) 2062 return errorSyntax(USAGE_GUESTSTATS, "Invalid update interval specified"); 2063 2064 RTPrintf("argc=%d interval=%u\n", argc, aUpdateInterval); 2065 2066 ComPtr<IMachine> ptrMachine; 2067 HRESULT rc; 2068 CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[0]).raw(), 2069 ptrMachine.asOutParam()), 1); 2070 2071 CHECK_ERROR_RET(ptrMachine, LockMachine(aSession, LockType_Shared), 1); 2072 2073 /* 2074 * Get the guest interface. 2075 */ 2076 ComPtr<IConsole> ptrConsole; 2077 CHECK_ERROR_RET(aSession, COMGETTER(Console)(ptrConsole.asOutParam()), 1); 2078 2079 ComPtr<IGuest> ptrGuest; 2080 CHECK_ERROR_RET(ptrConsole, COMGETTER(Guest)(ptrGuest.asOutParam()), 1); 2081 2082 if (aUpdateInterval) 2083 CHECK_ERROR_RET(ptrGuest, COMSETTER(StatisticsUpdateInterval)(aUpdateInterval), 1); 2084 else 2085 { 2086 ULONG mCpuUser, mCpuKernel, mCpuIdle; 2087 ULONG mMemTotal, mMemFree, mMemBalloon, mMemShared, mMemCache, mPageTotal; 2088 ULONG ulMemAllocTotal, ulMemFreeTotal, ulMemBalloonTotal, ulMemSharedTotal; 2089 2090 ptrGuest->InternalGetStatistics(&mCpuUser, &mCpuKernel, &mCpuIdle, 2091 &mMemTotal, &mMemFree, &mMemBalloon, &mMemShared, &mMemCache, 2092 &mPageTotal, &ulMemAllocTotal, &ulMemFreeTotal, &ulMemBalloonTotal, &ulMemSharedTotal); 2093 RTPrintf("mCpuUser=%u mCpuKernel=%u mCpuIdle=%u\n" 2094 "mMemTotal=%u mMemFree=%u mMemBalloon=%u mMemShared=%u mMemCache=%u\n" 2095 "mPageTotal=%u ulMemAllocTotal=%u ulMemFreeTotal=%u ulMemBalloonTotal=%u ulMemSharedTotal=%u\n", 2096 mCpuUser, mCpuKernel, mCpuIdle, 2097 mMemTotal, mMemFree, mMemBalloon, mMemShared, mMemCache, 2098 mPageTotal, ulMemAllocTotal, ulMemFreeTotal, ulMemBalloonTotal, ulMemSharedTotal); 2099 2100 } 2101 2102 return 0; 2103 } 2104 2105 2106 /** 2020 2107 * Wrapper for handling internal commands 2021 2108 */ … … 2058 2145 if (!strcmp(pszCmd, "passwordhash")) 2059 2146 return CmdGeneratePasswordHash(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2147 if (!strcmp(pszCmd, "gueststats")) 2148 return CmdGuestStats(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2060 2149 2061 2150 /* default: */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r35907 r36067 98 98 #define USAGE_EXTPACK RT_BIT_64(55) 99 99 #define USAGE_BANDWIDTHCONTROL RT_BIT_64(56) 100 #define USAGE_GUESTSTATS RT_BIT_64(57) 100 101 #define USAGE_ALL (~(uint64_t)0) 101 102 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.