sloe 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sloe/ixia.rb +218 -0
- data/lib/sloe/version.rb +1 -1
- data/sloe.gemspec +4 -4
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61017b98561bc3dbd93b0d9076c1464af7b29c07
|
4
|
+
data.tar.gz: c9d7d11560e9d05f3f1b90c677a83a3e4ee1f7ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a198be45e3772a67e498e289a48698b5dda98782700361ea67a456c51bac8829f79472de3ecbc19732c4304852546395ce8d3569e61873e4872c12a0de3f4202
|
7
|
+
data.tar.gz: 3db695158c963b0e3cc3a3323aa3fedf2941d0e5e04f945efd88892efe2f6a6385dcd16f45478ad209cb25a3dc39b36df045e62e99c97ddf38ed2b01a9c933f4
|
data/lib/sloe/ixia.rb
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
module Sloe
|
2
|
+
class Ixia
|
3
|
+
|
4
|
+
# Create Sloe::Ixia object. This assumes you have the Ixia Linux TCL library installed
|
5
|
+
#
|
6
|
+
# @param host [String] IP or DNS name of the Linux TCL server
|
7
|
+
# @param port [FixNum] port number to connect Ixia IxN controller on
|
8
|
+
# @param version [String] version of the IxHal
|
9
|
+
# @param ixncfg [String] path to IxN config file
|
10
|
+
# @param traffic_duration [FixNum] duration that traffic should run for, in seconds
|
11
|
+
# @param ixia_exe [String] path to shell script that executes TCL
|
12
|
+
# @param clear_stats_after [FixNum] number of seconds to wait after configuring protocols before clearing stats
|
13
|
+
# @return [Sloe::Ixia] object that can execute IxN config file
|
14
|
+
def initialize(host: 'localhost', port: 8009, version: nil, ixncfg: nil, traffic_duration: 60, ixia_exe: '/root/ixos/bin/ixia_shell', clear_stats_after: 10)
|
15
|
+
if ixncfg == nil
|
16
|
+
fail ArgumentError, "missing mandatory IxNetwork script"
|
17
|
+
end
|
18
|
+
|
19
|
+
@host = host
|
20
|
+
@port = port
|
21
|
+
@ixncfg = ixncfg
|
22
|
+
@traffic_duration = traffic_duration
|
23
|
+
@ixia_exe = ixia_exe
|
24
|
+
@buildtime = Time.now.to_i
|
25
|
+
# base csv file name on IxN cfg file name
|
26
|
+
@csv_file = File.basename(ixncfg).sub('.ixncfg','')
|
27
|
+
@clear_stats_after = clear_stats_after
|
28
|
+
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
# Run IxN file and return Ixia stats as a CSV object
|
33
|
+
def run
|
34
|
+
run_setup
|
35
|
+
sleep @clear_stats_after
|
36
|
+
clear_stats
|
37
|
+
sleep @traffic_duration
|
38
|
+
csv = run_stats_gather
|
39
|
+
csv
|
40
|
+
end
|
41
|
+
|
42
|
+
# Load IxN file, start all protocols and then start traffic
|
43
|
+
def run_setup
|
44
|
+
setup_tcl = File.open("/var/tmp/setup-#{@buildtime}", 'w')
|
45
|
+
setup_tcl.write setup
|
46
|
+
setup_tcl.close
|
47
|
+
system "#@ixia_exe /var/tmp/setup-#{@buildtime}"
|
48
|
+
File.delete setup_tcl
|
49
|
+
end
|
50
|
+
|
51
|
+
# Clear all Ixia stats. This removes "invalid" drops observed
|
52
|
+
def clear_stats
|
53
|
+
clear_tcl = File.open("/var/tmp/clear-#{@buildtime}", 'w')
|
54
|
+
clear_tcl.write clear_traffic_stats
|
55
|
+
clear_tcl.close
|
56
|
+
system "#{@ixia_exe} /var/tmp/clear-#{@buildtime}"
|
57
|
+
File.delete clear_tcl
|
58
|
+
end
|
59
|
+
|
60
|
+
# Stop Ixia traffic flows and gather Ixia stats
|
61
|
+
def run_stats_gather
|
62
|
+
stats_tcl = File.open("/var/tmp/stats-#{@buildtime}", 'w')
|
63
|
+
stats_tcl.write finish
|
64
|
+
stats_tcl.close
|
65
|
+
system "#@ixia_exe /var/tmp/stats-#{@buildtime}"
|
66
|
+
File.delete stats_tcl
|
67
|
+
ftp = Net::FTP.new(@host)
|
68
|
+
ftp.login
|
69
|
+
file = "#{@csv_file}.csv"
|
70
|
+
Dir.chdir "#{$log_path}/ixia" do
|
71
|
+
ftp.get "Reports/#{file}"
|
72
|
+
end
|
73
|
+
ftp.delete "Reports/#{file}"
|
74
|
+
ftp.delete "Reports/#{file}.columns"
|
75
|
+
ftp.close
|
76
|
+
CSV.read("#{$log_path}/ixia/#{file}", headers: true)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Just run protocols. Do not start traffic
|
80
|
+
def run_protocols
|
81
|
+
run_proto = File.open("/var/tmp/run-proto-#{@buildtime}", 'w')
|
82
|
+
tcl = connect
|
83
|
+
tcl << load_config
|
84
|
+
tcl << start_protocols
|
85
|
+
tcl << disconnect
|
86
|
+
run_proto.write tcl
|
87
|
+
run_proto.close
|
88
|
+
system "#{@ixia_exe} /var/tmp/run-proto-#{@buildtime}"
|
89
|
+
File.delete run_proto
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def setup
|
95
|
+
tcl = connect
|
96
|
+
tcl << load_config
|
97
|
+
tcl << start_protocols
|
98
|
+
tcl << start_traffic
|
99
|
+
tcl << disconnect
|
100
|
+
tcl
|
101
|
+
end
|
102
|
+
|
103
|
+
def clear_traffic_stats
|
104
|
+
tcl = connect
|
105
|
+
tcl << clear_ixia_traffic_stats
|
106
|
+
tcl << disconnect
|
107
|
+
tcl
|
108
|
+
end
|
109
|
+
|
110
|
+
def finish
|
111
|
+
tcl = connect
|
112
|
+
tcl << stop_traffic
|
113
|
+
tcl << get_stats
|
114
|
+
tcl << disconnect
|
115
|
+
tcl
|
116
|
+
end
|
117
|
+
|
118
|
+
def connect
|
119
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
120
|
+
|set VERSION [package require IxTclNetwork]
|
121
|
+
|
|
122
|
+
|ixNet connect #@host -port #@port -version $VERSION
|
123
|
+
TCL
|
124
|
+
code
|
125
|
+
end
|
126
|
+
|
127
|
+
def load_config
|
128
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
129
|
+
|ixNet exec loadConfig [ixNet readFrom "#@ixncfg"]
|
130
|
+
|set root [ixNet getRoot]
|
131
|
+
|set vportList [ixNet getList $root vport]
|
132
|
+
|after 120000
|
133
|
+
|ixTclNet::CheckLinkState $vportList doneList
|
134
|
+
|if {[llength $doneList]} {
|
135
|
+
| puts "Error: links are not up on $doneList"
|
136
|
+
| return -1
|
137
|
+
|}
|
138
|
+
TCL
|
139
|
+
code
|
140
|
+
end
|
141
|
+
|
142
|
+
def start_protocols
|
143
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
144
|
+
|ixNet exec startAllProtocols
|
145
|
+
|after 30000
|
146
|
+
TCL
|
147
|
+
code
|
148
|
+
end
|
149
|
+
|
150
|
+
def start_traffic
|
151
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
152
|
+
|set root [ixNet getRoot]
|
153
|
+
|ixNet exec apply $root/traffic
|
154
|
+
|ixNet exec start $root/traffic
|
155
|
+
|for {set timeOut 10} {$timeOut >= 0} {incr timeOut -1} {
|
156
|
+
| if {[ixNet getAttr $root/traffic -state] == "started"} {
|
157
|
+
| break
|
158
|
+
| }
|
159
|
+
| update idletasks
|
160
|
+
| after 1000
|
161
|
+
|}
|
162
|
+
TCL
|
163
|
+
code
|
164
|
+
end
|
165
|
+
|
166
|
+
def clear_ixia_traffic_stats
|
167
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
168
|
+
|ixNet exec clearStats
|
169
|
+
TCL
|
170
|
+
code
|
171
|
+
end
|
172
|
+
|
173
|
+
def stop_traffic
|
174
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
175
|
+
|set root [ixNet getRoot]
|
176
|
+
|ixNet exec stop $root/traffic
|
177
|
+
|after 10000
|
178
|
+
TCL
|
179
|
+
code
|
180
|
+
end
|
181
|
+
|
182
|
+
def get_stats
|
183
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
184
|
+
|set root [ixNet getRoot]
|
185
|
+
|set stats $root/statistics
|
186
|
+
|set csvWindowsPath "c:\\\\inetpub\\\\ftproot\\\\Reports"
|
187
|
+
|ixNet setAttr $stats -enableCsvLogging "true"
|
188
|
+
|ixNet setAttr $stats -csvFilePath $csvWindowsPath
|
189
|
+
|ixNet setAttr $stats -pollInterval 3
|
190
|
+
|ixNet commit
|
191
|
+
|set li1 [list "Flow Statistics"]
|
192
|
+
|set csvFileName "#{@csv_file}"
|
193
|
+
|set opts [::ixTclNet::GetDefaultSnapshotSettings]
|
194
|
+
|lset opts [lsearch $opts *Location*] [subst {Snapshot.View.Csv.Location: $csvWindowsPath}]
|
195
|
+
|lset opts [lsearch $opts *GeneratingMode*] {Snapshot.View.Csv.GeneratingMode: kAppendCSVFile}
|
196
|
+
|lset opts [lsearch $opts *Settings.Name*] [subst {Snapshot.Settings.Name: $csvFileName}]
|
197
|
+
|lset opts [lsearch $opts *Contents*] {Snapshot.View.Contents: "allPages"}
|
198
|
+
|lappend opts [subst {Snapshot.View.Csv.Name: $csvFileName}]
|
199
|
+
|ixTclNet::TakeViewCSVSnapshot $li1 $opts
|
200
|
+
TCL
|
201
|
+
code
|
202
|
+
end
|
203
|
+
|
204
|
+
def clean_up
|
205
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
206
|
+
|cleanUp
|
207
|
+
TCL
|
208
|
+
code
|
209
|
+
end
|
210
|
+
|
211
|
+
def disconnect
|
212
|
+
code = <<-TCL.gsub(/^\s+\|/,'')
|
213
|
+
|ixNet disconnect
|
214
|
+
TCL
|
215
|
+
code
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
data/lib/sloe/version.rb
CHANGED
data/sloe.gemspec
CHANGED
@@ -12,10 +12,10 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = %q{A one stop shop for collecting data from a network device using NETCONF or SNMP}
|
13
13
|
gem.homepage = "https://github.com/dgjnpr/Sloe"
|
14
14
|
|
15
|
-
gem.add_dependency('snmp', '
|
16
|
-
gem.add_dependency('netconf', '~> 0.3
|
17
|
-
gem.add_dependency('net-scp', '
|
18
|
-
gem.add_development_dependency('rspec', '
|
15
|
+
gem.add_dependency('snmp', '~> 1.1')
|
16
|
+
gem.add_dependency('netconf', '~> 0.3')
|
17
|
+
gem.add_dependency('net-scp', '~> 1.0')
|
18
|
+
gem.add_development_dependency('rspec', '~> 2.12')
|
19
19
|
gem.add_development_dependency('yard')
|
20
20
|
# gem.add_development_dependency('pry-debugger')
|
21
21
|
gem.add_development_dependency('simplecov')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sloe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Gethings
|
@@ -14,58 +14,58 @@ dependencies:
|
|
14
14
|
name: snmp
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1
|
19
|
+
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: netconf
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.3
|
33
|
+
version: '0.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.3
|
40
|
+
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: net-scp
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0
|
47
|
+
version: '1.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0
|
54
|
+
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.12
|
61
|
+
version: '2.12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.12
|
68
|
+
version: '2.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/sloe.rb
|
142
142
|
- lib/sloe/common.rb
|
143
143
|
- lib/sloe/device.rb
|
144
|
+
- lib/sloe/ixia.rb
|
144
145
|
- lib/sloe/junos.rb
|
145
146
|
- lib/sloe/version.rb
|
146
147
|
- mibs/ACCOUNTING-CONTROL-MIB.yaml
|