-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18586 add function to register sensors in proxy
- Loading branch information
1 parent
548360e
commit 2994471
Showing
2 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
module Rbmonitor | ||
module Helpers | ||
def update_sensor_proxyips(resource) | ||
# SENSOR MONITORIZATION FOR PROXY AND IPS | ||
# This is a BAD solution but I'm on a time constraint | ||
# So please, merge this file with update_sensor_config.rb when possible | ||
|
||
# FLOW SENSORS | ||
flow_nodes = resource['flow_nodes'] | ||
begin | ||
if flow_nodes | ||
# Title of section | ||
node.default['redborder']['monitor']['config']['sensors'].push('/* REMOTE SENSORS */') | ||
|
||
flow_nodes.each do |fnode| | ||
next unless !fnode['redborder']['monitors'].empty? && fnode['ipaddress'] | ||
|
||
fnode_name = fnode['rbname'] || fnode.name | ||
fnode_count = fnode['redborder']['monitors']&.size || 0 | ||
|
||
if fnode['redborder'] && !fnode['redborder']['monitors'].empty? | ||
# Title of sensor | ||
node.default['redborder']['monitor']['config']['sensors'].push("/* Node: #{fnode_name} Monitors: #{fnode_count} */") | ||
sensor = { | ||
'timeout': 5, | ||
'sensor_name': fnode_name, | ||
'sensor_ip': fnode['ipaddress'], | ||
'community': (fnode['redborder']['snmp_community'].nil? || fnode['redborder']['snmp_community'] == '') ? 'public' : fnode['redborder']['snmp_community'].to_s, | ||
'snmp_version' => (fnode['redborder']['snmp_version'].nil? || fnode['redborder']['snmp_version'] == '') ? '2c' : fnode['redborder']['snmp_version'].to_s, | ||
'enrichment' => enrich(fnode), | ||
'monitors' => monitors(fnode), | ||
} | ||
node.default['redborder']['monitor']['count'] = node.default['redborder']['monitor']['count'] + fnode['redborder']['monitors'].length | ||
node.default['redborder']['monitor']['config']['sensors'].push(sensor) | ||
else | ||
# The sensor is registered in another manager | ||
node.default['redborder']['monitor']['config']['sensors'].push("/* Node: #{fnode_name} Monitors: #{fnode_count} (not in this manager) */") | ||
end | ||
end | ||
end | ||
rescue | ||
puts 'Cant access to flow sensor, skipping...' | ||
end | ||
|
||
# DEVICES SENSORS | ||
device_nodes = resource['device_nodes'] | ||
begin | ||
if device_nodes | ||
# Title of section | ||
node.default['redborder']['monitor']['config']['sensors'].push('/* DEVICE SENSORS */') | ||
|
||
device_nodes.each do |dnode| | ||
next unless !dnode['redborder']['monitors'].empty? && dnode['ipaddress'] | ||
|
||
dnode_name = dnode['rbname'] || dnode.name | ||
dnode_count = dnode['redborder']['monitors'].size | ||
|
||
if dnode['redborder'] && !dnode['redborder']['monitors'].empty? | ||
# Title of sensor | ||
node.default['redborder']['monitor']['config']['sensors'].push("/* Node: #{dnode_name} Monitors: #{dnode_count} */") | ||
sensor = { | ||
'timeout': 5, | ||
'sensor_name': dnode_name, | ||
'sensor_ip': dnode['ipaddress'], | ||
'community': (dnode['redborder']['snmp_community'].nil? || dnode['redborder']['snmp_community'] == '') ? 'public' : dnode['redborder']['snmp_community'].to_s, | ||
'snmp_version': (dnode['redborder']['snmp_version'].nil? || dnode['redborder']['snmp_version'] == '') ? '2c' : dnode['redborder']['snmp_version'].to_s, | ||
'enrichment' => enrich(dnode), | ||
'monitors' => monitors(dnode), | ||
} | ||
node.default['redborder']['monitor']['count'] = node.default['redborder']['monitor']['count'] + dnode['redborder']['monitors'].length | ||
node.default['redborder']['monitor']['config']['sensors'].push(sensor) | ||
else | ||
# The sensor is registered in another manager | ||
node.default['redborder']['monitor']['config']['sensors'].push("/* Node: #{dnode_name} Monitors: #{dnode_count} (not in this manager) */") | ||
end | ||
end | ||
end | ||
rescue | ||
puts 'Cant access to device sensor, skipping...' | ||
end | ||
end | ||
end | ||
end |