| 86 | defGroup('Source3', property.source1) do |node| |
| 87 | node.addApplication("ping") do |app| |
| 88 | app.setProperty('target', property.sinkaddr11) |
| 89 | app.setProperty('count', 30) |
| 90 | #app.setProperty('interval', 1) |
| 91 | app.measure('ping', :samples => 1) |
| 92 | end |
| 93 | end |
| 94 | |
| 95 | defEvent(:MY_EVENT, every: 0.5) do |
| 96 | # Query for some measurements... |
| 97 | # returns an array where each element is a hash representing a row from the DB |
| 98 | query = ms('ping').select { [ :remote] } |
| 99 | data = defQuery(query) |
| 100 | # Alternatively the above line could also be: |
| 101 | # data = defQuery('select oml_ts_client, value from signalgen_sin') |
| 102 | # |
| 103 | # Also if you want to rename 'oml_ts_client' to 'ts' |
| 104 | # query = ms('sin').select { [ oml_ts_client.as(:ts), :value ] } |
| 105 | # data = defQuery('select oml_ts_client as ts, value from signalgen_sin') |
| 106 | |
| 107 | triggered = false |
| 108 | if !data.nil? && !(last_row = data.pop).nil? # Make sure we have some data |
| 109 | next if peak_list.include?(last_row[:remote]) # Do nothing if we have seen this sample before |
| 110 | if !peak_list.include?(last_row[:remote]) |
| 111 | peak_list << last_row[:remote] # record that sample, so we dont trigger on it again |
| 112 | end |
| 113 | if peak_list.include?('192.168.1.9')&&peak_list.include?('192.168.1.7')&&peak_list.include?('192.168.1.8') |
| 114 | |
| 115 | triggered = true |
| 116 | end |
| 117 | end |
| 118 | triggered |
| 119 | end |
| 120 | onEvent :MY_EVENT do |
| 121 | #group('switch').exec("ping www.google.com") |
| 122 | group('Source3').startApplications |
| 123 | end |