omf_rc_shm 0.1.7 → 0.1.8

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODIxMDgzNTk2ZmViYzBlNDViZDVhNTBlZTIwN2NlODQ2ZWI0ZWRmMw==
4
+ MmNiYWI3NTM2N2I0ZGRiMDNhZDc2MTY2ODM2MzM5ZTQ0YjgxMDBlMA==
5
5
  data.tar.gz: !binary |-
6
- MmJiMDE0Yzk0MTA0Mzc1ZjM2NzhhMzM2YjJhZGI2NjI5ZjMxYTM5Yg==
6
+ MWMzN2M1OWQyNzJlOGE3NGNmNDVhMWI1YWE5NWM1NGU4YmU4MWM3Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2ZmNzI5MjNjZDM3MDI2NjhhNWNjMjE0ZmI3OTBhODU2NDJmNDFjNDcwOTZi
10
- YTQxOWM4MDMxNzQ4Mjk1NjA5ZTgxYzQwNzIwNGY4YjVhOWFmMWM0ODIxNGQz
11
- ZDVlZDAwYTc4N2RlMmFhYWJjMWI0NjlkM2YxNTQ1OWVlODMyZmE=
9
+ ZmY2ZjdhZjhmNTVlNTg0Y2QzMzVjZTFiMGY3NDBmODY3MTk3N2Y4NzNjMjU4
10
+ ZWMwZmIxYTQzZjU4ODkyNTI4OGZmZmZlMGJhMmFiNDJiZjMxYWE2MDMwMDBj
11
+ YmUxYWU0M2E3OGFhZTQ3MjM4ZDgyODBmNjc1ZWNhZjVkMDFhNDQ=
12
12
  data.tar.gz: !binary |-
13
- YmIzNmI4ZTc4ODMyMDEwNmI5YjJiMTA1ZWJjMGFhNzUwM2I2OTExNmY3MWQz
14
- YzgxMWM3MDQyMDlkY2IxOThhYjMxZTQ1ZjhkYzUwYzlmMDllZWI2NGJhYjBh
15
- M2Q5NWE0NmY3YWNhMWFiYjNiNTk1NTU2NDE5YzhlZDFmN2I2MWQ=
13
+ MWQ4NjJhYzU5ODBjNDE4MWVkNjQ1NDRlNmM2NDBjMDdlNDM0NDlhOTY1YTQ1
14
+ OTFhYTg3YWZmODYwNDIxYmI5NWQ4OTNkZjZiNmNhOTljNmRjM2Q5MDk3ODRk
15
+ ZTM3OGE2YzYzMWIxN2M2OTMyMjk3Yjg4YTlkNDhlMmY0MDJmMWI=
data/README.md CHANGED
@@ -1,80 +1,91 @@
1
1
  # OmfRcShm
2
2
 
3
- An extension to OmfRc provides support for structure health monitoring project
3
+ An extension to the OMF RC, which provides support for the Structure Health Monitoring (SHM) project.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Install it as:
8
8
 
9
- $ gem install omf_rc_shm
9
+ $ gem install omf_rc_shm --no-ri --no-rdoc
10
+
11
+ (if the above command returns that it cannot download data from https://rubygems.org, then try again with the additional option `--source http://rubygems.org` and discard any subsequent SSL warning)
10
12
 
11
13
  Setup startup script
12
14
 
13
15
  $ install_omf_rc -c -i
14
16
 
15
- Configure OmfRc to load SHM extension, simply modify '/etc/omf_rc/config.yml' to something like this:
17
+ This installs a generic OMF RC configuration file in `/etc/omf_rc/config.yml`, you should modify it following the [SHM-specific configuration example](config/config.yml):
16
18
 
17
19
  ---
18
- :uri: xmpp://<%= "#{Socket.gethostname}-#{Process.pid}" %>:<%= "#{Socket.gethostname}-#{Process.pid}" %>@srv.mytestbed.net
20
+ :uri: local://local
19
21
  :environment: production
22
+ :debug: false
20
23
 
21
24
  :resources:
22
25
  - :type: shm_node
23
- :uid: <%= Socket.gethostname %>
24
- :app_definition_file: <path_to_app_definition_file>
26
+ :uid: <%= ip = `ifconfig br0`.match(/inet addr:(\d*\.\d*\.\d*\.\d*)/)[1].split('.') ; 'node' + (ip[2].to_i*256+ip[3].to_i).to_s.rjust(4,'0') %>
27
+ :app_definition_file: /etc/omf_rc/scheduled_app.rb
28
+ :ruby_path: /usr/local/bin/ruby
29
+ :watchdog_timer: 15
30
+
25
31
  :add_default_factories: false
26
32
  :factories:
27
33
  - :require: omf_rc_shm
28
34
 
35
+ Where
36
+
37
+ * `:uri:` is the URI for the communication scheme to use, e.g. `local://local` (= no communication) or `xmpp://user:password@some.xmpp.server` (= use XMPP server at some.xmpp.server)
38
+ * `:uid:` is the ID given to this resource (e.g. the above example constructs an ID similar to 'node1234' based on the IP address of the 'br0' interface)
39
+ * `:app_definition_file:` is the path to the file with the default application schedule
40
+ * `:ruby_path:` where to find the ruby binary
41
+ * `:watchdog_timer:` number of second between each watchdog timer top-up (comment that parameter to disable the watchdog timer)
42
+
29
43
  ## Define applications
30
44
 
31
- app_definition_file for shm_node simply defines the applications it runs.
45
+ The default schedule for the applications to run is in a file located at the path assigned to the above `:app_definition_file:` parameter. You should create such a file following the [default application schedule example](config/scheduled_app.rb):
32
46
 
33
47
  Example:
34
48
 
35
- App.define(
36
- "otr2", {
37
- schedule: "* * * * *",
38
- timeout: 20,
39
- binary_path: "/usr/bin/otr2",
40
- use_oml: true,
41
- parameters: {
42
- udp_local_host: { cmd: "--udp:local_host", value: "0.0.0.0" }
43
- },
44
- oml: {
45
- experiment: "otr2_#{Time.now.to_i}",
46
- id: "otr2",
47
- available_mps: [
48
- {
49
- mp: "udp_in",
50
- fields: [
51
- { field: "flow_id", type: :long },
52
- { field: "seq_no", type: :long },
53
- { field: "pkt_length", type: :long },
54
- { field: "dst_host", type: :string },
55
- { field: "dst_port", type: :long }
56
- ]
57
- }
58
- ],
59
- collection: [
60
- {
61
- url: "tcp://0.0.0.0:3003",
62
- streams: [
63
- {
64
- mp: "udp_in",
65
- interval: 3
66
- }
67
- ]
68
- }
69
- ]
70
- }
49
+ defApplication("my_app_name") do |a|
50
+ a.binary_path = "/usr/bin/my_app"
51
+ a.schedule = "*/5 * * * *"
52
+ a.timeout = 20
53
+ a.parameters = {
54
+ udp_target_host: { cmd: "--udp-target", value: "0.0.0.0", mandatory: true }
71
55
  }
72
- )
56
+ a.use_oml = true
57
+ a.oml = {
58
+ experiment: "my_experiment_#{Time.now.to_i}",
59
+ id: "some_ID",
60
+ collection: [
61
+ {
62
+ url: "tcp:0.0.0.0:3003",
63
+ streams: [
64
+ {
65
+ mp: "udp_in", samples: 1
66
+ }
67
+ ]
68
+ }
69
+ ]
70
+ }
71
+ end
72
+
73
+ Where
73
74
 
75
+ * `binary_path` is local path to the application's binary
76
+ * `schedule` is the definition of the schedule to run the application on. It can be either the string 'now' (= run this application as soon as possible) or a cron-type formatted schedule (see [crontab manual](http://www.google.com/search?q=man+crontab))
77
+ * `timeout` the time in second after which the application should be stopped, set to 0 to let the application stop by itself
78
+ * `parameters` the list of command line parameters that this application accepts, see the [OMF Documentation](https://github.com/mytestbed/omf/blob/master/doc/APPLICATION_PROXY.mkd#parameter-properties) for more detail
79
+ * `use_oml` enable OML instrumentation
80
+ * `oml` OML instrumentation parameters, see the [OML Config Documentation](http://omf.mytestbed.net/doc/oml/latest/liboml2.conf.5) for more detail. NOTE: if the sub-parameter `id:` is missing, the `:uid:` for this resource will be used by default, as requested by the SHM team.
81
+
82
+ Additional definition for application to be schedule may be added following the above definition in the same file.
74
83
 
75
84
  ## Usage
76
85
 
77
- OmfRc with SHM extension should start up automatically during boot.
86
+ The RC with SHM extension should start up automatically during boot.
87
+
88
+ However, if you need to start it manually you may use the command `omf_rc -c <path_to_config_file>`
78
89
 
79
90
  ## Contributing
80
91
 
data/config/config.yml ADDED
@@ -0,0 +1,29 @@
1
+ # Use this with standard omf_rc
2
+ ---
3
+ # URI to the communication system
4
+ # - local://local for no oustide communication
5
+ # - xmpp://user:password@some.xmpp.server to use XMPP communication via
6
+ # some.xmpp.server, using the specified user and password
7
+ :uri: local://local
8
+ :environment: production
9
+ :debug: false
10
+
11
+ :resources:
12
+ - :type: shm_node
13
+ # ID to give to this SHM node
14
+ # by default construct 'node1234' ID based on IP address of the br0 interface
15
+ # as requested by the SHM team
16
+ :uid: <%= ip = `ifconfig br0`.match(/inet addr:(\d*\.\d*\.\d*\.\d*)/)[1].split('.') ; 'node' + (ip[2].to_i*256+ip[3].to_i).to_s.rjust(4,'0') %>
17
+ # Path to the file with the default application schedule
18
+ :app_definition_file: /etc/omf_rc/scheduled_app.rb
19
+ # Path to find the Ruby binary
20
+ :ruby_path: /usr/local/bin/ruby
21
+ # The top-up value in second for the watchdog timer (must be lower than timeout value)
22
+ # Comment that line to disable the watchdog timer
23
+ :watchdog_timer: 15
24
+
25
+ :add_default_factories: false # Not loading default type factories
26
+
27
+ :factories: # Additional resources which can be created by this RC
28
+ - :require: omf_rc_shm
29
+
@@ -0,0 +1,23 @@
1
+ defApplication("my_app_name") do |a|
2
+ a.binary_path = "/usr/bin/my_app"
3
+ a.schedule = "*/5 * * * *"
4
+ a.timeout = 20
5
+ a.parameters = {
6
+ udp_target_host: { cmd: "--udp-target", value: "0.0.0.0", mandatory: true }
7
+ }
8
+ a.use_oml = true
9
+ a.oml = {
10
+ experiment: "my_experiment_#{Time.now.to_i}",
11
+ id: "some_ID",
12
+ collection: [
13
+ {
14
+ url: "tcp:0.0.0.0:3003",
15
+ streams: [
16
+ {
17
+ mp: "udp_in", samples: 1
18
+ }
19
+ ]
20
+ }
21
+ ]
22
+ }
23
+ end
@@ -32,6 +32,7 @@
32
32
  # - :experiment (String) name of the experiment in which this application
33
33
  # is scheduled
34
34
  # - :id (String) OML id to use for this application when it is scheduled
35
+ # if nil, then use this application's parent id
35
36
  # - parameters (Hash) the command line parameters available for this app.
36
37
  # This hash is of the form: { :param1 => attribut1, ... }
37
38
  # with param1 being the id of this parameter for this Proxy and
@@ -82,7 +83,6 @@ module OmfRc::ResourceProxy::ScheduledApplication
82
83
  MAX_PARAMETER_NUMBER = 1000
83
84
  DEFAULT_MANDATORY_PARAMETER = false
84
85
 
85
- property :ruby_path
86
86
  property :app_id, :default => nil
87
87
  property :description, :default => ''
88
88
  property :binary_path, :default => nil
@@ -104,6 +104,8 @@ module OmfRc::ResourceProxy::ScheduledApplication
104
104
  property :file_change_callback, :default => nil
105
105
  property :file_read_offset, :default => {}
106
106
  property :app_log_dir, :default => '/tmp/omf_scheduled_app'
107
+ property :ruby_path
108
+ property :parent_id
107
109
 
108
110
  # @!macro group_hook
109
111
  #
@@ -285,6 +287,7 @@ module OmfRc::ResourceProxy::ScheduledApplication
285
287
  if res.property.state == :scheduled
286
288
  info "Removing cron job for '#{res.property.app_id}'"
287
289
  CronEdit::Crontab.Remove res.property.app_id
290
+ restart_cron = `/etc/init.d/cron restart` # Vixie Cron on Angstrom requires restart!
288
291
  pid_file = "#{res.property.app_log_dir}/#{res.property.app_id}.pid.log"
289
292
  File.readlines(pid_file).each do |line|
290
293
  begin
@@ -319,9 +322,9 @@ module OmfRc::ResourceProxy::ScheduledApplication
319
322
  res.property.schedule = t.strftime("%-M %-H %-d %-m *")
320
323
  end
321
324
  Dir.mkdir(res.property.app_log_dir) if !Dir.exist?(res.property.app_log_dir)
322
- stderr_file = "#{res.property.app_log_dir}/#{res.property.app_id}.err.log"
323
- stdout_file = "#{res.property.app_log_dir}/#{res.property.app_id}.out.log"
324
- pid_file = "#{res.property.app_log_dir}/#{res.property.app_id}.pid.log"
325
+ stderr_file = "#{res.property.app_log_dir}/#{res.property.app_id}.#{res.uid}.err.log"
326
+ stdout_file = "#{res.property.app_log_dir}/#{res.property.app_id}.#{res.uid}.out.log"
327
+ pid_file = "#{res.property.app_log_dir}/#{res.property.app_id}.#{res.uid}.pid.log"
325
328
  File.delete(stderr_file) if File.exist?(stderr_file)
326
329
  File.delete(stdout_file) if File.exist?(stdout_file)
327
330
  File.delete(pid_file) if File.exist?(pid_file)
@@ -334,6 +337,7 @@ module OmfRc::ResourceProxy::ScheduledApplication
334
337
  info "Adding cron job for '#{res.property.app_id}' with schedule '#{res.property.schedule}' and command '#{cmd}'"
335
338
 
336
339
  CronEdit::Crontab.Add res.property.app_id, "#{res.property.schedule} #{cmd}"
340
+ restart_cron = `/etc/init.d/cron restart` # Vixie Cron on Angstrom requires restart!
337
341
  res.property.file_change_callback = Proc.new do |modified, added, removed|
338
342
  removed.each do |file|
339
343
  res.property.file_read_offset[file]=nil
@@ -348,13 +352,14 @@ module OmfRc::ResourceProxy::ScheduledApplication
348
352
  event_type = "STDOUT"
349
353
  if file.include? ".err.log"
350
354
  event_type = "STDERR"
351
- if line.include? "exited with code:"
355
+ if line.include? "exited with status:"
352
356
  if line.split(":").last.to_i == 0
353
357
  event_type = "DONE.OK"
354
358
  else
355
359
  event_type = "DONE.ERROR"
356
360
  end
357
361
  end
362
+ event_type = "DONE.OK" if line.include? "killed by signal:"
358
363
  end
359
364
  res.process_event(res, event_type, res.property.app_id, line)
360
365
  end
@@ -509,7 +514,8 @@ module OmfRc::ResourceProxy::ScheduledApplication
509
514
  o = res.property.oml
510
515
  ofile = "/tmp/#{res.uid}-#{Time.now.to_i}.xml"
511
516
  of = File.open(ofile,'w')
512
- of << "<omlc experiment='#{o.experiment}' id='#{o.id}'>\n"
517
+ oid = o.id.nil? ? res.property.parent_id : o.id
518
+ of << "<omlc experiment='#{o.experiment}' id='#{oid}'>\n"
513
519
  o.collection.each do |c|
514
520
  of << " <collect url='#{c.url}'>\n"
515
521
  c.streams.each do |m|
@@ -19,7 +19,7 @@ module OmfRc::ResourceProxy::ShmNode
19
19
 
20
20
  OmfRcShm.app.definitions.each do |name, app_opts|
21
21
  info "Got definition #{app_opts.inspect}, now schedule them..."
22
- opts = app_opts.properties.merge(hrn: name, ruby_path: node.property.ruby_path)
22
+ opts = app_opts.properties.merge(hrn: name, ruby_path: node.property.ruby_path, parent_id: node.uid)
23
23
  s_app = OmfRc::ResourceFactory.create(:scheduled_application, opts)
24
24
  OmfCommon.el.after(5) do
25
25
  s_app.configure_state(:scheduled)
@@ -1,3 +1,3 @@
1
1
  module OmfRcShm
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_rc_shm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - NICTA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-17 00:00:00.000000000 Z
11
+ date: 2013-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,8 +108,8 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - bin/cronjob_app_wrapper
111
- - config/rc.yml.sample
112
- - config/test.rb
111
+ - config/config.yml
112
+ - config/scheduled_app.rb
113
113
  - lib/omf_rc/resource_proxy/scheduled_application.rb
114
114
  - lib/omf_rc/resource_proxy/shm_node.rb
115
115
  - lib/omf_rc_shm.rb
data/config/rc.yml.sample DELETED
@@ -1,20 +0,0 @@
1
- # Use this with standard omf_rc
2
- ---
3
- :uri: local://local
4
- :environment: development
5
- :debug: false
6
-
7
- :resources:
8
- - :type: shm_node
9
- :uid: <%= ip = `ifconfig br0`.match(/inet addr:(\d*\.\d*\.\d*\.\d*)/)[1].split('.') ; 'node' + (ip[2].to_i*256+ip[3].to_i).to_s.rjust(4,'0') %>
10
- :app_definition_file: path_to_your_app_definition_file
11
- :ruby_path: <full_path_to_ruby>
12
- # Uncomment :watchdog_timer line to start the watchdog time, set the top-up
13
- # value in second (make sure to have it lower than timeout value)
14
- #:watchdog_timer: 15
15
-
16
- :add_default_factories: false # Not loading default type factories
17
-
18
- :factories: # Additional resources which can be created by this RC
19
- - :require: omf_rc_shm
20
-
data/config/test.rb DELETED
@@ -1,25 +0,0 @@
1
- defApplication("otr2") do |a|
2
- a.schedule = "* * * * *"
3
- a.timeout = 20
4
- a.binary_path = "/usr/bin/otr2"
5
- a.use_oml = true
6
- a.parameters = {
7
- udp_local_host: { cmd: "--udp:local_host", value: "0.0.0.0" }
8
- }
9
- a.oml = {
10
- experiment: "otr2_#{Time.now.to_i}",
11
- id: "otr2",
12
- collection: [
13
- {
14
- url: "tcp:0.0.0.0:3003",
15
- streams: [
16
- {
17
- mp: "udp_in",
18
- interval: 3
19
- }
20
- ]
21
- }
22
- ]
23
- }
24
- end
25
-