forked from ytti/oxidized
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edgecos.rb
63 lines (53 loc) · 1.54 KB
/
edgecos.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class EdgeCOS < Oxidized::Model
comment '! '
# Handle pager for ES3526XA-V2
expect /^---More---.*$/ do |data, re|
send ' '
data.sub re, ''
end
cmd :secret do |cfg|
cfg.gsub!(/password \d+ (\S+).*/, '<secret removed>')
cfg.gsub!(/community (\S+)/, 'community <hidden>')
cfg
end
cmd :all do |cfg|
# Do not show errors for commands that are not supported on some devices
cfg.gsub! /^(% Invalid input detected at '\^' marker\.|^\s+\^)$/, ''
# Handle pager for ES3526XA-V2
cfg.gsub! /^([\b]{10}\s{10}[\b]{10})/, ''
cfg.cut_both
end
cmd 'show running-config' do |cfg|
# Remove "building running-config, please wait..." message
cfg.cut_head
end
cmd 'show system' do |cfg|
cfg.gsub! /^.*\sUp Time\s*:.*\n/i, ''
cfg.gsub! /^(.*\sTemperature \d*:).*\n/i, '\\1 <removed>'
comment cfg
end
cmd 'show version' do |cfg|
comment cfg
end
cmd 'show watchdog' do |cfg|
comment cfg
end
cmd 'show interfaces transceiver' do |cfg|
cfg.gsub! /(\d\d)!/, '\\1 ' # alarm indicators of DDM thresholds
cfg.gsub! /^(\s*Temperature\s*:).*/, '\1 <hidden>'
cfg.gsub! /^(\s*Vcc\s*:).*/, '\1 <hidden>'
cfg.gsub! /^(\s*Bias Current\s*:).*/, '\1 <hidden>'
cfg.gsub! /^(\s*TX Power\s*:).*/, '\1 <hidden>'
cfg.gsub! /^(\s*RX Power\s*:).*/, '\1 <hidden>'
comment cfg
end
cfg :telnet do
username /^Username:/
password /^Password:/
end
cfg :telnet, :ssh do
post_login 'terminal length 0'
post_login 'terminal width 300'
pre_logout 'exit'
end
end