Class: Netdisco::Peer
- Inherits:
-
Object
- Object
- Netdisco::Peer
- Defined in:
- lib/netdisco/peer.rb
Instance Attribute Summary collapse
-
#dst ⇒ Object
类对象方法属性.
-
#ip ⇒ Object
类对象方法属性.
-
#oid ⇒ Object
类对象方法属性.
-
#raw_ip ⇒ Object
类对象方法属性.
-
#raw_name ⇒ Object
类对象方法属性.
-
#src ⇒ Object
类对象方法属性.
Instance Method Summary collapse
-
#initialize ⇒ Peer
constructor
初始化函数.
-
#name ⇒ Object
设置邻居名称.
-
#to_h ⇒ Object
将邻居对象转换为 HASH.
Constructor Details
#initialize ⇒ Peer
初始化函数
9 10 11 12 13 14 15 16 17 |
# File 'lib/netdisco/peer.rb', line 9 def initialize @ip = nil # Best guess of system IP @name = nil # Reverse of said IP @raw_ip = nil # IP as seen in polling @raw_name = nil # Name as seen in polling @src = nil # SRC/local interface @dst = nil # DST/remote interface @oid = {} # Hash of oids collected end |
Instance Attribute Details
#dst ⇒ Object
类对象方法属性
6 7 8 |
# File 'lib/netdisco/peer.rb', line 6 def dst @dst end |
#ip ⇒ Object
类对象方法属性
6 7 8 |
# File 'lib/netdisco/peer.rb', line 6 def ip @ip end |
#oid ⇒ Object
类对象方法属性
6 7 8 |
# File 'lib/netdisco/peer.rb', line 6 def oid @oid end |
#raw_ip ⇒ Object
类对象方法属性
6 7 8 |
# File 'lib/netdisco/peer.rb', line 6 def raw_ip @raw_ip end |
#raw_name ⇒ Object
类对象方法属性
6 7 8 |
# File 'lib/netdisco/peer.rb', line 6 def raw_name @raw_name end |
#src ⇒ Object
类对象方法属性
6 7 8 |
# File 'lib/netdisco/peer.rb', line 6 def src @src end |
Instance Method Details
#name ⇒ Object
设置邻居名称
20 21 22 |
# File 'lib/netdisco/peer.rb', line 20 def name @name ||= DNS.getname @ip end |
#to_h ⇒ Object
将邻居对象转换为 HASH
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/netdisco/peer.rb', line 25 def to_h { "ip" => ip.to_s, "name" => name.to_s, "interface" => { "source" => src.to_s, "destination" => dst.to_s }, "raw" => { "ip" => raw_ip.to_s, "name" => raw_name.to_s } } end |