修改网速入参,磁盘温度

This commit is contained in:
shaozhimin 2022-10-20 16:20:40 +08:00
parent dabc2a7e5a
commit 8099028329
3 changed files with 8 additions and 5 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}