#coding=utf-8 require "aio/core" class Aio::Module::Cmd::Cisco::ShowIpInterfaceBrief < Aio::Module::Cmd::Cisco include Aio::Module def initialize super({ :cmd_full => "show ip interface brief", :cmd_short => "sh ip int b", :author => "Elin", :description => "This is Cisco Command# show ip interface brief", :ranking => Ranking_1, :platform => RS, :benchmark => { } }) end def parse context = self.context.dup useful[:interface_brief] = {} context.readline_match_block(/Interface IP-Address OK\? Method Status Protocol/) {|b|b} context.readline_match_block_loop(/(?[^\s]+) (?[^\s]+) (?[^\s]+) (?[^\s]+) (?(?:administratively\s)?[^\s]+) (?[^\s]+)/, reg_blank) do |block| iface = {} iface_id = block[:interface_id] useful[:interface_brief][iface_id.to_sym] = iface block.update(iface, :interface_id) block.update(iface, :ip) block.update(iface, :ok) block.update(iface, :method) block.update(iface, :status) # 当状态是起来的,但是协议为Down,则纳入警告 if (block[:status] =~ /up/) and !(block[:protocol] =~ /up/) block.warning_serious(iface, :protocol, self, {:force => true}) else block.warning_serious(iface, :protocol, self, {:force => false}) end end end end