如何测量每个用户的下行带宽?
在基于 Linux 的系统(特别是 Ubuntu Server 8.04)中,如何测量每个用户的下游带宽? 最理想的是,我想要一种直接提供数据的方法,而不必运行另一个进程并解析其输出。 我有一种通过为每个用户设置一个 iptables 过滤器并定期检查其计数器来测量每个用户上行带宽的技术,但这似乎不支持下游连接,我认为这是因为 iptables 在数据包之前检查数据包被路由到一个进程。
[edit 20080916 153434 EST]
我所说的“每个用户”是指系统上的字面帐户。 也就是说,任何具有真实 POSIX UID 的帐户都拥有实际正在运行的进程。 因此,对于 Ubuntu Server 8.04,测量将包括 root
、www-data
、我自己的帐户等的值。
In a Linux-based system (specifically, Ubuntu Server 8.04), how can you measure downstream bandwidth on a per-user basis? Optimally, I would like a method that provides data directly instead of having to run another process and parse its output. I have a technique for measuring per-user upstream bandwidth by setting up one iptables filter per user and checking their counters at regular intervals, but this doesn't seem to be supported for downstream connections, which I assume is because iptables checks packets before they are routed to a process.
[edit 20080916 153434 EST]
By "per-user", I mean literal accounts on the system. That is, any account with a real POSIX UID owning actual running processes. So, for Ubuntu Server 8.04, measurements would include values for root
, www-data
, my own account, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有看到任何明显的方法可以实现这一点,但我希望您可以使用自定义
ip_conntrack
模块来完成此操作。 您将在首次创建 conntrack 条目时捕获 uid,然后在两个方向应用相同的 uid。I don't see any obvious way to do this as implemented, but I'd expect it would be something you could do with a custom
ip_conntrack
module. You'd capture the uid when first creating the conntrack entry, then apply that same uid in both directions.