问题描述
我需要以编程方式找到系统的当前带宽。
我在这里正确吗?
double f1,f2,dif,bandwidth;
std::string bw1,bw2,sshObj->exec_ssh_command("rm file1");
sshObj->exec_ssh_command("rm file2");
auto start = std::chrono::system_clock::Now();
sshObj->exec_ssh_command("cat /proc/net/dev >> file1");
sshObj->exec_ssh_command("cat /proc/net/dev >> file2");
auto end = std::chrono::system_clock::Now();
std::chrono::duration<double> elapsed_seconds = end - start;
nic_recv_bw_1 = "cat file1 | grep ens160 | awk '{print $2}'";
nic_recv_bw_1 = "cat file2 | grep ens169| awk '{print $2}'";
bw1 = sshObj->exec_ssh_channel_command(nic_recv_bw_1);
bw2 = sshObj->exec_ssh_channel_command(nic_recv_bw_2);
f1 = std::stod(bw1);
f2 = std::stod(bw2);
dif = f2 - f1;
bandwidth = dif / elapsed_seconds;
exec_ssh_channel_command
是通过ssh会话执行命令并以字符串形式输出的函数。
我的问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)