oxidized 0.29.1 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +4 -4
- data/.github/workflows/publishdocker.yml +3 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/stale.yml +4 -1
- data/.rubocop.yml +6 -3
- data/.rubocop_todo.yml +10 -93
- data/CHANGELOG.md +66 -4
- data/CONTRIBUTING.md +174 -0
- data/Dockerfile +12 -1
- data/README.md +18 -36
- data/bin/oxidized +2 -5
- data/docs/Hooks.md +37 -1
- data/docs/Model-Notes/APC_AOS.md +52 -0
- data/docs/Model-Notes/FSOS.md +11 -0
- data/docs/Model-Notes/FortiOS.md +28 -0
- data/docs/Model-Notes/README.md +1 -20
- data/docs/Model-Notes/XGS4600-Zyxel.md +5 -0
- data/docs/Ruby-API.md +1 -1
- data/docs/Sources.md +13 -0
- data/docs/Supported-OS-Types.md +178 -270
- data/docs/Troubleshooting.md +16 -0
- data/examples/podman-compose/Makefile +61 -0
- data/examples/podman-compose/README.md +58 -0
- data/examples/podman-compose/docker-compose.yml +21 -0
- data/examples/podman-compose/model-simulation/Dockerfile-model +13 -0
- data/examples/podman-compose/model-simulation/asternos.sh +34 -0
- data/examples/podman-compose/oxidized-config/.gitignore +8 -0
- data/examples/podman-compose/oxidized-config/config +46 -0
- data/examples/podman-compose/oxidized-config/router.db +1 -0
- data/examples/podman-compose/oxidized-ssh/README.md +14 -0
- data/extra/rest_client.rb +2 -2
- data/extra/syslog.rb +2 -2
- data/lib/oxidized/cli.rb +6 -4
- data/lib/oxidized/config.rb +17 -14
- data/lib/oxidized/core.rb +22 -3
- data/lib/oxidized/hook.rb +3 -3
- data/lib/oxidized/input/exec.rb +1 -1
- data/lib/oxidized/input/ftp.rb +2 -2
- data/lib/oxidized/input/http.rb +32 -8
- data/lib/oxidized/input/input.rb +1 -1
- data/lib/oxidized/input/scp.rb +52 -0
- data/lib/oxidized/input/ssh.rb +10 -7
- data/lib/oxidized/input/telnet.rb +3 -2
- data/lib/oxidized/input/tftp.rb +1 -1
- data/lib/oxidized/jobs.rb +11 -1
- data/lib/oxidized/manager.rb +6 -6
- data/lib/oxidized/model/acos.rb +1 -1
- data/lib/oxidized/model/addpack.rb +26 -0
- data/lib/oxidized/model/adtran.rb +5 -1
- data/lib/oxidized/model/adva.rb +2 -2
- data/lib/oxidized/model/aoscx.rb +2 -1
- data/lib/oxidized/model/apc_aos.rb +2 -1
- data/lib/oxidized/model/aricentiss.rb +7 -0
- data/lib/oxidized/model/asternos.rb +22 -0
- data/lib/oxidized/model/asyncos.rb +2 -2
- data/lib/oxidized/model/awplus.rb +2 -2
- data/lib/oxidized/model/bdcom.rb +1 -0
- data/lib/oxidized/model/c4cmts.rb +1 -2
- data/lib/oxidized/model/ciscosma.rb +1 -1
- data/lib/oxidized/model/ciscosmb.rb +6 -1
- data/lib/oxidized/model/comware.rb +2 -2
- data/lib/oxidized/model/cumulus.rb +1 -1
- data/lib/oxidized/model/dellx.rb +1 -1
- data/lib/oxidized/model/dlink.rb +4 -2
- data/lib/oxidized/model/dlinknextgen.rb +51 -0
- data/lib/oxidized/model/dnos.rb +3 -0
- data/lib/oxidized/model/edgecos.rb +1 -1
- data/lib/oxidized/model/eltex.rb +2 -0
- data/lib/oxidized/model/enterasys800.rb +1 -1
- data/lib/oxidized/model/eos.rb +1 -1
- data/lib/oxidized/model/firebrick.rb +2 -2
- data/lib/oxidized/model/firewareos.rb +1 -1
- data/lib/oxidized/model/fortios.rb +9 -2
- data/lib/oxidized/model/fsos.rb +44 -0
- data/lib/oxidized/model/ios.rb +1 -1
- data/lib/oxidized/model/iosxr.rb +2 -2
- data/lib/oxidized/model/junos.rb +3 -2
- data/lib/oxidized/model/mimosab11.rb +34 -0
- data/lib/oxidized/model/ml66.rb +33 -0
- data/lib/oxidized/model/model.rb +3 -3
- data/lib/oxidized/model/netgear.rb +1 -1
- data/lib/oxidized/model/netscaler.rb +1 -1
- data/lib/oxidized/model/nxos.rb +4 -3
- data/lib/oxidized/model/ocnos.rb +42 -0
- data/lib/oxidized/model/onefinity.rb +18 -0
- data/lib/oxidized/model/openbsd.rb +1 -1
- data/lib/oxidized/model/opengear.rb +36 -1
- data/lib/oxidized/model/opnsense.rb +1 -1
- data/lib/oxidized/model/panos.rb +2 -0
- data/lib/oxidized/model/pfsense.rb +1 -0
- data/lib/oxidized/model/procurve.rb +3 -1
- data/lib/oxidized/model/rgos.rb +33 -0
- data/lib/oxidized/model/routeros.rb +10 -8
- data/lib/oxidized/model/slxos.rb +2 -2
- data/lib/oxidized/model/sonicos.rb +18 -17
- data/lib/oxidized/model/sros.rb +3 -3
- data/lib/oxidized/model/tplink.rb +4 -3
- data/lib/oxidized/model/truenas.rb +2 -1
- data/lib/oxidized/model/vrp.rb +3 -1
- data/lib/oxidized/model/vyatta.rb +6 -0
- data/lib/oxidized/model/zynos.rb +67 -3
- data/lib/oxidized/model/zynosadsl.rb +14 -0
- data/lib/oxidized/model/zynosgs.rb +2 -0
- data/lib/oxidized/model/zynosmgs.rb +32 -0
- data/lib/oxidized/node.rb +7 -7
- data/lib/oxidized/nodes.rb +17 -12
- data/lib/oxidized/output/file.rb +1 -1
- data/lib/oxidized/output/git.rb +5 -3
- data/lib/oxidized/output/gitcrypt.rb +4 -3
- data/lib/oxidized/signals.rb +44 -0
- data/lib/oxidized/source/csv.rb +1 -1
- data/lib/oxidized/source/http.rb +26 -5
- data/lib/oxidized/source/source.rb +2 -2
- data/lib/oxidized/source/sql.rb +3 -3
- data/lib/oxidized/version.rb +2 -2
- data/lib/oxidized/worker.rb +8 -1
- data/lib/oxidized.rb +3 -2
- data/lib/refinements.rb +1 -1
- data/oxidized.gemspec +6 -3
- metadata +77 -9
@@ -0,0 +1,42 @@
|
|
1
|
+
class OcNOS < Oxidized::Model
|
2
|
+
using Refinements
|
3
|
+
|
4
|
+
prompt /([\w.@-]+[#>]\s?)$/
|
5
|
+
comment '# '
|
6
|
+
|
7
|
+
cfg :ssh do
|
8
|
+
post_login 'terminal length 0'
|
9
|
+
pre_logout do
|
10
|
+
send "disable\r"
|
11
|
+
send "logout\r"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
cmd :all do |cfg|
|
16
|
+
cfg.lines.to_a[1..-2].join
|
17
|
+
end
|
18
|
+
|
19
|
+
cmd 'show version' do |cfg|
|
20
|
+
comment cfg
|
21
|
+
end
|
22
|
+
|
23
|
+
cmd 'show system fru' do |cfg|
|
24
|
+
comment cfg
|
25
|
+
end
|
26
|
+
|
27
|
+
cmd 'show system-information board-info' do |cfg|
|
28
|
+
comment cfg
|
29
|
+
end
|
30
|
+
|
31
|
+
cmd 'show forwarding profile limit' do |cfg|
|
32
|
+
comment cfg
|
33
|
+
end
|
34
|
+
|
35
|
+
cmd 'show license' do |cfg|
|
36
|
+
comment cfg
|
37
|
+
end
|
38
|
+
|
39
|
+
cmd 'show running-config' do |cfg|
|
40
|
+
cfg
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class OneFinity < Oxidized::Model
|
2
|
+
using Refinements
|
3
|
+
|
4
|
+
# Fujitsu 1finity
|
5
|
+
|
6
|
+
prompt /(\r?[\w.@_()-]+[>]\s?)$/
|
7
|
+
|
8
|
+
cmd :all do |cfg|
|
9
|
+
cfg.each_line.to_a[1..-3].join
|
10
|
+
end
|
11
|
+
|
12
|
+
cmd 'show configuration | display set | nomore'
|
13
|
+
|
14
|
+
cfg :ssh do
|
15
|
+
pre_logout 'exit'
|
16
|
+
exec true
|
17
|
+
end
|
18
|
+
end
|
@@ -5,7 +5,7 @@ class Openbsd < Oxidized::Model
|
|
5
5
|
# you can edit the one that your user uses, with root would be /root/.profile using the next PS1 def
|
6
6
|
# export PS1="\033[32m\u@\h\033[00m:\033[36m\w\033[00m$ "
|
7
7
|
|
8
|
-
prompt
|
8
|
+
prompt /^.+@.+:.+\$/
|
9
9
|
comment '# '
|
10
10
|
|
11
11
|
# Add a comment between files/configs
|
@@ -8,12 +8,47 @@ class OpenGear < Oxidized::Model
|
|
8
8
|
cmd :secret do |cfg|
|
9
9
|
cfg.gsub!(/password (\S+)/, 'password <secret removed>')
|
10
10
|
cfg.gsub!(/community (\S+)/, 'community <secret removed>')
|
11
|
+
cfg.gsub!(/community=(\S+)/, 'community=<secret removed>')
|
12
|
+
cfg.gsub!(/private_key=(\S+)/, 'private_key=<secret removed>')
|
13
|
+
cfg.gsub!(/ key=(\S+)/, ' key=<secret removed>')
|
14
|
+
cfg.gsub!(/hashed_password=(\S+)/, 'hashed_password=<secret removed>')
|
11
15
|
cfg
|
12
16
|
end
|
13
17
|
|
14
18
|
cmd('cat /etc/version') { |cfg| comment cfg }
|
15
19
|
|
16
|
-
|
20
|
+
# newer opengear firmware versions
|
21
|
+
cmd 'ogdeviceinfo -r' do |cfg|
|
22
|
+
comment cfg unless cfg.include? "ogdeviceinfo: command not found"
|
23
|
+
end
|
24
|
+
|
25
|
+
cmd 'config export' do |cfg|
|
26
|
+
unless cfg.include? "usage: config"
|
27
|
+
out = ''
|
28
|
+
cfg.each_line do |line|
|
29
|
+
out << line
|
30
|
+
end
|
31
|
+
out
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# older opengear firmware versions
|
36
|
+
cmd 'showserial' do |cfg|
|
37
|
+
unless cfg.include? "showserial: command not found"
|
38
|
+
cfg.gsub! /^/, 'Serial Number: '
|
39
|
+
comment cfg
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
cmd 'config -g config' do |cfg|
|
44
|
+
unless cfg.include? "config: error: argument"
|
45
|
+
out = ''
|
46
|
+
cfg.each_line do |line|
|
47
|
+
out << line
|
48
|
+
end
|
49
|
+
out
|
50
|
+
end
|
51
|
+
end
|
17
52
|
|
18
53
|
cfg :ssh do
|
19
54
|
exec true # don't run shell, run each command in exec channel
|
@@ -18,7 +18,7 @@ class OpnSense < Oxidized::Model
|
|
18
18
|
# that lack the opnsense-version command. Newer versions of OPNsense no longer
|
19
19
|
# store the version information in this file, so both versions have to be
|
20
20
|
# supported here for now.
|
21
|
-
cmd 'opnsense-version
|
21
|
+
cmd 'opnsense-version || echo "OPNsense "`cat /usr/local/opnsense/version/opnsense`' do |version|
|
22
22
|
xmlcomment version
|
23
23
|
end
|
24
24
|
|
data/lib/oxidized/model/panos.rb
CHANGED
@@ -18,6 +18,8 @@ class PanOS < Oxidized::Model
|
|
18
18
|
cfg.gsub! /^threat-.*?: .*$/, ''
|
19
19
|
cfg.gsub! /^wildfire-.*?: .*$/, ''
|
20
20
|
cfg.gsub! /^wf-private.*?: .*$/, ''
|
21
|
+
cfg.gsub! /^device-dictionary-version.*?: .*$/, ''
|
22
|
+
cfg.gsub! /^device-dictionary-release-date.*?: .*$/, ''
|
21
23
|
cfg.gsub! /^url-filtering.*?: .*$/, ''
|
22
24
|
cfg.gsub! /^global-.*?: .*$/, ''
|
23
25
|
comment cfg
|
@@ -15,6 +15,7 @@ class PfSense < Oxidized::Model
|
|
15
15
|
|
16
16
|
cfg.gsub! /\s<revision>\s*<time>\d*<\/time>\s*.*\s*.*\s*<\/revision>/, ''
|
17
17
|
cfg.gsub! /\s<last_rule_upd_time>\d*<\/last_rule_upd_time>/, ''
|
18
|
+
cfg.gsub! /\s<created>\s*<time>\d*<\/time>\s*.*CDATA\[Auto\].*\s*.*\s*<\/created>/, ''
|
18
19
|
cfg
|
19
20
|
end
|
20
21
|
|
@@ -5,7 +5,7 @@ class Procurve < Oxidized::Model
|
|
5
5
|
# ssh switches prompt may start with \r, followed by the prompt itself, regex ([\w\s.-]+[#>] ), which ends the line
|
6
6
|
# telnet switches may start with various vt100 control characters, regex (\e\[24;[0-9][hH]), followed by the prompt, followed
|
7
7
|
# by at least 3 other vt100 characters
|
8
|
-
prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+
|
8
|
+
prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+[#>] )($|(\e\[24;[0-9][0-9]?[hH]){3})/
|
9
9
|
|
10
10
|
comment '! '
|
11
11
|
|
@@ -36,6 +36,8 @@ class Procurve < Oxidized::Model
|
|
36
36
|
cfg.gsub! /\e\[\??\d+(;\d+)*[A-Za-z]/, ''
|
37
37
|
# Additional filtering for power usage reporting which obviously changes over time
|
38
38
|
cfg.gsub! /^(.*AC [0-9]{3}V\/?([0-9]{3}V)?) *([0-9]{1,3}) (.*)/, '\\1 <removed> \\4'
|
39
|
+
# Remove failed commands that are not supported on all models
|
40
|
+
cfg.gsub! /^Invalid input: [A-Za-z-]+\n/, ''
|
39
41
|
cfg
|
40
42
|
end
|
41
43
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class RGOS < Oxidized::Model
|
2
|
+
using Refinements
|
3
|
+
|
4
|
+
comment '! '
|
5
|
+
|
6
|
+
cmd :secret do |cfg|
|
7
|
+
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
|
8
|
+
cfg.gsub! /^(username .+ (password|secret) \d) .+/, '\\1 <secret hidden>'
|
9
|
+
cfg.gsub! /^(enable (password|secret)( level \d+)?( \d)?) .+/, '\\1 <secret hidden>'
|
10
|
+
cfg
|
11
|
+
end
|
12
|
+
|
13
|
+
cmd 'show version' do |cfg|
|
14
|
+
cfg = cfg.each_line.reject { |line| line.match /^System start time/ }.join
|
15
|
+
cfg = cfg.each_line.reject { |line| line.match /^System uptime/ }.join
|
16
|
+
comment "#{cfg.cut_both}\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
cmd 'show running-config' do |cfg|
|
20
|
+
cfg = cfg.each_line.reject { |line| line.match /^Building configuration.../ }.join
|
21
|
+
cfg = cfg.each_line.reject { |line| line.match /^Current configuration : \d+ bytes/ }.join
|
22
|
+
cfg = cfg.each_line.reject { |line| line.match /^version [\d\w()]+/ }.join
|
23
|
+
# remove empty lines
|
24
|
+
cfg = cfg.each_line.reject { |line| line.match /^[\r\n\s\u0000#]+$/ }.join
|
25
|
+
cfg.cut_both
|
26
|
+
end
|
27
|
+
|
28
|
+
cfg :telnet, :ssh do
|
29
|
+
post_login 'terminal length 0'
|
30
|
+
post_login 'terminal width 0'
|
31
|
+
pre_logout 'exit'
|
32
|
+
end
|
33
|
+
end
|
@@ -14,14 +14,14 @@ class RouterOS < Oxidized::Model
|
|
14
14
|
cfg
|
15
15
|
end
|
16
16
|
|
17
|
-
cmd '/system routerboard print
|
17
|
+
cmd '/system routerboard print' do |cfg|
|
18
18
|
cfg = cfg.each_line.grep(/(model|firmware-type|current-firmware|serial-number):/).join
|
19
19
|
comment cfg
|
20
20
|
end
|
21
21
|
|
22
|
-
cmd '/system package update print
|
23
|
-
version_line = cfg.each_line.grep(/installed-version
|
24
|
-
@ros_version =
|
22
|
+
cmd '/system package update print' do |cfg|
|
23
|
+
version_line = cfg.each_line.grep(/installed-version:\s|current-version:\s/)[0]
|
24
|
+
@ros_version = /([0-9])/.match(version_line)[0].to_i
|
25
25
|
comment version_line
|
26
26
|
end
|
27
27
|
|
@@ -40,12 +40,14 @@ class RouterOS < Oxidized::Model
|
|
40
40
|
end
|
41
41
|
cmd run_cmd do |cfg|
|
42
42
|
cfg.gsub! /\\\r?\n\s+/, '' # strip new line
|
43
|
-
cfg.gsub!
|
43
|
+
cfg.gsub! "# inactive time\r\n", '' # Remove time based system comment
|
44
44
|
cfg.gsub! /# received packet from \S+ bad format\r\n/, '' # Remove intermittent VRRP/CARP collision comment
|
45
|
-
cfg.gsub!
|
46
|
-
cfg.gsub!
|
45
|
+
cfg.gsub! "# poe-out status: short_circuit\r\n", '' # Remove intermittent POE short_circuit comment
|
46
|
+
cfg.gsub! "# Firmware upgraded successfully, please reboot for changes to take effect!\r\n", '' # Remove transient firmware upgrade comment
|
47
47
|
cfg.gsub! /# \S+ not ready\r\n/, '' # Remove intermittent $interface not ready comment
|
48
|
-
cfg = cfg.split("\n")
|
48
|
+
cfg = cfg.split("\n")
|
49
|
+
cfg.reject! { |line| line[/^#\s\w{3}\/\d{2}\/\d{4}.*$/] } # Remove date time and 'by RouterOS' comment (v6)
|
50
|
+
cfg.reject! { |line| line[/^#\s\d{4}-\d{2}-\d{2}.*$/] } # Remove date time and 'by RouterOS' comment (v7)
|
49
51
|
cfg.join("\n") + "\n"
|
50
52
|
end
|
51
53
|
end
|
data/lib/oxidized/model/slxos.rb
CHANGED
@@ -14,7 +14,7 @@ class SLXOS < Oxidized::Model
|
|
14
14
|
cmd 'show chassis' do |cfg|
|
15
15
|
cfg.encode!("UTF-8", invalid: :replace, undef: :replace) # sometimes ironware returns broken encoding
|
16
16
|
cfg.gsub! /.*Power Usage.*/, '' # remove unwanted lines power usage
|
17
|
-
cfg.gsub! /^Update
|
17
|
+
cfg.gsub! /^Update:.*$/, '' # remove unwanted current date
|
18
18
|
cfg.gsub! /Time A(live|wake).*/, '' # remove unwanted lines time alive/awake
|
19
19
|
cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, ''
|
20
20
|
|
@@ -31,7 +31,7 @@ class SLXOS < Oxidized::Model
|
|
31
31
|
|
32
32
|
cmd 'show slots' do |cfg|
|
33
33
|
cfg.gsub! /^-*^$/, '' # some slx devices are fixed config
|
34
|
-
cfg.gsub!
|
34
|
+
cfg.gsub! "syntax error: element does not exist", '' # same as above
|
35
35
|
|
36
36
|
comment cfg
|
37
37
|
end
|
@@ -11,20 +11,21 @@ class SonicOS < Oxidized::Model
|
|
11
11
|
end
|
12
12
|
|
13
13
|
cmd :secret do |cfg|
|
14
|
-
cfg.gsub! /cli ftp password default \d
|
15
|
-
cfg.gsub! /secret \d
|
16
|
-
cfg.gsub! /shared-secret \d
|
17
|
-
cfg.gsub! /password \d
|
18
|
-
cfg.gsub! /passphrase password \d
|
19
|
-
cfg.gsub! /bind-password \d
|
20
|
-
cfg.gsub! /authentication sha1 \d
|
21
|
-
cfg.gsub! /encryption aes \d
|
22
|
-
cfg.gsub! /smtp-pass \d
|
23
|
-
cfg.gsub! /pop-pass \d
|
24
|
-
cfg.gsub! /sslvpn password \d
|
25
|
-
cfg.gsub! /administrator password \d
|
26
|
-
cfg.gsub! /ftp password \d
|
27
|
-
cfg.gsub! /shared-key \d
|
14
|
+
cfg.gsub! /cli ftp password default \d,(\S+)/, 'cli ftp password default <secret hidden> \2'
|
15
|
+
cfg.gsub! /secret \d,(\S+)/, 'secret <secret hidden> \2'
|
16
|
+
cfg.gsub! /shared-secret \d,(\S+)/, 'shared-secret <secret hidden> \2'
|
17
|
+
cfg.gsub! /password \d,(\S+)/, 'password <secret hidden> \2'
|
18
|
+
cfg.gsub! /passphrase password \d,(\S+)/, 'passphrase password <secret hidden> \2'
|
19
|
+
cfg.gsub! /bind-password \d,(\S+)/, 'bind-password <secret hidden> \2'
|
20
|
+
cfg.gsub! /authentication sha1 \d,(\S+)/, 'authentication sha1 <secret hidden> \2'
|
21
|
+
cfg.gsub! /encryption aes \d,(\S+)/, 'encryption aes <secret hidden> \2'
|
22
|
+
cfg.gsub! /smtp-pass \d,(\S+)/, 'smtp-pass <secret hidden> \2'
|
23
|
+
cfg.gsub! /pop-pass \d,(\S+)/, 'pop-pass <secret hidden> \2'
|
24
|
+
cfg.gsub! /sslvpn password \d,(\S+)/, 'sslvpn password <secret hidden> \2'
|
25
|
+
cfg.gsub! /administrator password \d,(\S+)/, 'administrator password <secret hidden> \2'
|
26
|
+
cfg.gsub! /ftp password \d,(\S+)/, 'ftp password <secret hidden> \2'
|
27
|
+
cfg.gsub! /shared-key \d,(\S+)/, 'shared-key <secret hidden> \2'
|
28
|
+
cfg.gsub! /wpa passphrase \d,(\S+)/, 'wpa passphrase <secret hidden> \2'
|
28
29
|
cfg
|
29
30
|
end
|
30
31
|
|
@@ -46,9 +47,9 @@ class SonicOS < Oxidized::Model
|
|
46
47
|
def clean(cfg)
|
47
48
|
out = []
|
48
49
|
cfg.each_line do |line|
|
49
|
-
next if line =~ /date \d{4}
|
50
|
-
next if line =~ /time \d{2}
|
51
|
-
next if line =~ /system-time
|
50
|
+
next if line =~ /date \d{4}:\d{2}:\d{2}/
|
51
|
+
next if line =~ /time \d{2}:\d{2}:\d{2}/
|
52
|
+
next if line =~ /system-time "\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}.\d+"/
|
52
53
|
next if line =~ /system-uptime "((\s+up\s+\d+\s+)|(\d+\s\w+(,\s)?)*)"/
|
53
54
|
next if line =~ /checksum \d+/
|
54
55
|
|
data/lib/oxidized/model/sros.rb
CHANGED
@@ -32,7 +32,7 @@ class SROS < Oxidized::Model
|
|
32
32
|
#
|
33
33
|
# Strip uptime.
|
34
34
|
#
|
35
|
-
cfg.
|
35
|
+
cfg.gsub! /^System Up Time.*$/, ''
|
36
36
|
comment cfg
|
37
37
|
end
|
38
38
|
|
@@ -75,14 +75,14 @@ class SROS < Oxidized::Model
|
|
75
75
|
#
|
76
76
|
# Show the running persistent indices.
|
77
77
|
#
|
78
|
-
cmd
|
78
|
+
cmd "admin display-config index\n" do |cfg|
|
79
79
|
comment cfg
|
80
80
|
end
|
81
81
|
|
82
82
|
#
|
83
83
|
# Show the running configuration.
|
84
84
|
#
|
85
|
-
cmd
|
85
|
+
cmd "admin display-config\n" do |cfg|
|
86
86
|
cfg
|
87
87
|
end
|
88
88
|
|
@@ -8,7 +8,8 @@ class TrueNAS < Oxidized::Model
|
|
8
8
|
cmd('sqlite3 "file:///data/freenas-v1.db?mode=ro&immutable=1" .dump') do |cfg|
|
9
9
|
cfg.lines.reject do |line|
|
10
10
|
line.match(/^INSERT INTO storage_replication /) ||
|
11
|
-
line.match(/^INSERT INTO system_alert /)
|
11
|
+
line.match(/^INSERT INTO system_alert /) || # ignore system alerts in db
|
12
|
+
line.match(/^INSERT INTO sqlite_sequence VALUES\('system_alert',/) # ignore system alerts in db
|
12
13
|
end.join
|
13
14
|
end
|
14
15
|
|
data/lib/oxidized/model/vrp.rb
CHANGED
@@ -27,15 +27,17 @@ class VRP < Oxidized::Model
|
|
27
27
|
end
|
28
28
|
|
29
29
|
cmd 'display version' do |cfg|
|
30
|
-
cfg = cfg.each_line.reject { |l| l.match /uptime
|
30
|
+
cfg = cfg.each_line.reject { |l| l.match /uptime|^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d(\.\d\d\d)? ?(\+\d\d:\d\d)?$/ }.join
|
31
31
|
comment cfg
|
32
32
|
end
|
33
33
|
|
34
34
|
cmd 'display device' do |cfg|
|
35
|
+
cfg = cfg.each_line.reject { |l| l.match /^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d(\.\d\d\d)? ?(\+\d\d:\d\d)?$/ }.join
|
35
36
|
comment cfg
|
36
37
|
end
|
37
38
|
|
38
39
|
cmd 'display current-configuration all' do |cfg|
|
40
|
+
cfg = cfg.each_line.reject { |l| l.match /^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d(\.\d\d\d)? ?(\+\d\d:\d\d)?$/ }.join
|
39
41
|
cfg
|
40
42
|
end
|
41
43
|
end
|
@@ -15,9 +15,15 @@ class Vyatta < Oxidized::Model
|
|
15
15
|
cfg.gsub! /password (\S+).*/, 'password <secret removed>'
|
16
16
|
cfg.gsub! /pre-shared-secret (\S+).*/, 'pre-shared-secret <secret removed>'
|
17
17
|
cfg.gsub! /community (\S+) {/, 'community <hidden> {'
|
18
|
+
cfg.gsub! /private-key (\S+).*/, 'private-key <secret removed>'
|
19
|
+
cfg.gsub! /preshared-key (\S+).*/, 'preshared-key <secret removed>'
|
18
20
|
cfg
|
19
21
|
end
|
20
22
|
|
23
|
+
cmd 'show version' do |cfg|
|
24
|
+
comment cfg
|
25
|
+
end
|
26
|
+
|
21
27
|
cmd 'show configuration commands | no-more'
|
22
28
|
|
23
29
|
cfg :telnet do
|
data/lib/oxidized/model/zynos.rb
CHANGED
@@ -1,12 +1,76 @@
|
|
1
1
|
class ZyNOS < Oxidized::Model
|
2
2
|
using Refinements
|
3
3
|
|
4
|
-
|
4
|
+
prompt /^([\w.@()-<]+[#>]\s?)$/
|
5
|
+
# if there is something you can not identify after prompt, uncomment next line and comment previous line
|
6
|
+
# prompt /^([\w.@()-<]+[#>]\s?).*$/
|
5
7
|
|
6
8
|
comment '! '
|
7
9
|
|
8
|
-
|
10
|
+
# Used in Zyxel DSLAMs, such as SAM1316. Uncomment next line to enable ftp.
|
11
|
+
# cmd 'config-0'
|
9
12
|
|
10
|
-
|
13
|
+
# replace next line control sequence with a new line
|
14
|
+
expect /(\e\[1M\e\[\??\d+(;\d+)*[A-Za-z]\e\[1L)|(\eE)/ do |data, re|
|
15
|
+
data.gsub re, "\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
# replace all used vt100 control sequences
|
19
|
+
expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re|
|
20
|
+
data.gsub re, ''
|
21
|
+
end
|
22
|
+
|
23
|
+
# ignore copyright motd
|
24
|
+
expect /^(Copyright .*)\n^([\w.@()-<]+[#>]\s?)$/ do
|
25
|
+
send '\n'
|
26
|
+
""
|
27
|
+
end
|
28
|
+
|
29
|
+
cmd :all do |cfg|
|
30
|
+
cfg = cfg.gsub /^\r/, ''
|
31
|
+
# Additional filtering for elder switches sending vt100 control chars via telnet
|
32
|
+
cfg.gsub! /\e\[\??\d+(;\d+)*[A-Za-z]/, ''
|
33
|
+
cfg
|
34
|
+
end
|
35
|
+
|
36
|
+
# remove snmp community, username, password and admin-password
|
37
|
+
cmd :secret do |cfg|
|
38
|
+
cfg.gsub! /^(snmp-server get-community) \S+(.*)/, '\\1 <secret hidden> \\2'
|
39
|
+
cfg.gsub! /^(snmp-server set-community) \S+(.*)/, '\\1 <secret hidden> \\2'
|
40
|
+
cfg.gsub! /^(logins username) \S+(.*) (password) \S+(.*)/, '\\1 <secret hidden> \\2 \\3 <secret hidden> \\4'
|
41
|
+
cfg.gsub! /^(admin-password) \S+(.*)/, '\\1 <secret hidden> \\2'
|
42
|
+
cfg.gsub! /^(password) \S+(.*) (privilege \S+)/, '\\1 <secret hidden> \\2 \\3'
|
43
|
+
cfg
|
44
|
+
end
|
45
|
+
|
46
|
+
cmd 'show version' do |cfg|
|
47
|
+
comment cfg
|
48
|
+
end
|
49
|
+
|
50
|
+
cmd 'show system-information' do |cfg|
|
51
|
+
cfg.gsub! /^([Ss]ystem up [Tt]ime\s*:)(.*)/, '\\1 <time removed>'
|
52
|
+
comment cfg
|
53
|
+
end
|
54
|
+
|
55
|
+
cmd 'show running-config' do |cfg|
|
56
|
+
cfg = cfg.split("\n")[4..-2].join("\n")
|
57
|
+
cfg
|
58
|
+
end
|
59
|
+
|
60
|
+
cfg :telnet do
|
61
|
+
username /^User name:/i
|
62
|
+
password /^Password:/i
|
63
|
+
end
|
64
|
+
|
65
|
+
cfg :telnet, :ssh do
|
66
|
+
post_login do
|
67
|
+
if vars(:enable) == true
|
68
|
+
cmd "enable"
|
69
|
+
elsif vars(:enable)
|
70
|
+
cmd "enable", /^[pP]assword:/
|
71
|
+
cmd vars(:enable)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
pre_logout 'exit'
|
11
75
|
end
|
12
76
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class ZyNOSMGS < Oxidized::Model
|
2
|
+
using Refinements
|
3
|
+
|
4
|
+
PROMPT = /^(\w.*)>(.*)?$/
|
5
|
+
# Used in Zyxel MGS Series switches
|
6
|
+
|
7
|
+
prompt PROMPT
|
8
|
+
comment '! '
|
9
|
+
|
10
|
+
cmd 'show version' do |cfg|
|
11
|
+
clear_output cfg
|
12
|
+
end
|
13
|
+
|
14
|
+
cmd 'show running-config' do |cfg|
|
15
|
+
clear_output cfg
|
16
|
+
end
|
17
|
+
|
18
|
+
cfg :telnet do
|
19
|
+
username /^User\s?name(\(1-32 chars\))?:/i
|
20
|
+
password /^Password(\(1-32 chars\))?:/i
|
21
|
+
end
|
22
|
+
|
23
|
+
cfg :telnet, :ssh do
|
24
|
+
pre_logout 'exit'
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def clear_output(output)
|
30
|
+
output.gsub PROMPT, ''
|
31
|
+
end
|
32
|
+
end
|
data/lib/oxidized/node.rb
CHANGED
@@ -59,7 +59,7 @@ module Oxidized
|
|
59
59
|
|
60
60
|
def run_input(input)
|
61
61
|
rescue_fail = {}
|
62
|
-
[input.class::
|
62
|
+
[input.class::RESCUE_FAIL, input.class.superclass::RESCUE_FAIL].each do |hash|
|
63
63
|
hash.each do |level, errors|
|
64
64
|
errors.each do |err|
|
65
65
|
rescue_fail[err] = level
|
@@ -79,20 +79,20 @@ module Oxidized
|
|
79
79
|
@err_type = err.class.to_s
|
80
80
|
@err_reason = err.message.to_s
|
81
81
|
false
|
82
|
-
rescue StandardError =>
|
82
|
+
rescue StandardError => e
|
83
83
|
crashdir = Oxidized.config.crash.directory
|
84
84
|
crashfile = Oxidized.config.crash.hostnames? ? name : ip.to_s
|
85
85
|
FileUtils.mkdir_p(crashdir) unless File.directory?(crashdir)
|
86
86
|
|
87
87
|
File.open File.join(crashdir, crashfile), 'w' do |fh|
|
88
88
|
fh.puts Time.now.utc
|
89
|
-
fh.puts
|
89
|
+
fh.puts e.message + ' [' + e.class.to_s + ']'
|
90
90
|
fh.puts '-' * 50
|
91
|
-
fh.puts
|
91
|
+
fh.puts e.backtrace
|
92
92
|
end
|
93
|
-
Oxidized.logger.error '%s raised %s with msg "%s", %s saved' % [ip,
|
94
|
-
@err_type =
|
95
|
-
@err_reason =
|
93
|
+
Oxidized.logger.error '%s raised %s with msg "%s", %s saved' % [ip, e.class, e.message, crashfile]
|
94
|
+
@err_type = e.class.to_s
|
95
|
+
@err_reason = e.message.to_s
|
96
96
|
false
|
97
97
|
end
|
98
98
|
end
|
data/lib/oxidized/nodes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Oxidized
|
2
2
|
require 'ipaddr'
|
3
3
|
require 'oxidized/node'
|
4
|
-
class
|
5
|
-
class
|
4
|
+
class NotSupported < OxidizedError; end
|
5
|
+
class NodeNotFound < OxidizedError; end
|
6
6
|
|
7
7
|
class Nodes < Array
|
8
8
|
attr_accessor :source, :jobs
|
@@ -21,10 +21,10 @@ module Oxidized
|
|
21
21
|
begin
|
22
22
|
node_obj = Node.new node
|
23
23
|
new.push node_obj
|
24
|
-
rescue ModelNotFound =>
|
25
|
-
Oxidized.logger.error "node %s raised %s with message '%s'" % [node,
|
26
|
-
rescue Resolv::ResolvError =>
|
27
|
-
Oxidized.logger.error "node %s is not resolvable, raised %s with message '%s'" % [node,
|
24
|
+
rescue ModelNotFound => e
|
25
|
+
Oxidized.logger.error "node %s raised %s with message '%s'" % [node, e.class, e.message]
|
26
|
+
rescue Resolv::ResolvError => e
|
27
|
+
Oxidized.logger.error "node %s is not resolvable, raised %s with message '%s'" % [node, e.class, e.message]
|
28
28
|
end
|
29
29
|
end
|
30
30
|
size.zero? ? replace(new) : update_nodes(new)
|
@@ -80,7 +80,7 @@ module Oxidized
|
|
80
80
|
# set last job to nil so that the node is picked for immediate update
|
81
81
|
n.last = nil
|
82
82
|
put n
|
83
|
-
jobs.
|
83
|
+
jobs.increment if Oxidized.config.next_adds_job?
|
84
84
|
end
|
85
85
|
end
|
86
86
|
alias top next
|
@@ -95,7 +95,7 @@ module Oxidized
|
|
95
95
|
# @param node node whose index number in Nodes to find
|
96
96
|
# @return [Fixnum] index number of node in Nodes
|
97
97
|
def find_node_index(node)
|
98
|
-
find_index(node) || raise(
|
98
|
+
find_index(node) || raise(NodeNotFound, "unable to find '#{node}'")
|
99
99
|
end
|
100
100
|
|
101
101
|
def version(node_name, group)
|
@@ -129,8 +129,8 @@ module Oxidized
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
def with_lock(
|
133
|
-
@mutex.synchronize(
|
132
|
+
def with_lock(...)
|
133
|
+
@mutex.synchronize(...)
|
134
134
|
end
|
135
135
|
|
136
136
|
def find_index(node)
|
@@ -160,13 +160,18 @@ module Oxidized
|
|
160
160
|
# @param [Array] nodes Array of nodes used to replace+update old
|
161
161
|
def update_nodes(nodes)
|
162
162
|
old = dup
|
163
|
+
# load the Array "nodes" in self (the class Nodes inherits Array)
|
163
164
|
replace(nodes)
|
164
165
|
each do |node|
|
165
166
|
if (i = old.find_node_index(node.name))
|
166
167
|
node.stats = old[i].stats
|
167
168
|
node.last = old[i].last
|
168
169
|
end
|
169
|
-
rescue
|
170
|
+
rescue NodeNotFound
|
171
|
+
# Do nothing:
|
172
|
+
# when a node is not found, we have nothing to do:
|
173
|
+
# it has already been loaded by replace(nodes) and there are no
|
174
|
+
# stats to copy
|
170
175
|
end
|
171
176
|
sort_by! { |x| x.last.nil? ? Time.new(0) : x.last.end }
|
172
177
|
end
|
@@ -175,7 +180,7 @@ module Oxidized
|
|
175
180
|
with_lock do
|
176
181
|
node = find { |n| n.name == node_name }
|
177
182
|
output = node.output.new
|
178
|
-
raise
|
183
|
+
raise NotSupported unless output.respond_to? :fetch
|
179
184
|
|
180
185
|
yield node, output
|
181
186
|
end
|