oml4r 2.10.4.20.g6503629 → 2.10.4.30.g89b8035
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/ntpq-oml2 +11 -11
- data/bin/ping-oml2 +24 -15
- data/bin/signalgen +75 -0
- data/lib/oml4r/version.rb +4 -0
- data/omf/ping-oml2.rb +4 -4
- data/omf/signalgen.rb +60 -0
- metadata +10 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd8b6f5e465409927b5b77ac846b1d43d14a4b6c
|
4
|
+
data.tar.gz: 7ecd90004cbbe74cad0f59777f154848411f7f2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8119deb446648db71725aa85043ee6e9cf5bda2c03b50599372d18edde524880cde856102f68cb8786a62d53598ff3f7ae149c758d436defe6b52d5046a240a9
|
7
|
+
data.tar.gz: 13552cdb60d6f98357bc2140cdad612634e7ee017b8d3c08bc2662e02d0c45d35f601987dcc9c81ec66674a96d137f224c24bdf3cd838335b23c72941fb56a89
|
data/bin/ntpq-oml2
CHANGED
@@ -30,9 +30,9 @@
|
|
30
30
|
require 'rubygems'
|
31
31
|
require 'oml4r'
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
$bin = "ntpq"
|
34
|
+
$binopt = "-p -n"
|
35
|
+
$appname = $bin + "-oml2"
|
36
36
|
# XXX: if when is expressed in days, we need to rescale it, see MP.cleanup
|
37
37
|
@@regex = /^(?<rtype>\*|#|o|\+|x|.|-| )(?<remote>[^\s]+)\s+(?<refid>[^\s]+)\s+(?<stratum>\d+)\s+(?<type>l|u|m|b|-)\s+(?<when>\d+d?|-})\s+(?<poll>\d+)\s+(?<reach>\d+)\s+(?<delay>(\d|\.)+)\s+(?<offset>-?(\d|\.)+)\s+(?<jitter>(\d|\.)+)$/
|
38
38
|
|
@@ -40,7 +40,7 @@ require 'oml4r'
|
|
40
40
|
# [rtype]remote, refid, st[ratum], t[ype], when, poll, reach, delay, offset, jitter [or dispersion]
|
41
41
|
# [0] http://h30499.www3.hp.com/t5/System-Administration/Interpreting-NTPQ-output/m-p/3616540/highlight/true#M235154
|
42
42
|
class MP < OML4R::MPBase
|
43
|
-
name
|
43
|
+
name $bin
|
44
44
|
|
45
45
|
param :rtype, :type => :string #
|
46
46
|
# Character that may be before hostname:
|
@@ -109,14 +109,14 @@ class Wrapper
|
|
109
109
|
@loop_interval = 0
|
110
110
|
|
111
111
|
begin
|
112
|
-
@leftover = OML4R::init(args, :appName =>
|
113
|
-
argParser.banner = "Runs the system #{
|
112
|
+
@leftover = OML4R::init(args, :appName => $bin) do |argParser|
|
113
|
+
argParser.banner = "Runs the system #{$bin}#{($binopt.nil?)?"":" (#{$binopt})"} and reports measurements via OML\n Use -h or --help for a list of options\n\n"
|
114
114
|
argParser.on("-l","--loop-interval NUMBER","Interval between runs (seconds)"){ |interval| @loop_interval = interval.to_i()}
|
115
|
-
argParser.on("-q","--[no]-quiet ","Don't show #{
|
115
|
+
argParser.on("-q","--[no]-quiet ","Don't show #{$bin} output on the console"){ @verbose = false }
|
116
116
|
end
|
117
117
|
|
118
118
|
rescue OML4R::MissingArgumentException => ex
|
119
|
-
OML4R.logger.warn "#{
|
119
|
+
OML4R.logger.warn "#{$appname}: #{ex}"
|
120
120
|
end
|
121
121
|
|
122
122
|
end
|
@@ -128,7 +128,7 @@ class Wrapper
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def run()
|
131
|
-
@binio = IO.popen("#{
|
131
|
+
@binio = IO.popen("#{$bin} #{$binopt} #{(@leftover.nil?)?"":@leftover.join(' ')}")
|
132
132
|
while true
|
133
133
|
row = @binio.readline
|
134
134
|
puts row if @verbose
|
@@ -159,7 +159,7 @@ class Wrapper
|
|
159
159
|
end #end of class
|
160
160
|
|
161
161
|
begin
|
162
|
-
OML4R.logger.info "#{
|
162
|
+
OML4R.logger.info "#{$appname} #{OML4R::VERSION}"
|
163
163
|
|
164
164
|
app = Wrapper.new(ARGV)
|
165
165
|
|
@@ -191,7 +191,7 @@ rescue Interrupt
|
|
191
191
|
rescue SystemExit
|
192
192
|
OML4R.close
|
193
193
|
rescue Exception => ex
|
194
|
-
OML4R.logger.error "#{
|
194
|
+
OML4R.logger.error "#{$appname}: #{ex}"
|
195
195
|
end
|
196
196
|
|
197
197
|
# Local Variables:
|
data/bin/ping-oml2
CHANGED
@@ -32,12 +32,13 @@
|
|
32
32
|
require 'rubygems'
|
33
33
|
require 'oml4r'
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
$bin = "ping"
|
36
|
+
$appname = $bin + "-oml2"
|
37
37
|
|
38
38
|
class MPStat < OML4R::MPBase
|
39
|
-
name
|
40
|
-
param :
|
39
|
+
name $bin
|
40
|
+
param :remote, :type => :string
|
41
|
+
param :seq, :type => :uint32
|
41
42
|
param :ttl, :type => :uint32
|
42
43
|
param :rtt, :type => :double
|
43
44
|
param :rtt_unit, :type => :string
|
@@ -74,7 +75,7 @@ class PingWrapper
|
|
74
75
|
@binio = nil
|
75
76
|
|
76
77
|
begin
|
77
|
-
leftover = OML4R::init(args, :appName =>
|
78
|
+
leftover = OML4R::init(args, :appName => $bin) do |argParser|
|
78
79
|
argParser.banner = "Runs the system ping and reports measurements via OML\n Use -h or --help for a list of options\n\n"
|
79
80
|
argParser.on("-a","--dest_addr ADDRESS","Address to ping (the -a switch is optional)") { |address| @addr = address.to_s() }
|
80
81
|
argParser.on("-b","--broadcast","Allow pinging a broadcast address") { @broadcast ='-b' }
|
@@ -86,7 +87,7 @@ class PingWrapper
|
|
86
87
|
end
|
87
88
|
|
88
89
|
rescue OML4R::MissingArgumentException => ex
|
89
|
-
OML4R.logger.warn "#{
|
90
|
+
OML4R.logger.warn "#{$appname}: #{ex}"
|
90
91
|
leftover = []
|
91
92
|
end
|
92
93
|
|
@@ -102,27 +103,35 @@ class PingWrapper
|
|
102
103
|
|
103
104
|
def process_output(row)
|
104
105
|
if not (parse =
|
105
|
-
/^\d+ bytes from (.*):.*ttl=(\d+) time=([0-9.]+) ([a-zA-Z]+)/.match(row)
|
106
|
+
/^\d+ bytes from (.*):.*icmp_seq=(\d+) ttl=(\d+) time=([0-9.]+) ([a-zA-Z]+)/.match(row)
|
106
107
|
).nil? # One sample
|
107
|
-
|
108
|
+
MPStat.inject(*parse[1..5])
|
108
109
|
|
109
110
|
elsif not (parse =
|
110
|
-
|
111
|
-
|
111
|
+
/^PING .*\((?<dest_addr>[^\)]+)\) (?<packetsize>\d+)\((?<packetsize_total>\d+)\) bytes/.match(row)
|
112
|
+
).nil? # First line
|
113
|
+
|
114
|
+
MPStat.inject_metadata('dest_addr',parse[:dest_addr])
|
115
|
+
MPStat.inject_metadata('packetsize_B',parse[:packetsize])
|
116
|
+
MPStat.inject_metadata('packetsize_total_B',parse[:packetsize_total])
|
117
|
+
|
118
|
+
elsif not (parse =
|
119
|
+
/^(\d+).*transmitted, (\d+).*received,.* ([0-9.]+)%.*loss(, time ([0-9.]+) *([a-zA-Z]+))?/.match(row)
|
120
|
+
).nil? # Summary XXX: ignore duplicates in, e.g., "3 packets transmitted, 3 received, +171 duplicates, 0% packet loss, time 2003ms"
|
112
121
|
# time (matches 5 & 6) is not printed by ping on OSX
|
113
122
|
# match 4 is unused
|
114
123
|
q = parse.to_a[1..3] + parse.to_a[5..6]
|
115
|
-
|
124
|
+
MPSummary.inject(*q)
|
116
125
|
|
117
126
|
elsif not (parse =
|
118
127
|
/min.*= ([0-9.]+)\/([0-9.]+)\/([0-9.]+)\/([0-9.]+) ([a-zA-Z]+)/.match(row)
|
119
128
|
).nil? # RTT statistics
|
120
|
-
|
129
|
+
MPRTTStats.inject(*parse[1..5])
|
121
130
|
end
|
122
131
|
end
|
123
132
|
|
124
133
|
def run()
|
125
|
-
@binio = IO.popen("#{
|
134
|
+
@binio = IO.popen("#{$bin}#{@inet6} #{@numeric} #{@count} #{@interval} #{@broadcast} #{@addr}")
|
126
135
|
while true
|
127
136
|
row = @binio.readline
|
128
137
|
puts row if @verbose
|
@@ -148,7 +157,7 @@ class PingWrapper
|
|
148
157
|
end #end of class
|
149
158
|
|
150
159
|
begin
|
151
|
-
OML4R.logger.info "#{
|
160
|
+
OML4R.logger.info "#{$appname} #{OML4R::VERSION}"
|
152
161
|
|
153
162
|
app = PingWrapper.new(ARGV)
|
154
163
|
|
@@ -173,7 +182,7 @@ rescue Interrupt
|
|
173
182
|
rescue SystemExit
|
174
183
|
OML4R.close
|
175
184
|
rescue Exception => ex
|
176
|
-
OML4R.logger.error "#{
|
185
|
+
OML4R.logger.error "#{$appname}: #{ex}"
|
177
186
|
end
|
178
187
|
|
179
188
|
# Local Variables:
|
data/bin/signalgen
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014 National ICT Australia Limited (NICTA).
|
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
|
+
# ------------------
|
11
|
+
#
|
12
|
+
# = signalgen
|
13
|
+
#
|
14
|
+
# This is a simple OML4R example, which generates some signal values and
|
15
|
+
# sends them to an OML end-point (e.g. oml2 server)
|
16
|
+
#
|
17
|
+
require 'oml4r'
|
18
|
+
|
19
|
+
# Some default parameter values
|
20
|
+
APPNAME = 'signalgen'
|
21
|
+
DEF_ODOMAIN = 'foo'
|
22
|
+
DEF_OCOLLECT = 'file:-'
|
23
|
+
DEF_FREQ = 2.0 # Hz
|
24
|
+
DEF_INCREMENT = 15 # rad
|
25
|
+
DEF_SAMPLE = 500 # samples
|
26
|
+
|
27
|
+
# Define our Measurement Points
|
28
|
+
class SinMP < OML4R::MPBase
|
29
|
+
name :sin
|
30
|
+
param :label # default type is String
|
31
|
+
param :phase, :type => :int32
|
32
|
+
param :value, :type => :double
|
33
|
+
end
|
34
|
+
|
35
|
+
class CosMP < OML4R::MPBase
|
36
|
+
name :cos
|
37
|
+
param :label # default type is String
|
38
|
+
param :value, :type => :double
|
39
|
+
end
|
40
|
+
|
41
|
+
# Initialise the OML4R module for our application
|
42
|
+
# 'collect' could also be tcp:host:port
|
43
|
+
opts = {:appName => APPNAME, :domain => DEF_ODOMAIN, :collect => DEF_OCOLLECT}
|
44
|
+
|
45
|
+
begin
|
46
|
+
@freq = DEF_FREQ
|
47
|
+
@inc = DEF_INCREMENT
|
48
|
+
@sample = DEF_SAMPLE
|
49
|
+
OML4R::init(ARGV, opts) do |ap|
|
50
|
+
ap.banner = "A simple OML4R example, which generates some signal values."
|
51
|
+
ap.on("-f","--frequency F","Signal frequency [Hz]") { |f| @freq = f.to_f }
|
52
|
+
ap.on("-i","--increment A","Increment angle between samples [rad]") { |a| @inc = a.to_i }
|
53
|
+
ap.on("-n","--samples N","Number of samples to generate") { |n| @sample = n.to_i }
|
54
|
+
end
|
55
|
+
rescue OML4R::MissingArgumentException => mex
|
56
|
+
$stderr.puts mex
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
|
60
|
+
# Record some metadata
|
61
|
+
puts "#{APPNAME} - Frequency: #{@freq} Hz - Increment: #{@inc} rad - Samples: #{@sample}"
|
62
|
+
SinMP.inject_metadata('frequency',@freq)
|
63
|
+
SinMP.inject_metadata('increment',@inc)
|
64
|
+
SinMP.inject_metadata('samples',@sample)
|
65
|
+
|
66
|
+
# Now collect and inject some measurements
|
67
|
+
@sample.times do |i|
|
68
|
+
sleep 1./@freq
|
69
|
+
angle = @inc * i
|
70
|
+
SinMP.inject("label_#{angle}", angle, Math.sin(angle))
|
71
|
+
CosMP.inject("label_#{angle}", Math.cos(angle))
|
72
|
+
end
|
73
|
+
|
74
|
+
# Don't forget to close when you are finished
|
75
|
+
OML4R::close()
|
data/lib/oml4r/version.rb
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
|
7
7
|
module OML4R
|
8
8
|
|
9
|
+
# NOTE: The version number is now derived automatically from Git tags. This
|
10
|
+
# file needs not be modified.
|
11
|
+
# To create a new release, use git tag -asm "DESC" v2.m.r (make sure the
|
12
|
+
# feature set corresponds to that of liboml2-2.m).
|
9
13
|
def self.version_of(name)
|
10
14
|
git_tag = `git describe --tags 2> /dev/null`.chomp
|
11
15
|
git_root = `git rev-parse --show-toplevel 2> /dev/null`.chomp
|
data/omf/ping-oml2.rb
CHANGED
@@ -9,12 +9,11 @@
|
|
9
9
|
#
|
10
10
|
defApplication('oml:app:ping', 'ping') do |a|
|
11
11
|
|
12
|
-
a.version(2, 9, 0)
|
13
|
-
a.shortDescription = "Wrapper around ping"
|
12
|
+
# a.version(2, 9, 0) # Deprecated in OMF6
|
14
13
|
a.description = %{This application runs the system ping, parses its output and
|
15
14
|
reports the measurements via OML
|
16
15
|
}
|
17
|
-
a.
|
16
|
+
a.binary_path = "/usr/local/bin/ping-oml2"
|
18
17
|
|
19
18
|
a.defProperty('dest_addr', 'Address to ping', nil,
|
20
19
|
:type => :string)
|
@@ -28,7 +27,8 @@ reports the measurements via OML
|
|
28
27
|
:type => :boolean)
|
29
28
|
|
30
29
|
a.defMeasurement('ping') do |m|
|
31
|
-
m.defMetric('
|
30
|
+
m.defMetric('remote',:string)
|
31
|
+
m.defMetric('seq',:uint32)
|
32
32
|
m.defMetric('ttl',:uint32)
|
33
33
|
m.defMetric('rtt',:double)
|
34
34
|
m.defMetric('rtt_unit',:string)
|
data/omf/signalgen.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (c) 2014 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of
|
3
|
+
# the MIT license (License). You should find a copy of the License in
|
4
|
+
# COPYING or at http://opensource.org/licenses/MIT. By downloading or
|
5
|
+
# using this software you accept the terms and the liability disclaimer
|
6
|
+
# in the License.
|
7
|
+
#
|
8
|
+
|
9
|
+
defApplication('signalgen') do |a|
|
10
|
+
a.binary_path = "/usr/local/bin/signalgen"
|
11
|
+
a.description = "A simple signal generator reporting values into OML"
|
12
|
+
|
13
|
+
a.defProperty('frequency', 'Signal frequency [Hz]', '-f', :type => :numeric)
|
14
|
+
a.defProperty('increment', 'Increment angle between samples [rad]', '-i', :type => :numeric)
|
15
|
+
a.defProperty('samples', 'Number of samples to generate', '-n', :type => :numeric)
|
16
|
+
|
17
|
+
a.defMeasurement('sin') do |m|
|
18
|
+
m.defMetric('label', :string)
|
19
|
+
m.defMetric('phase', :int32)
|
20
|
+
m.defMetric('value', :double)
|
21
|
+
end
|
22
|
+
|
23
|
+
a.defMeasurement('cos') do |m|
|
24
|
+
m.defMetric('label', :string)
|
25
|
+
m.defMetric('value', :double)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Example use with OMF v6:
|
30
|
+
#
|
31
|
+
# loadOEDL('https://raw.githubusercontent.com/mytestbed/oml4r/master/omf/signalgen.rb')
|
32
|
+
#
|
33
|
+
# defProperty('res1', "test1", "ID of a node")
|
34
|
+
#
|
35
|
+
# defGroup('Generator', property.res1) do |node|
|
36
|
+
# node.addApplication("signalgen") do |app|
|
37
|
+
# app.setProperty('samples', 10)
|
38
|
+
# app.measure('sin', samples: 1)
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# onEvent(:ALL_UP_AND_INSTALLED) do
|
43
|
+
# info "Starting a remote signal generator"
|
44
|
+
# allGroups.startApplications
|
45
|
+
#
|
46
|
+
# after 30 do
|
47
|
+
# allGroups.stopApplications
|
48
|
+
# Experiment.done
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# defGraph 'Sine' do |g|
|
53
|
+
# g.ms('sin').select {[ oml_ts_client.as(:ts), :value ]}
|
54
|
+
# g.caption "Generated Sine Signal"
|
55
|
+
# g.type 'line_chart3'
|
56
|
+
# g.mapping :x_axis => :ts, :y_axis => :value
|
57
|
+
# g.xaxis :legend => 'time [s]'
|
58
|
+
# g.yaxis :legend => 'Sine Signal', :ticks => {:format => 's'}
|
59
|
+
# end
|
60
|
+
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oml4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.4.
|
5
|
-
prerelease: 10
|
4
|
+
version: 2.10.4.30.g89b8035
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- NICTA
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-09
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: This is a simple client library for OML which does not use liboml2 and
|
15
14
|
its filters, but connects directly to the server using the +text+ protocol. User
|
@@ -27,6 +26,7 @@ executables:
|
|
27
26
|
- oml4r-wlanconfig
|
28
27
|
- oml4r-zabbix
|
29
28
|
- ping-oml2
|
29
|
+
- signalgen
|
30
30
|
- test_types
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- bin/oml4r-wlanconfig
|
47
47
|
- bin/oml4r-zabbix
|
48
48
|
- bin/ping-oml2
|
49
|
+
- bin/signalgen
|
49
50
|
- bin/test_types
|
50
51
|
- examples/oml4r-logging.rb
|
51
52
|
- examples/oml4r-multiple-channel-example.rb
|
@@ -64,30 +65,30 @@ files:
|
|
64
65
|
- omf/README
|
65
66
|
- omf/ntpq-oml2.rb
|
66
67
|
- omf/ping-oml2.rb
|
68
|
+
- omf/signalgen.rb
|
67
69
|
- oml4r.gemspec
|
68
70
|
homepage: http://oml.mytestbed.net
|
69
71
|
licenses:
|
70
72
|
- MIT
|
73
|
+
metadata: {}
|
71
74
|
post_install_message:
|
72
75
|
rdoc_options: []
|
73
76
|
require_paths:
|
74
77
|
- lib
|
75
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
79
|
requirements:
|
78
|
-
- -
|
80
|
+
- - '>='
|
79
81
|
- !ruby/object:Gem::Version
|
80
82
|
version: '1.9'
|
81
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
84
|
requirements:
|
84
|
-
- -
|
85
|
+
- - '>'
|
85
86
|
- !ruby/object:Gem::Version
|
86
87
|
version: 1.3.1
|
87
88
|
requirements: []
|
88
89
|
rubyforge_project:
|
89
|
-
rubygems_version:
|
90
|
+
rubygems_version: 2.2.1
|
90
91
|
signing_key:
|
91
|
-
specification_version:
|
92
|
+
specification_version: 4
|
92
93
|
summary: Simple OML client library and applications for Ruby
|
93
94
|
test_files: []
|