修改网速入参,磁盘温度
This commit is contained in:
parent
dabc2a7e5a
commit
8099028329
|
@ -19,13 +19,15 @@ float RealTimeInfo::kdk_real_get_io_speed()
|
|||
return 0;
|
||||
}
|
||||
|
||||
float RealTimeInfo::kdk_real_get_net_speed()
|
||||
float RealTimeInfo::kdk_real_get_net_speed(const char *nc)
|
||||
{
|
||||
if(!nc)
|
||||
return -1;
|
||||
struct if_speed ndev;
|
||||
|
||||
int ret = 0;
|
||||
memset(&ndev, 0, sizeof(ndev));
|
||||
sprintf(ndev.ifs_name, "enp3s0");
|
||||
sprintf(ndev.ifs_name, nc);
|
||||
ndev.ifs_us = 100000;
|
||||
ret = get_if_speed(&ndev);
|
||||
if (ret < 0)
|
||||
|
@ -58,7 +60,8 @@ float RealTimeInfo::kdk_real_get_cpu_temperature()
|
|||
{
|
||||
fgets(tmp, sizeof(tmp), fp);
|
||||
fclose(fp);
|
||||
return atof(tmp) / 1000;
|
||||
float temp = atof(tmp);
|
||||
return temp < 100 ? temp : temp / 1000;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
RealTimeInfo();
|
||||
public:
|
||||
float kdk_real_get_io_speed();
|
||||
float kdk_real_get_net_speed();
|
||||
float kdk_real_get_net_speed(const char *nc);
|
||||
float kdk_real_get_cpu_temperature();
|
||||
float kdk_real_get_disk_temperature(const char *name);
|
||||
int kdk_real_get_disk_rate(const char *name);
|
||||
|
|
|
@ -7,7 +7,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
printf("diskTemp : %f\n", info.kdk_real_get_disk_temperature(argv[argc -1]));
|
||||
printf("cpuTemp: %f\n", info.kdk_real_get_cpu_temperature());
|
||||
printf("netSpeed : %f\n", info.kdk_real_get_net_speed());
|
||||
printf("netSpeed : %f\n", info.kdk_real_get_net_speed(argv[argc -2]));
|
||||
printf("diskRate : %d\n", info.kdk_real_get_disk_rate(argv[argc -1]));
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue