31 | | defProperty('source1', "nodea-dbhatpostboot", "ID of a resource") |
32 | | defProperty('source2', "switch1-dbhatpostboot", "ID of a resource") |
33 | | defProperty('source3', "switch2-dbhatpostboot", "ID of a resource") |
34 | | |
| 31 | |
| 32 | defProperty('source1', "nodea-extend1", "ID of a resource") |
| 33 | defProperty('source2', "switch1-extend1", "ID of a resource") |
| 34 | defProperty('source3', "switch2-extend1", "ID of a resource") |
| 35 | peak_list = [] |
105 | | |
106 | | |
107 | | |
108 | | |
109 | | #defGroup('Sink1', property.sink1) do |node| |
110 | | #end |
111 | | |
112 | | #defGroup('Sink2', property.sink2) do |node| |
113 | | #end |
114 | | |
115 | | #defGroup('Sink3', property.sink3) do |node| |
116 | | #end |
117 | | |
118 | | #defGroup('Sink4', property.sink4) do |node| |
119 | | #end |
120 | | |
121 | | #defGroup('Sink5', property.sink5) do |node| |
122 | | #end |
| 106 | defGroup('Source3', property.source1) do |node| |
| 107 | node.addApplication("ping") do |app| |
| 108 | app.setProperty('target', property.sinkaddr11) |
| 109 | app.setProperty('count', 30) |
| 110 | #app.setProperty('interval', 1) |
| 111 | app.measure('ping', :samples => 1) |
| 112 | end |
| 113 | end |
| 114 | |
| 115 | defEvent(:MY_EVENT, every: 0.5) do |
| 116 | # Query for some measurements... |
| 117 | # returns an array where each element is a hash representing a row from the DB |
| 118 | query = ms('ping').select { [ :remote] } |
| 119 | data = defQuery(query) |
| 120 | # Alternatively the above line could also be: |
| 121 | # data = defQuery('select oml_ts_client, value from signalgen_sin') |
| 122 | # |
| 123 | # Also if you want to rename 'oml_ts_client' to 'ts' |
| 124 | # query = ms('sin').select { [ oml_ts_client.as(:ts), :value ] } |
| 125 | # data = defQuery('select oml_ts_client as ts, value from signalgen_sin') |
| 126 | |
| 127 | triggered = false |
| 128 | if !data.nil? && !(last_row = data.pop).nil? # Make sure we have some data |
| 129 | next if peak_list.include?(last_row[:remote]) # Do nothing if we have seen this sample before |
| 130 | if !peak_list.include?(last_row[:remote]) |
| 131 | peak_list << last_row[:remote] # record that sample, so we dont trigger on it again |
| 132 | end |
| 133 | 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') |
| 134 | |
| 135 | triggered = true |
| 136 | end |
| 137 | end |
| 138 | triggered |
| 139 | end |
| 140 | onEvent :MY_EVENT do |
| 141 | #group('switch').exec("ping www.google.com") |
| 142 | group('Source3').startApplications |
| 143 | end |