Skip to content

Commit

Permalink
Merge pull request #5 from redBorder/development
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
jsotofernandez authored Jul 10, 2024
2 parents 4b591b7 + 5d4f190 commit 5aec9de
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
cookbook-rb-exporter CHANGELOG
===============

## 0.1.0

- David Vanhoucke
- [c1ee0f3] fix netflow v5
- [4a06b54] add subnet to observation id filters

## 0.0.2

- Miguel Negron
Expand Down
6 changes: 2 additions & 4 deletions packaging/rpm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ SOURCES:

archive: SOURCES
cd ../../ && \
tar --exclude=packaging/rpm/SOURCES -cvf packaging/rpm/SOURCES/$(PACKAGE_NAME)-$(VERSION).tar.gz \
--transform 's%^./%$(PACKAGE_NAME)-$(VERSION)/%' .
#git archive --prefix=$(PACKAGE_NAME)-$(VERSION)/ \
# -o packaging/rpm/SOURCES/$(PACKAGE_NAME)-$(VERSION).tar.gz HEAD
git archive --prefix=$(PACKAGE_NAME)-$(VERSION)/ \
-o packaging/rpm/SOURCES/$(PACKAGE_NAME)-$(VERSION).tar.gz HEAD


build_prepare: archive
Expand Down
2 changes: 1 addition & 1 deletion resources/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
maintainer_email 'git@redborder.com'
license 'AGPL-3.0'
description 'Installs/Configures cookbook-rb-exporter'
version '0.0.2'
version '0.1.0'
7 changes: 4 additions & 3 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@

# Calculate observation_id
observation_id = (iface['observationId'] && !iface['observationId'].empty?) ? iface['observationId'] : nil
observation_id = 4294967295 if observation_id.nil? && iface['type'].downcase.include?('sflow')
observation_id = 4294967295 if observation_id.nil? && iface['protocol_type'].downcase.include?('sflow')
observation_id_filters = iface['observation_id_filters'] || {}

template "/etc/rb-exporter/#{iface_key}/rb-exporter.conf" do
source 'rb-exporter_conf.erb'
Expand All @@ -104,7 +105,7 @@
cookbook 'rb-exporter'
mode '0644'
retries 2
variables(dstAddress: iface['dstAddress'], type: iface['type'], ipAddress: node['ipaddress'], iface: iface_key, observation_id: observation_id)
variables(dstAddress: iface['dstAddress'], type: iface['protocol_type'], ipAddress: node['ipaddress'], iface: iface_key, observation_id: observation_id, observation_id_filters: observation_id_filters)
notifies :run, "execute[restart_rb-exporter_#{iface_key}]", :delayed
end

Expand All @@ -115,7 +116,7 @@
cookbook 'rb-exporter'
mode '0644'
retries 2
variables(observation_id: observation_id)
variables(observation_id: observation_id, observation_id_filters: observation_id_filters)
notifies :run, "execute[restart_rb-exporter_#{iface_key}]", :delayed
end
else
Expand Down
52 changes: 52 additions & 0 deletions resources/templates/default/rb-exporter_conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
daemonize: true
logfile:/var/log/rb-exporter/<%= @iface %>/rb-exporter.log

<% if @type.downcase.include? "netflow"%>
<% if @observation_id_filters.count > 0 %>
<% unique_observation_ids = @observation_id_filters.map { |filter| filter['observation_id'] }.uniq %>
<% unique_observation_ids.each do |id| %>
aggregate[<%= id %>]: src_host, dst_host, src_mac, dst_mac, src_port, dst_port, proto, class, vlan
<% end %>
aggregate[<%= @observation_id %>]: src_host, dst_host, src_mac, dst_mac, src_port, dst_port, proto, class, vlan

<% @observation_id_filters.each do |filter| %>
aggregate_filter[<%= filter['observation_id'] %>]: src net <%= filter['subnet'] %>
<% end %>
<% @observation_id_filters.each do |filter| %>
aggregate_filter[<%= filter['observation_id'] %>]: dst net <%= filter['subnet'] %><%= " and not src net " + @observation_id_filters.reject { |f| f == filter }.map { |f| f['subnet'] }.join(' and not src net ') if @observation_id_filters.length > 1 %>
<% end %>

aggregate_filter[<%= @observation_id %>]: not src net <%= @observation_id_filters.map { |f| f['subnet'] }.join(' and not src net ') %> and not dst net <%= @observation_id_filters.map { |f| f['subnet'] }.join(' and not dst net ') %>

plugins: <%= unique_observation_ids.map { |id| "nfprobe[#{id}]" }.join(', ') %>, nfprobe[<%= @observation_id %>]
nfprobe_receiver: <%= @dstAddress %>
nfprobe_version: <%= @type.scan(/\d/).join('') %>
nfprobe_timeouts: maxlife=30:tcp=30:udp=30:icmp=30:general=30
<% unique_observation_ids.each do |id| %>
nfprobe_engine[<%= id %>]: <%= id %><%=@type.scan(/\d/).join('').to_i > 5 ? "" : ":0"%>
<% end %>
nfprobe_engine[<%= @observation_id %>]: <%= @observation_id %><%=@type.scan(/\d/).join('').to_i > 5 ? "" : ":0"%>
<% else %>
aggregate: src_host, dst_host, src_mac, dst_mac, src_port, dst_port, proto, class, vlan

plugins: nfprobe
nfprobe_receiver: <%= @dstAddress %>
nfprobe_version: <%= @type.scan(/\d/).join('') %>
nfprobe_timeouts: maxlife=30:tcp=30:udp=30:icmp=30:general=30
<% if @observation_id %>
nfprobe_engine: <%=@observation_id%><%=@type.scan(/\d/).join('').to_i > 5 ? "" : ":0"%>
<% end %>
<% end # end netflow%>
<% end %>

<% if @type.downcase.include? "sflow" %>
aggregate: class, dst_host, dst_host_country, dst_mac, dst_port, export_proto_seqno, in_iface, out_iface, peer_dst_ip, peer_src_ip, proto, sampling_rate, src_host, src_host_country, src_mac, src_port, tag, tag2, tcpflags, timestamp_arrival, tos, vlan

plugins: sfprobe
sfprobe_agentip: <%= @ipAddress %>
sfprobe_agentsubid: 1402
sfprobe_receiver: <%= @dstAddress %>
sampling_rate: 20
!pre_tag_label_encode_as_map: true
pre_tag_map: /etc/rb-exporter/<%=@iface%>/pretag.map
<% end %>
8 changes: 8 additions & 0 deletions resources/templates/default/rb-exporter_pretag_map.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@
! dst_mac, vlan.

<% if @observation_id %>
<% for observation_id_filter in @observation_id_filters %>
set_tag2=<%= observation_id_filter['observation_id'] %> filter='src net <%= observation_id_filter['subnet'] %>'
<% end %>

<% for observation_id_filter in @observation_id_filters %>
set_tag2=<%= observation_id_filter['observation_id'] %> filter='dst net <%= observation_id_filter['subnet'] %>'
<% end %>

set_tag2=<%=@observation_id%>
<% end %>
26 changes: 0 additions & 26 deletions resources/templates/rb-exporter_conf.erb

This file was deleted.

0 comments on commit 5aec9de

Please sign in to comment.