- Timestamp:
- Nov 29, 2012 8:58:17 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/Performance.h
r43958 r43994 528 528 void init(ULONG period, ULONG length) { mPeriod = period; mLength = length; mLinkSpeed->init(length); }; 529 529 void preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) {}; 530 void collect() { mLinkSpeed->put(mSpeed); };530 void collect() { if (mSpeed) mLinkSpeed->put(mSpeed); }; 531 531 const char *getUnit() { return "mbit/s"; }; 532 532 ULONG getMinValue() { return 0; }; -
trunk/src/VBox/Main/src-server/Performance.cpp
r43958 r43994 716 716 { 717 717 LogFlowThisFunc(("Check cable for %s! speed=%llu period=%d.\n", mShortName.c_str(), mSpeed, getPeriod())); 718 /* We do not collect host network metrics for unplugged interfaces! 718 719 mRx->put(0); 719 720 mTx->put(0); 721 */ 720 722 } 721 723 else -
trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp
r43668 r43994 170 170 fclose(fp); 171 171 } 172 if (pInfo->uSpeedMbits == 10) 173 { 174 /* Check the cable is plugged in at all */ 175 unsigned uCarrier = 0; 176 RTStrPrintf(szBuf, sizeof(szBuf), "/sys/class/net/%s/carrier", pszName); 177 fp = fopen(szBuf, "r"); 178 if (fp) 179 { 180 if (fscanf(fp, "%u", &uCarrier) != 1 || uCarrier == 0) 181 pInfo->uSpeedMbits = 0; 182 fclose(fp); 183 } 184 } 185 172 186 if (pInfo->uSpeedMbits == 0) 173 187 { -
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r43516 r43994 301 301 } 302 302 struct ifreq IfReq; 303 struct ethtool_value EthToolVal; 303 304 struct ethtool_cmd EthToolReq; 304 305 int fd = socket(AF_INET, SOCK_DGRAM, 0); … … 310 311 return ADPCTLERR_SOCKET_FAILED; 311 312 } 313 /* Get link status first. */ 314 memset(&EthToolVal, 0, sizeof(EthToolVal)); 312 315 memset(&IfReq, 0, sizeof(IfReq)); 313 316 snprintf(IfReq.ifr_name, sizeof(IfReq.ifr_name), "%s", pszAdapterName); 314 EthToolReq.cmd = ETHTOOL_GSET; 315 IfReq.ifr_data = (caddr_t)&EthToolReq; 317 318 EthToolVal.cmd = ETHTOOL_GLINK; 319 IfReq.ifr_data = (caddr_t)&EthToolVal; 316 320 rc = ioctl(fd, SIOCETHTOOL, &IfReq); 317 321 if (rc == 0) 318 322 { 319 printf("%u", EthToolReq.speed); 323 if (EthToolVal.data) 324 { 325 memset(&IfReq, 0, sizeof(IfReq)); 326 snprintf(IfReq.ifr_name, sizeof(IfReq.ifr_name), "%s", pszAdapterName); 327 EthToolReq.cmd = ETHTOOL_GSET; 328 IfReq.ifr_data = (caddr_t)&EthToolReq; 329 rc = ioctl(fd, SIOCETHTOOL, &IfReq); 330 if (rc == 0) 331 { 332 printf("%u", EthToolReq.speed); 333 } 334 else 335 { 336 fprintf(stderr, "VBoxNetAdpCtl: Error while retrieving link " 337 "speed for %s: ", pszAdapterName); 338 perror("VBoxNetAdpCtl: ioctl failed"); 339 rc = ADPCTLERR_IOCTL_FAILED; 340 } 341 } 342 else 343 printf("0"); 320 344 } 321 345 else 322 346 { 323 347 fprintf(stderr, "VBoxNetAdpCtl: Error while retrieving link " 324 "s peedfor %s: ", pszAdapterName);348 "status for %s: ", pszAdapterName); 325 349 perror("VBoxNetAdpCtl: ioctl failed"); 326 350 rc = ADPCTLERR_IOCTL_FAILED; 327 351 } 352 328 353 close(fd); 329 354 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.