Python 中从网络接口获取信息的模块或函数
我编写了一个小应用程序,在 Linux 终端上使用它来跟踪我在 Internet 连接会话中消耗的数据量(我将信息存储在 MongoDB 中)。我手动写入上下数据并从监控系统读取它们(以视觉方式),事实是我想使我的应用程序更加自动化,并使其从我用来连接的接口网络读取上下消耗的数据互联网(在我的例子中是 ppp0),但细节是我没有找到在 Python 中执行的方法。我猜Python有一个可以导入的模块或者可以让我做我想做的事情的东西,但直到现在我已经研究过,我还没有找到一种方法来做到这一点。
你知道有什么模块、函数或类似的东西可以让我在 python 中做我想做的事情吗?
有什么例子吗?
提前致谢
I wrote a little application that I use from the terminal in Linux to keep track of the amount of data up and down that I consume in a session of Internet connection (I store the info in MongoDB). The data up and down I write by hand and read them (visually) from the monitor system, the fact is that I would like to automate more my application and make it read data consumed up and down from the interface network i use to connect to internet (in my case ppp0), but the detail is in that I does not find the way to do in Python. I guess Python have a module to import or something that lets me do what I want, but until now I have researched I have not found a way to do it.
Do you know of any module, function or similar that allows me to do in python what I want?
any example?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我回答自己
在 PyAr 社区中找到了这个 食谱 对我来说就像手套一样做我们想做的事,而无需使用额外的命令或其他应用程序。
稍微修改代码以更好地适合我的应用程序,并添加一个将字节转换为兆字节的函数,如下所示:
Well I answer myself
Found in the community PyAr this recipe to me me like a glove going to do what we wanted without having to use extra commands or other applications.
Slightly modifying the code to better suit my application and add a function that comvierta of bytes to Megabytes leave it like this: