oml4r 2.9.8 → 2.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/ping-oml2 +168 -0
- data/examples/oml4r-multiple-channel-example.rb +2 -0
- data/examples/oml4r-simple-example.rb +2 -0
- data/examples/oml4r-wlanconfig.rb +2 -1
- data/lib/oml4r/version.rb +1 -1
- data/lib/oml4r.rb +6 -4
- data/omf/README +1 -0
- data/omf/ping-oml2.app.rb +83 -0
- data/oml4r.gemspec +2 -2
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzExMmRjZTY5YjU4ZDFmNjg2NzU2NDMzNWFmNThhZTAyOWY3ZDNhZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGU4MmY5MjQ5M2UyMzViNjA5ODMwY2Q3MmY3ZjIzY2VmYmM0YWQ1YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzI0ZjFhMWU1MTI3NGU5YmU5OGYwMzAyZDliZmYwMzBhZmI3MzM1OWVkNjQ2
|
10
|
+
ZTNjNDQ0Y2FlOWEwYjA0MGJkOTc0OGJmNjA0YzY4ZTMxODk4MGJhNmQ3YTJi
|
11
|
+
Y2E0MjAxOTJjMDc2OTQwMDQyYjVkNTFiMzAyMTAxZTkyZjA4Y2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDE0ODUxZGU3OGZjNTcyZDFlYTFkNzkwZDhkZjM5ZTkxMjE4NjBkMmFmN2Mw
|
14
|
+
MWViYWQ2Yzg2MWE4YTc5MWVjNWRmMDMwOTRlYzMzZjk2NzgwNjYzYTM1ZjBh
|
15
|
+
M2IwMDRkOWVmOTkyZWYyYzRiNzY2YTZhZjgyOGMzNWIyYWM1MmE=
|
data/bin/ping-oml2
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# OML4R wrapper for ping
|
4
|
+
#
|
5
|
+
# This application runs the system ping, parses its output and reports the
|
6
|
+
# measurements via OML
|
7
|
+
#
|
8
|
+
# Author: Christoph Dwertmann <christoph.dwertmann@nicta.com.au>, (C) 2012-2013
|
9
|
+
# Author: Olivier Mehani <olivier.mehani@nicta.com.au>, (C) 2012-2013
|
10
|
+
#
|
11
|
+
# Copyright (c) 2012 National ICT Australia (NICTA)
|
12
|
+
#
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
14
|
+
# of this software and associated documentation files (the "Software"), to deal
|
15
|
+
# in the Software without restriction, including without limitation the rights
|
16
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
17
|
+
# copies of the Software, and to permit persons to whom the Software is
|
18
|
+
# furnished to do so, subject to the following conditions:
|
19
|
+
#
|
20
|
+
# The above copyright notice and this permission notice shall be included in
|
21
|
+
# all copies or substantial portions of the Software.
|
22
|
+
#
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
24
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
26
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
27
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
29
|
+
# THE SOFTWARE.
|
30
|
+
#
|
31
|
+
|
32
|
+
require 'rubygems'
|
33
|
+
require 'oml4r'
|
34
|
+
|
35
|
+
class MPStat < OML4R::MPBase
|
36
|
+
name :ping
|
37
|
+
param :dest_addr, :type => :string
|
38
|
+
param :ttl, :type => :uint32
|
39
|
+
param :rtt, :type => :double
|
40
|
+
param :rtt_unit, :type => :string
|
41
|
+
end
|
42
|
+
|
43
|
+
class MPSummary < OML4R::MPBase
|
44
|
+
name :summary
|
45
|
+
param :ntransmitted, :type => :uint32
|
46
|
+
param :nreceived, :type => :uint32
|
47
|
+
param :lossratio, :type => :double
|
48
|
+
param :runtime, :type => :double
|
49
|
+
param :runtime_unit, :type => :string
|
50
|
+
end
|
51
|
+
|
52
|
+
class MPRTTStats < OML4R::MPBase
|
53
|
+
name :rtt_stats
|
54
|
+
param :min, :type => :double
|
55
|
+
param :avg, :type => :double
|
56
|
+
param :max, :type => :double
|
57
|
+
param :mdev, :type => :double
|
58
|
+
param :rtt_unit, :type => :string
|
59
|
+
end
|
60
|
+
|
61
|
+
class PingWrapper
|
62
|
+
|
63
|
+
def initialize(args)
|
64
|
+
@addr = nil
|
65
|
+
@count = ''
|
66
|
+
@interval = ''
|
67
|
+
@verbose = true
|
68
|
+
@inet6 = ''
|
69
|
+
@numeric = ''
|
70
|
+
@pingio = nil
|
71
|
+
|
72
|
+
leftover = OML4R::init(args, :appName => 'ping') do |argParser|
|
73
|
+
argParser.banner = "Runs the system ping and reports measurements via OML\n Use -h or --help for a list of options\n\n"
|
74
|
+
argParser.on("-a","--dest_addr ADDRESS","Address to ping (the -a switch is optional)") { |address| @addr = address.to_s() }
|
75
|
+
argParser.on("-c","--count NUMBER","Number of pings (default: infinite)"){ |count| @count = "-c #{count.to_i()}"}
|
76
|
+
argParser.on("-i","--interval NUMBER","Interval between pings (seconds)"){ |interval| @interval = "-i #{interval.to_i()}"}
|
77
|
+
argParser.on("-q","--[no]-quiet ","Don't show ping output on the console"){ @verbose = false }
|
78
|
+
argParser.on("-6","--[no]-inet6 ","Use ping6 rather than ping"){ @inet6 = "6"}
|
79
|
+
argParser.on("-n","--[no]-numeric ","No attempt will be made to lookup symbolic names for host addresses"){ @numeric = '-n' }
|
80
|
+
end
|
81
|
+
|
82
|
+
if @addr.nil?
|
83
|
+
if leftover.length > 0
|
84
|
+
@addr = leftover[0]
|
85
|
+
else
|
86
|
+
raise "You did not specify an address to ping!"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
def process_output(row)
|
93
|
+
if not (parse =
|
94
|
+
/^\d+ bytes from (.*):.*ttl=(\d+) time=([0-9.]+) ([a-zA-Z]+)/.match(row)
|
95
|
+
).nil? # One sample
|
96
|
+
MPStat.inject(*parse[1..4])
|
97
|
+
|
98
|
+
elsif not (parse =
|
99
|
+
/^(\d+).*transmitted, (\d+).*received, ([0-9.]+)%.*loss(, time ([0-9.]+) *([a-zA-Z]+))?/.match(row)
|
100
|
+
).nil? # Summary
|
101
|
+
# time (matches 5 & 6) is not printed by ping on OSX
|
102
|
+
# match 4 is unused
|
103
|
+
q = parse.to_a[1..3] + parse.to_a[5..6]
|
104
|
+
MPSummary.inject(*q)
|
105
|
+
|
106
|
+
elsif not (parse =
|
107
|
+
/min.*= ([0-9.]+)\/([0-9.]+)\/([0-9.]+)\/([0-9.]+) ([a-zA-Z]+)/.match(row)
|
108
|
+
).nil? # RTT statistics
|
109
|
+
MPRTTStats.inject(*parse[1..5])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def ping()
|
114
|
+
@pingio = IO.popen("ping#{@inet6} #{@numeric} #{@count} #{@interval} #{@addr}")
|
115
|
+
while true
|
116
|
+
row = @pingio.readline
|
117
|
+
puts row if @verbose
|
118
|
+
process_output(row)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def start()
|
123
|
+
return if not @pingio.nil?
|
124
|
+
|
125
|
+
# Handle for OMF's 'exit' command
|
126
|
+
a = Thread.new do
|
127
|
+
$stdin.each do |line|
|
128
|
+
if /^exit/ =~ line
|
129
|
+
Process.kill("INT", 0)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Handle Ctrl+C and OMF's SIGTERM
|
135
|
+
Signal.trap("INT", stop )
|
136
|
+
Signal.trap("TERM", stop)
|
137
|
+
|
138
|
+
begin
|
139
|
+
ping
|
140
|
+
rescue EOFError
|
141
|
+
# This error is expected
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def stop()
|
146
|
+
return if @pingio.nil?
|
147
|
+
# Kill the ping process, which will result in EOFError from ping()
|
148
|
+
Process.kill("INT", @pingio.pid)
|
149
|
+
end
|
150
|
+
|
151
|
+
end #end of class
|
152
|
+
|
153
|
+
begin
|
154
|
+
$stderr.puts " INFO ping-oml2: V#{OML4R::VERSION}\n"
|
155
|
+
app = PingWrapper.new(ARGV)
|
156
|
+
app.start()
|
157
|
+
# XXX: Sleep for one second to let OML4R send the remaining data (see comments
|
158
|
+
# in #1485)
|
159
|
+
sleep 1
|
160
|
+
rescue Interrupt
|
161
|
+
rescue Exception => ex
|
162
|
+
$stderr.puts " ERROR ping-oml2: #{ex}\n"
|
163
|
+
end
|
164
|
+
|
165
|
+
# Local Variables:
|
166
|
+
# mode:ruby
|
167
|
+
# End:
|
168
|
+
# vim: ft=ruby:sw=2
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
# Copyright (c) 2013 National ICT Australia Limited (NICTA).
|
2
4
|
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
5
|
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
# Copyright (c) 2009 - 2012 National ICT Australia Limited (NICTA).
|
2
4
|
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
5
|
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
data/lib/oml4r/version.rb
CHANGED
data/lib/oml4r.rb
CHANGED
@@ -180,6 +180,8 @@ module OML4R
|
|
180
180
|
a << (defs[:seq_no] += 1)
|
181
181
|
args.each_with_index do |arg, i|
|
182
182
|
case types[i]
|
183
|
+
when :double
|
184
|
+
arg = "NaN" if arg.nil?
|
183
185
|
when :string
|
184
186
|
# Escape tabs and newlines
|
185
187
|
arg = arg.to_s.gsub("\\", "\\\\").gsub("\r", "\\r").gsub("\n", "\\n").gsub("\t", "\\t")
|
@@ -359,13 +361,13 @@ module OML4R
|
|
359
361
|
unless omlConfigFile.nil?
|
360
362
|
f = File.open(omlConfigFile, 'r')
|
361
363
|
f.each_line do |l|
|
362
|
-
d = l[/.*experiment=["']([^
|
364
|
+
d = l[/.*experiment=["']([^"']*)/,1]
|
363
365
|
opts[:domain] = d if d
|
364
|
-
d = l[/.*domain=["']([^
|
366
|
+
d = l[/.*domain=["']([^"']*)/,1]
|
365
367
|
opts[:domain] = d if d
|
366
|
-
i = l[/.*id=["']([^
|
368
|
+
i = l[/.*id=["']([^"']*)/,1]
|
367
369
|
opts[:nodeID] = i if i
|
368
|
-
u = l[/.*url=["']([^
|
370
|
+
u = l[/.*url=["']([^"']*)/,1]
|
369
371
|
opts[:omlCollectUri] = u if u
|
370
372
|
end
|
371
373
|
f.close
|
data/omf/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
This directory contains OMF application definitions for the applications that ship with the oml4r gem. To use it, copy the application definition file into the ame directory as your OEDL experiment and run the EC from there.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012-2013 National ICT Australia (NICTA)
|
3
|
+
#
|
4
|
+
# This software may be used and distributed solely under the terms of
|
5
|
+
# the MIT license (License). You should find a copy of the License in
|
6
|
+
# COPYING or at http://opensource.org/licenses/MIT. By downloading or
|
7
|
+
# using this software you accept the terms and the liability disclaimer
|
8
|
+
# in the License.
|
9
|
+
#
|
10
|
+
defApplication('oml:app:ping', 'ping') do |a|
|
11
|
+
|
12
|
+
a.version(2, 9, 0)
|
13
|
+
a.shortDescription = "Wrapper around ping"
|
14
|
+
a.description = %{This application runs the system ping, parses its output and
|
15
|
+
reports the measurements via OML
|
16
|
+
}
|
17
|
+
a.path = "/usr/local/bin/ping-oml2"
|
18
|
+
|
19
|
+
a.defProperty('dest_addr', 'Address to ping', nil,
|
20
|
+
:type => :string)
|
21
|
+
a.defProperty('count', 'Number of times to ping', '-c',
|
22
|
+
:type => :integer)
|
23
|
+
a.defProperty('interval', 'Interval between echo requests', '-i',
|
24
|
+
:type => :integer, :unit => "seconds")
|
25
|
+
a.defProperty('quiet', 'Don\'t show ping output on the console', '-q',
|
26
|
+
:type => :boolean)
|
27
|
+
a.defProperty('inet6', 'Use ping6 rather than ping', '-6',
|
28
|
+
:type => :boolean)
|
29
|
+
|
30
|
+
a.defMeasurement('ping') do |m|
|
31
|
+
m.defMetric('dest_addr',:string)
|
32
|
+
m.defMetric('ttl',:uint32)
|
33
|
+
m.defMetric('rtt',:double)
|
34
|
+
m.defMetric('rtt_unit',:string)
|
35
|
+
end
|
36
|
+
|
37
|
+
a.defMeasurement('summary') do |m|
|
38
|
+
m.defMetric('ntransmitted',:uint32)
|
39
|
+
m.defMetric('nreceived',:uint32)
|
40
|
+
m.defMetric('lossratio',:double)
|
41
|
+
m.defMetric('runtime',:double)
|
42
|
+
m.defMetric('runtime_unit',:string)
|
43
|
+
end
|
44
|
+
|
45
|
+
a.defMeasurement('rtt_stats') do |m|
|
46
|
+
m.defMetric('min',:double)
|
47
|
+
m.defMetric('avg',:double)
|
48
|
+
m.defMetric('max',:double)
|
49
|
+
m.defMetric('mdev',:double)
|
50
|
+
m.defMetric('rtt_unit',:string)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Example use with OMF:
|
55
|
+
#defProperty('source', "node1-1.grid.orbit-lab.org", "ID of a resource")
|
56
|
+
#defProperty('sink', "node1-2.grid.orbit-lab.org", "ID of a resource")
|
57
|
+
#defProperty('sinkaddr', 'node1-2.grid.orbit-lab.org', "Ping destination address")
|
58
|
+
#
|
59
|
+
#defGroup('Source', property.source) do |node|
|
60
|
+
# node.addApplication("oml:app:ping") do |app|
|
61
|
+
# app.setProperty('dest_addr', property.sinkaddr)
|
62
|
+
# app.setProperty('count', 5)
|
63
|
+
# app.setProperty('interval', 1)
|
64
|
+
# app.measure('ping', :samples => 1)
|
65
|
+
# end
|
66
|
+
#end
|
67
|
+
#
|
68
|
+
#defGroup('Sink', property.sink) do |node|
|
69
|
+
#end
|
70
|
+
#
|
71
|
+
#onEvent(:ALL_UP_AND_INSTALLED) do |event|
|
72
|
+
# info "Starting the ping"
|
73
|
+
# group('Source').startApplications
|
74
|
+
# wait 6
|
75
|
+
# info "Stopping the ping"
|
76
|
+
# group('Source').stopApplications
|
77
|
+
# Experiment.done
|
78
|
+
#end
|
79
|
+
|
80
|
+
# Local Variables:
|
81
|
+
# mode:ruby
|
82
|
+
# End:
|
83
|
+
# vim: ft=ruby:sw=2
|
data/oml4r.gemspec
CHANGED
@@ -6,8 +6,8 @@ require "oml4r/version"
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.authors = ["NICTA"]
|
8
8
|
gem.email = ["oml-user@lists.nicta.com.au"]
|
9
|
-
gem.description = ["Simple OML client library for Ruby"]
|
10
|
-
gem.summary = ["This is a simple client library for OML which does not use liboml2 and its filters, but connects directly to the server using the +text+ protocol. User can use this library to create ruby applications which can send measurement to the OML collection server."]
|
9
|
+
gem.description = ["Simple OML client library and applications for Ruby"]
|
10
|
+
gem.summary = ["This is a simple client library for OML which does not use liboml2 and its filters, but connects directly to the server using the +text+ protocol. User can use this library to create ruby applications which can send measurement to the OML collection server. The gem ships with some example applications."]
|
11
11
|
gem.homepage = "http://oml.mytestbed.net"
|
12
12
|
|
13
13
|
# ls-files won't work in VPATH builds;
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oml4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NICTA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: ! '["Simple OML client library for Ruby"]'
|
13
|
+
description: ! '["Simple OML client library and applications for Ruby"]'
|
14
14
|
email:
|
15
15
|
- oml-user@lists.nicta.com.au
|
16
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- ping-oml2
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
@@ -22,6 +23,7 @@ files:
|
|
22
23
|
- LICENSE.txt
|
23
24
|
- README.md
|
24
25
|
- Rakefile
|
26
|
+
- bin/ping-oml2
|
25
27
|
- examples/oml4r-multiple-channel-example.rb
|
26
28
|
- examples/oml4r-neuca-beacon.rb
|
27
29
|
- examples/oml4r-orca-beacon.rb
|
@@ -34,6 +36,8 @@ files:
|
|
34
36
|
- lib/oml4r/benchmark.rb
|
35
37
|
- lib/oml4r/log4r/oml_outputter.rb
|
36
38
|
- lib/oml4r/version.rb
|
39
|
+
- omf/README
|
40
|
+
- omf/ping-oml2.app.rb
|
37
41
|
- oml4r.gemspec
|
38
42
|
homepage: http://oml.mytestbed.net
|
39
43
|
licenses:
|
@@ -61,5 +65,6 @@ specification_version: 4
|
|
61
65
|
summary: ! '["This is a simple client library for OML which does not use liboml2 and
|
62
66
|
its filters, but connects directly to the server using the +text+ protocol. User
|
63
67
|
can use this library to create ruby applications which can send measurement to the
|
64
|
-
OML collection server."]'
|
68
|
+
OML collection server. The gem ships with some example applications."]'
|
65
69
|
test_files: []
|
70
|
+
has_rdoc:
|