在容器内使用iotop ,错误信息:

raceback (most recent call last):
  File "/usr/sbin/iotop", line 16, in <module>
    main()
  File "/usr/lib/python2.6/site-packages/iotop/ui.py", line 559, in main
    main_loop()
  File "/usr/lib/python2.6/site-packages/iotop/ui.py", line 549, in <lambda>
    main_loop = lambda: run_iotop(options)
  File "/usr/lib/python2.6/site-packages/iotop/ui.py", line 447, in run_iotop
    return curses.wrapper(run_iotop_window, options)
  File "/usr/lib64/python2.6/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/lib/python2.6/site-packages/iotop/ui.py", line 437, in run_iotop_window
    taskstats_connection = TaskStatsNetlink(options)
  File "/usr/lib/python2.6/site-packages/iotop/data.py", line 113, in __init__
    self.family_id = controller.get_family_id('TASKSTATS')
  File "/usr/lib/python2.6/site-packages/iotop/genetlink.py", line 54, in get_family_id
    m = self.conn.recv()
  File "/usr/lib/python2.6/site-packages/iotop/netlink.py", line 190, in recv
    raise err
OSError: Netlink error: No such file or directory (2)

iotop是通过内核的taskstats接口获取统计信息的。taskstats是基于generic netlink实现的,而且taskstats不支持net namespace。

static struct genl_family family = {
	.id		= GENL_ID_GENERATE,
	.name		= TASKSTATS_GENL_NAME,
	.version	= TASKSTATS_GENL_VERSION,
	.maxattr	= TASKSTATS_CMD_ATTR_MAX,
};


static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
{
 int i, n = 0;
 struct genl_family *rt;
 struct net *net = sock_net(skb->sk);
 int chains_to_skip = cb->args[0];
 int fams_to_skip = cb->args[1];
 for (i = chains_to_skip; i < GENL_FAM_TAB_SIZE; i++) {
  n = 0;
  list_for_each_entry(rt, genl_family_chain(i), family_list) {
   if (!rt->netnsok && !net_eq(net, &init_net))///don't support netnamespace
    continue;


Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐