英文:
How to push cpu info to OpenTSDB server using golang
问题
我需要使用golang将CPU信息推送到OpenTSDB服务器。
在golang中发送数据的步骤是什么?
应该使用哪个包来发送数据?(websocket还是http)
应该以哪种格式发送数据?
推送数据时应该使用哪种方法?(POST还是GET)
英文:
I need to push cpu info to OpenTSDB server using golang.
What is the procedure to send data in golang?
In which package should use the sent Data? (websocket or http)
In which format should I send the data?
What method should I use for pushing the data? (POST OR GET)
答案1
得分: 1
你可以使用https://github.com/shirou/gopsutil包来收集指标,然后使用http包将数据通过POST请求发送到后端,请求体为json格式。可以参考这个帖子了解如何使用golang发送带有json字符串的POST请求:https://stackoverflow.com/questions/24455147/go-lang-how-send-json-string-in-post-request。
英文:
You can use https://github.com/shirou/gopsutil package to gather metrics then use http package to push data to your backend using a POST request with a json body. Have a look to this thread for posting data with golang : https://stackoverflow.com/questions/24455147/go-lang-how-send-json-string-in-post-request.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论