Changes between Initial Version and Version 1 of GEC20Agenda/LabWiki/ModuleE/DesignSetup


Ignore:
Timestamp:
06/19/14 18:27:33 (10 years ago)
Author:
dbhat@bbn.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GEC20Agenda/LabWiki/ModuleE/DesignSetup

    v1 v1  
     1
     2
     3== 1.1 !OpenFlow Statistics Measurement ==
     4
     5ofcollect.rb
     6{{{
     7
     8#!/usr/bin/env ruby
     9require 'rubygems'
     10require 'oml4r'
     11require 'file-tail'
     12APPNAME = "ofstats"
     13class MPThroughput < OML4R::MPBase
     14   name :ofthroughput
     15   param :pathtype, :type => :string
     16   param :numflows, :type => :int64
     17   param :numbytes, :type => :int64
     18   param :numpacket, :type => :int64
     19   param :throughput, :type => :int64
     20   param :units,        :type => :string
     21   param :instput, :type => :int64
     22   param :units2,       :type => :string
     23end
     24class OFStatsWrapper
     25  def initialize(args)
     26     @addr = nil
     27     @if_num = ' '
     28     @trema_port = ' '
     29     @trema_path = ' '
     30     @verbose = true
     31     @numeric = ' '
     32     OML4R::init(args, :appName => "#{APPNAME}_wrapper", :domain => 'foo', :collect => 'file:-') {  |argParser|
     33       argParser.banner = "Reports OpenFlow stat measurements via OML\n\n"
     34       argParser.on("-f" , "--file_path ADDRESS", "Path where output is saved"){ |address| @addr = address }
     35       argParser.on("-i","--interface IFNUM","Interface number"){ |if_num| @if_num ="#{if_num.to_i()}" }
     36       argParser.on("-q", "--no-quiet ","Don't show of stats output on console"){ @verbose = false }
     37       argParser.on("-n", "--[no]-numeric ", "No attempt twill be made to look up symbolic names for host addresses"){ @numeric ='-n' }
     38    }
     39     unless @addr !=nil
     40      raise "You did not specify path of file (-p option)"
     41    end
     42end
     43class MyFile < File
     44  include File::Tail
     45end
     46def start()
     47                log = MyFile.new("#{@addr}")
     48                log.interval = @if_num
     49                log.backward(10)
     50                puts "#{@if_num}"
     51                log.tail { |line| print line
     52                processOutput(line)
     53                }
     54end
     55def processOutput(output)
     56  column = output.split(" ")
     57      puts "Each line process"
     58      # Inject the measurements into OML
     59      MPThroughput.inject("#{column[0]}", column[1], column[2],
     60                                column[3], column[4], "#{column[5]}",
     61                                column[6], "#{column[7]}")
     62end
     63end
     64begin
     65  app = OFStatsWrapper.new(ARGV)
     66  app.start()
     67  rescue SystemExit
     68  rescue SignalException
     69     puts "OFWrapper stopped."
     70  rescue Exception => ex
     71  puts "Error - When executing the wrapper application!"
     72  puts "Error - Type: #{ex.class}"
     73  puts "Error - Message: #{ex}\n\n"
     74  # Uncomment the next line to get more info on errors
     75  # puts "Trace - #{ex.backtrace.join("\n\t")}"
     76end
     77OML4R::close()
     78# Local Variables:
     79# mode:ruby
     80# End:
     81# vim: ft=ruby:sw=2
     82}}}
     83
     84OEDL script
     85{{{
     86
     87defProperty('source1', "nowcastbox-sdxdemo", "ID of a resource")
     88defProperty('intervalcol',"1", "Interval to Tail")
     89
     90defProperty('pathfile', "/tmp/flowstats.out", "Path to file")
     91
     92
     93
     94defApplication('ofstats') do |app|
     95  app.description = 'Simple Definition for the of-collect application'
     96  # Define the path to the binary executable for this application
     97  app.binary_path = '/usr/local/bin/ofcollect.rb'
     98  app.defProperty('target', 'Address to output file', '-f', {:type => :string})
     99  app.defProperty("interval","Interval",'-i', {:type => :string})
     100  app.defMeasurement('wrapper_ofthroughput') do |m|
     101    m.defMetric(':pathtype', :string)
     102    m.defMetric('throughput',:int64)
     103    m.defMetric('instput',:int64)
     104  end
     105end
     106defGroup('Source1', property.source1) do |node|
     107  node.addApplication("ofstats") do |app|
     108    app.setProperty('target', property.pathfile)
     109    app.setProperty('interval', property.intervalcol)
     110    app.measure('wrapper_ofthroughput', :samples => 1)
     111  end
     112end
     113
     114
     115onEvent(:ALL_UP_AND_INSTALLED) do |event|
     116  info "Starting the collect"
     117  after 2 do
     118    group('Source1').startApplications
     119  end
     120  after 800 do
     121    info "Stopping the collect"
     122    allGroups.stopApplications
     123    Experiment.done
     124  end
     125end
     126
     127defGraph 'Throughput' do |g|
     128  g.ms('wrapper_ofthroughput').select(:oml_ts_client, :throughput, :pathtype)
     129  g.caption "Throughput of Flows"
     130  g.type 'line_chart3'
     131  g.mapping :x_axis => :oml_ts_client, :y_axis => :throughput, :group_by => :pathtype
     132  g.xaxis :legend => 'oml_ts'
     133  g.yaxis :legend => 'Throughput', :ticks => {:format => 's'}
     134end
     135defGraph 'InstantaneousThroughput' do |g|
     136  g.ms('wrapper_ofthroughput').select(:oml_ts_client, :instput, :pathtype)
     137  g.caption "Throughput of Flows"
     138  g.type 'line_chart3'
     139  g.mapping :x_axis => :oml_ts_client, :y_axis => :instput, :group_by => :pathtype
     140  g.xaxis :legend => 'oml_ts'
     141  g.yaxis :legend => 'Instantaneous Throughput', :ticks => {:format => 's'}
     142end
     143
     144}}}
     145
     146
     147[wiki:GEC20Agenda/LabWiki LabWiki Tutorial]