Changes between Version 2 and Version 3 of GEC22Agenda/LabWiki/ModuleD


Ignore:
Timestamp:
03/10/15 17:06:49 (9 years ago)
Author:
eswer18@gmail.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GEC22Agenda/LabWiki/ModuleD

    v2 v3  
    66
    77{{{
    8 #!ruby
    9 
    10 defProperty('resource1', "nodea", "ID of a resource")
    11 defProperty('resource2', "switch1", "ID of a resource")
    12 defProperty('resource3', "switch2", "ID of a resource")
    13 
     8defProperty('source1', "nodea-extend1", "ID of a resource")
     9defProperty('source2', "switch1-extend1", "ID of a resource")
     10defProperty('source3', "switch2-extend1", "ID of a resource")
     11peak_list = []
    1412
    1513defProperty('sinkaddr12', '192.168.1.7', "Ping destination address")
     
    1917defProperty('sinkaddr23', '192.168.1.14', "Ping destination address")
    2018defProperty('sinkaddr24', '192.168.1.15', "Ping destination address")
    21 
     19defProperty('sinkaddr11', '192.168.1.6', "Ping destination address")
    2220
    2321defApplication('ping') do |app|
     
    3533  # sample from this MP will be composed of a 4-tuples (addr,ttl,rtt,rtt_unit)
    3634  app.defMeasurement('ping') do |m|
    37     m.defMetric('remote',:string)
     35    m.defMetric('dest_addr',:string)
    3836    m.defMetric('ttl',:uint32)
    3937    m.defMetric('rtt',:double)
     
    4644  app.binary_path = '/bin/sh /root/ovs-setup2.sh'
    4745end
    48 defGroup('Source2', property.resource2, property.resource3) do |node|
     46defGroup('Source2', property.source2, property.source3) do |node|
    4947  node.addApplication("trema")
    5048end
    51 defGroup('Source1', property.resource1) do |node|
     49defGroup('Source1', property.source1) do |node|
    5250  node.addApplication("ping") do |app|
    5351    app.setProperty('target', property.sinkaddr12)
     
    8280end
    8381
     82defGroup('Source3', property.source1) do |node|
     83  node.addApplication("ping") do |app|
     84    app.setProperty('target', property.sinkaddr11)
     85    app.setProperty('count', 30)
     86    #app.setProperty('interval', 1)
     87    app.measure('ping', :samples => 1)
     88  end
     89end
     90
     91defEvent(:MY_EVENT, every: 0.5) do
     92# Query for some measurements...
     93  # returns an array where each element is a hash representing a row from the DB
     94  query = ms('ping').select { [ :remote] }
     95  data = defQuery(query)
     96  triggered = false
     97  if !data.nil? && !(last_row = data.pop).nil? # Make sure we have some data
     98    next if peak_list.include?(last_row[:remote]) # Do nothing if we have seen this sample before
     99    if !peak_list.include?(last_row[:remote])
     100      peak_list << last_row[:remote] # record that sample, so we dont trigger on it again
     101    end
     102    if peak_list.include?('192.168.1.7')&&peak_list.include?('192.168.1.8')&&peak_list.include?('192.168.1.13')&&peak_list.include?('192.168.1.14')&&peak_list.include?('192.168.1.15')
     103     
     104      triggered = true
     105    end
     106  end
     107  triggered
     108end
     109onEvent :MY_EVENT do
     110  group('Source3').startApplications
     111end
    84112
    85113onEvent(:ALL_UP_AND_INSTALLED) do |event|
     
    99127
    100128defGraph 'RTT' do |g|
    101   g.ms('ping').select(:oml_seq, :remote, :rtt)
     129  g.ms('ping').select(:oml_seq, :dest_addr, :rtt)
    102130  g.caption "RTT of received packets."
    103131  g.type 'line_chart3'
    104   g.mapping :x_axis => :oml_seq, :y_axis => :rtt, :group_by => :remote
     132  g.mapping :x_axis => :oml_seq, :y_axis => :rtt, :group_by => :dest_addr
    105133  g.xaxis :legend => 'oml_seq'
    106134  g.yaxis :legend => 'rtt', :ticks => {:format => 's'}