首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >木偶因素对某些网络事实的影响很慢

问木偶因素对某些网络事实的影响很慢
EN

Stack Overflow用户
提问于 2012-04-12 20:23:51
回答 1查看 1.8K关注 0票数 1

我正在学习vagrant和puppet。当我使用漫游的lucid32 (Ubuntu10.04),木偶似乎非常慢。我已经修复了(question 7780322)的fqdn问题,但它仍然非常慢。

我已将问题(部分)追溯到事实。请求is地址非常快,但ipaddress_eth0需要20秒:

代码语言:javascript
复制
root@a:/# time facter ipaddress
10.0.2.15

real    0m0.031s
user    0m0.024s
sys     0m0.004s
root@a:/# time facter ipaddress_eth0
10.0.2.15

real    0m20.126s
user    0m0.080s
sys     0m0.020s
root@a:/# 

查找ipaddress_lo的速度也很慢。

有没有人能帮我解决这个问题,或者给我一个如何调试的建议?我是Ruby的新手,但愿意学习。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-13 20:09:28

问题是arp -a的运行速度非常慢。

代码语言:javascript
复制
vagrant@lucid32:~$ time arp -a
? (10.0.2.3) at 52:54:00:12:35:03 [ether] on eth0
? (10.0.2.2) at 52:54:00:12:35:02 [ether] on eth0

real    0m20.022s
user    0m0.004s
sys     0m0.000s
vagrant@lucid32:~$

我假设这是virtualbox (4.1.12_77245)、纯主机网络、ubuntu10.04和windows7主机操作系统的某种组合的问题。

作为一种解决办法,假设我可以在不知道我的mac地址的情况下学习一点关于puppet的知识,我将/opt/ruby/lib/ruby/gems/1.8/gems/facter-1.6.0/lib/facter/arp.rb的第7行替换为:

代码语言:javascript
复制
require 'facter/util/ip'

Facter.add(:arp) do
  confine :kernel => :linux
  setcode do
    ### output = Facter::Util::Resolution.exec('arp -a') # disable for slow arp
    output = "" ### return a blank, rather than the real (but slow) arp
    if not output.nil?
      arp = ""
      output.each_line do |s|
        if s =~ /^\S+\s\S+\s\S+\s(\S+)\s\S+\s\S+\s\S+$/
          arp = $1.downcase
          break # stops on the first match
        end
      end
    end
    "fe:ff:ff:ff:ff:ff" == arp ? arp : nil
  end
end

Facter::Util::IP.get_interfaces.each do |interface|
  Facter.add("arp_" + Facter::Util::IP.alphafy(interface)) do
    confine :kernel => :linux
    setcode do
      arp = Facter::Util::IP.get_arp_value(interface)
      "fe:ff:ff:ff:ff:ff" == arp ? arp : nil
    end
  end
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10123517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档