Changeset 43507 in vbox for trunk/src/VBox/Main/src-server/linux
- Timestamp:
- Oct 2, 2012 1:22:31 PM (12 years ago)
- Location:
- trunk/src/VBox/Main/src-server/linux
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp
r33540 r43507 149 149 fclose(fp); 150 150 } 151 /* 152 * I wish I could do simple ioctl here, but older kernels require root 153 * privileges for any ethtool commands. 154 */ 155 char szBuf[256]; 156 /* First, we try to retrieve the speed via sysfs. */ 157 RTStrPrintf(szBuf, sizeof(szBuf), "/sys/class/net/%s/speed", pszName); 158 fp = fopen(szBuf, "r"); 159 if (fp && fscanf(fp, "%u", &pInfo->uSpeedMbytes) == 1) 160 fclose(fp); 161 else 162 { 163 /* Failed to get speed via sysfs, go to plan B. */ 164 int rc = NetIfAdpCtlOut(pszName, "info", szBuf, sizeof(szBuf)); 165 if (RT_SUCCESS(rc)) 166 { 167 pInfo->uSpeedMbytes = RTStrToUInt32(szBuf); 168 } 169 else 170 return rc; 171 } 151 172 } 152 173 return VINF_SUCCESS; -
trunk/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
r43445 r43507 40 40 41 41 virtual int getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle); 42 virtual int getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx , uint64_t *speed);42 virtual int getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx); 43 43 virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total); 44 44 private: … … 218 218 } 219 219 220 int CollectorLinux::getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx , uint64_t *speed)220 int CollectorLinux::getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx) 221 221 { 222 222 int rc = VINF_SUCCESS; … … 242 242 rc = VERR_FILE_IO_ERROR; 243 243 fclose(f); 244 RTStrPrintf(szIfName, sizeof(szIfName), "/sys/class/net/%s/speed", name);245 f = fopen(szIfName, "r");246 if (f)247 {248 if (fscanf(f, "%llu", &u64Speed) == 1)249 *speed = u64Speed * (1000000/8); /* Convert to bytes/sec */250 else251 rc = VERR_FILE_IO_ERROR;252 fclose(f);253 }254 else255 rc = VERR_ACCESS_DENIED;256 244 } 257 245 else
Note:
See TracChangeset
for help on using the changeset viewer.