Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CR] add server,ip etc write to influxdb #30

Open
xinmans opened this issue Feb 7, 2022 · 0 comments
Open

[CR] add server,ip etc write to influxdb #30

xinmans opened this issue Feb 7, 2022 · 0 comments

Comments

@xinmans
Copy link

xinmans commented Feb 7, 2022

i want to add more muliti segments like below server info,but now only support 2 segments, will support?

"server":{"id":3633,"name":"ChinaTelecom","location":"Shanghai","country":"China","host":"speedtest1.online.sh.cn","port":8080,"ip":"101.95.48.41"}`
/usr/src/app # /usr/bin/speedtest -f json
{"type":"result","timestamp":"2022-02-07T12:27:35Z","ping":{"jitter":0.14999999999999999,"latency":10.974},"download":{"bandwidth":115106257,"bytes":1397939096,"elapsed":12711},"upload":{"bandwidth":4362655,"bytes":60270168,"elapsed":12409},"isp":"China Telecom","interface":{"internalIp":"172.19.0.4","name":"eth0","macAddr":"02:42:AC:13:00:04","isVpn":false,"externalIp":"115.193.174.195"},"server":{"id":3633,"name":"China Telecom","location":"Shanghai","country":"China","host":"speedtest1.online.sh.cn","port":8080,"ip":"101.95.48.41"},"result":{"id":"ab44b5d4-2a04-43a7-912a-b77cee852890","url":"https://www.speedtest.net/result/c/ab44b5d4-2a04-43a7-912a-b77cee852890"}}
/usr/src/app # 

const getSpeedMetrics = async () => {
const args = (process.env.SPEEDTEST_SERVER) ?
[ "--accept-license", "--accept-gdpr", "-f", "json", "--server-id=" + process.env.SPEEDTEST_SERVER] :
[ "--accept-license", "--accept-gdpr", "-f", "json" ];

const { stdout } = await execa("speedtest", args);
const result = JSON.parse(stdout);
return {
upload: bitToMbps(result.upload.bandwidth),
download: bitToMbps(result.download.bandwidth),
server: result.server.name,
serverip: result.server.ip,
isp: result.isp,

ping: result.ping.latency
};
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant