Changeset 48008 in vbox
- Timestamp:
- Aug 23, 2013 7:36:35 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstCollector.cpp
r45367 r48008 163 163 } 164 164 rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStart, &hostTxStart); 165 if (RT_FAILURE(rc)) 166 { 167 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc); 168 return 1; 169 } 170 171 RTThreadSleep(5000); // Sleep for five seconds 172 173 rc = collector->preCollect(hints, 0); 174 if (RT_FAILURE(rc)) 175 { 176 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 177 return 1; 178 } 179 hostRxStop = hostRxStart; 180 hostTxStop = hostTxStart; 181 rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStop, &hostTxStop); 182 if (RT_FAILURE(rc)) 183 { 184 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc); 185 return 1; 186 } 187 RTPrintf("tstCollector: host network speed = %llu bytes/sec (%llu mbit/sec)\n", 188 speed, speed/(1000000/8)); 189 RTPrintf("tstCollector: host network rx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n", 190 (hostRxStop - hostRxStart)/5, (hostRxStop - hostRxStart)/(5000000/8), 191 (hostRxStop - hostRxStart) * 100 / (speed * 5), 192 (hostRxStop - hostRxStart) * 10000 / (speed * 5) % 100); 193 RTPrintf("tstCollector: host network tx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n\n", 194 (hostTxStop - hostTxStart)/5, (hostTxStop - hostTxStart)/(5000000/8), 195 (hostTxStop - hostTxStart) * 100 / (speed * 5), 196 (hostTxStop - hostTxStart) * 10000 / (speed * 5) % 100); 165 if (rc == VERR_NOT_IMPLEMENTED) 166 RTPrintf("tstCollector: getRawHostNetworkLoad() not implemented, skipping\n"); 167 else 168 { 169 if (RT_FAILURE(rc)) 170 { 171 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc); 172 return 1; 173 } 174 175 RTThreadSleep(5000); // Sleep for five seconds 176 177 rc = collector->preCollect(hints, 0); 178 if (RT_FAILURE(rc)) 179 { 180 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 181 return 1; 182 } 183 hostRxStop = hostRxStart; 184 hostTxStop = hostTxStart; 185 rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStop, &hostTxStop); 186 if (RT_FAILURE(rc)) 187 { 188 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc); 189 return 1; 190 } 191 RTPrintf("tstCollector: host network speed = %llu bytes/sec (%llu mbit/sec)\n", 192 speed, speed/(1000000/8)); 193 RTPrintf("tstCollector: host network rx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n", 194 (hostRxStop - hostRxStart)/5, (hostRxStop - hostRxStart)/(5000000/8), 195 (hostRxStop - hostRxStart) * 100 / (speed * 5), 196 (hostRxStop - hostRxStart) * 10000 / (speed * 5) % 100); 197 RTPrintf("tstCollector: host network tx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n\n", 198 (hostTxStop - hostTxStart)/5, (hostTxStop - hostTxStart)/(5000000/8), 199 (hostTxStop - hostTxStart) * 100 / (speed * 5), 200 (hostTxStop - hostTxStart) * 10000 / (speed * 5) % 100); 201 } 197 202 198 203 return 0; … … 226 231 pm::DiskList disksUsage, disksLoad; 227 232 int rc = collector->getDiskListByFs(FSNAME, disksUsage, disksLoad); 228 if (RT_FAILURE(rc)) 229 { 230 RTPrintf("tstCollector: getDiskListByFs(%s) -> %Rrc\n", FSNAME, rc); 231 return 1; 232 } 233 if (disksUsage.empty()) 234 { 235 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME); 236 return 1; 237 } 238 if (disksLoad.empty()) 239 { 240 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME); 241 return 1; 242 } 243 244 pm::DiskList::iterator it; 245 for (it = disksUsage.begin(); it != disksUsage.end(); ++it) 246 { 247 uint64_t diskSize = 0; 248 rc = collector->getHostDiskSize(it->c_str(), &diskSize); 249 RTPrintf("tstCollector: TESTING - Disk size (%s) = %llu\n", it->c_str(), diskSize); 250 if (RT_FAILURE(rc)) 251 { 252 RTPrintf("tstCollector: getHostDiskSize() -> %Rrc\n", rc); 253 return 1; 254 } 255 } 256 257 for (it = disksLoad.begin(); it != disksLoad.end(); ++it) 258 { 259 RTPrintf("tstCollector: TESTING - Disk utilization (%s), sleeping for 5 sec...\n", it->c_str()); 260 261 hints.collectHostCpuLoad(); 262 rc = collector->preCollect(hints, 0); 263 if (RT_FAILURE(rc)) 264 { 265 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 266 return 1; 267 } 268 rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStart, &totalMsStart); 269 if (RT_FAILURE(rc)) 270 { 271 RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc); 272 return 1; 273 } 274 275 RTThreadSleep(5000); // Sleep for five seconds 276 277 rc = collector->preCollect(hints, 0); 278 if (RT_FAILURE(rc)) 279 { 280 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 281 return 1; 282 } 283 rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStop, &totalMsStop); 284 if (RT_FAILURE(rc)) 285 { 286 RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc); 287 return 1; 288 } 289 RTPrintf("tstCollector: host disk util = %llu msec (%u.%u %%), total = %llu msec\n\n", 290 (diskMsStop - diskMsStart), 291 (unsigned)((diskMsStop - diskMsStart) * 100 / (totalMsStop - totalMsStart)), 292 (unsigned)((diskMsStop - diskMsStart) * 10000 / (totalMsStop - totalMsStart) % 100), 293 totalMsStop - totalMsStart); 233 if (rc == VERR_NOT_IMPLEMENTED) 234 RTPrintf("tstCollector: getDiskListByFs() not implemented, skipping\n"); 235 else 236 { 237 if (RT_FAILURE(rc)) 238 { 239 RTPrintf("tstCollector: getDiskListByFs(%s) -> %Rrc\n", FSNAME, rc); 240 return 1; 241 } 242 if (disksUsage.empty()) 243 { 244 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME); 245 return 1; 246 } 247 if (disksLoad.empty()) 248 { 249 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME); 250 return 1; 251 } 252 253 pm::DiskList::iterator it; 254 for (it = disksUsage.begin(); it != disksUsage.end(); ++it) 255 { 256 uint64_t diskSize = 0; 257 rc = collector->getHostDiskSize(it->c_str(), &diskSize); 258 RTPrintf("tstCollector: TESTING - Disk size (%s) = %llu\n", it->c_str(), diskSize); 259 if (RT_FAILURE(rc)) 260 { 261 RTPrintf("tstCollector: getHostDiskSize() -> %Rrc\n", rc); 262 return 1; 263 } 264 } 265 266 for (it = disksLoad.begin(); it != disksLoad.end(); ++it) 267 { 268 RTPrintf("tstCollector: TESTING - Disk utilization (%s), sleeping for 5 sec...\n", it->c_str()); 269 270 hints.collectHostCpuLoad(); 271 rc = collector->preCollect(hints, 0); 272 if (RT_FAILURE(rc)) 273 { 274 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 275 return 1; 276 } 277 rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStart, &totalMsStart); 278 if (RT_FAILURE(rc)) 279 { 280 RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc); 281 return 1; 282 } 283 284 RTThreadSleep(5000); // Sleep for five seconds 285 286 rc = collector->preCollect(hints, 0); 287 if (RT_FAILURE(rc)) 288 { 289 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 290 return 1; 291 } 292 rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStop, &totalMsStop); 293 if (RT_FAILURE(rc)) 294 { 295 RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc); 296 return 1; 297 } 298 RTPrintf("tstCollector: host disk util = %llu msec (%u.%u %%), total = %llu msec\n\n", 299 (diskMsStop - diskMsStart), 300 (unsigned)((diskMsStop - diskMsStart) * 100 / (totalMsStop - totalMsStart)), 301 (unsigned)((diskMsStop - diskMsStart) * 10000 / (totalMsStop - totalMsStart) % 100), 302 totalMsStop - totalMsStart); 303 } 294 304 } 295 305
Note:
See TracChangeset
for help on using the changeset viewer.