Skip to content

Commit

Permalink
Merge pull request #12 from redBorder/bugfix/17260_wrong_configuratio…
Browse files Browse the repository at this point in the history
…n_monitor_services

Bugfix/17260 wrong configuration monitor services
  • Loading branch information
JPeraltaNic authored Jun 3, 2024
2 parents 81c805a + 7d2cce2 commit 50f88d2
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions resources/libraries/update_manager_config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Rbmonitor
module Helpers

def update_manager_config(resource)

##########################
Expand All @@ -12,9 +12,9 @@ def update_manager_config(resource)
monitor_dg = Chef::DataBagItem.load("rBglobal", "monitors") rescue monitor_dg={}
snmp_monitors = []
begin
if monitor_dg["monitors"].nil? or monitor_dg["monitors"].include?("load_1")
if monitor_dg["monitors"].nil? or monitor_dg["monitors"].include?("load_1")
snmp_monitors.push({"name": "load_1", "oid": "UCD-SNMP-MIB::laLoad.1", "unit": "%"},)
node.default[:redborder][:monitor][:count] = node.default[:redborder][:monitor][:count] + 1
node.default[:redborder][:monitor][:count] = node.default[:redborder][:monitor][:count] + 1
end
if monitor_dg["monitors"].nil? or monitor_dg["monitors"].include?("cpu")
snmp_monitors.push({"name": "cpu_idle", "oid": "UCD-SNMP-MIB::ssCpuIdle.0", "send": 0, "unit": "%"},)
Expand Down Expand Up @@ -79,21 +79,21 @@ def update_manager_config(resource)
if monitor_dg["monitors"].nil? or monitor_dg["monitors"].include?("disk_raw_load")
snmp_monitors.push({"name": "disk_raw_load", "system": "snmptable -v 2c -c redborder 127.0.0.1 diskIOTable|grep ' dm-2 ' | awk '{print $7}'", "unit": "%"},)
node.default[:redborder][:monitor][:count] = node.default[:redborder][:monitor][:count] + 1
end
end
elsif File.exist?("/dev/mapper/vg_rbdata-lv_raw")
if monitor_dg["monitors"].nil? or monitor_dg["monitors"].include?("disk_raw")
snmp_monitors.push({"name": "disk_raw", "oid": "UCD-SNMP-MIB::dskPercent.2", "unit": "%"},)
node.default[:redborder][:monitor][:count] = node.default[:redborder][:monitor][:count] + 1
end
end
rescue
rescue
puts "Error, can't access to SNMP monitors, skipping snmp monitors"
end

# IPMI monitors
monitor_dg = Chef::DataBagItem.load("rBglobal", "monitors") rescue monitor_dg={}
ipmi_monitors = []

begin
if File.exist?("/dev/ipmi0") or File.exist?("/dev/ipmi/0") or File.exist?("/dev/ipmidev/0")
if monitor_dg["monitors"].nil? or monitor_dg["monitors"].include?("system_temp")
Expand Down Expand Up @@ -132,20 +132,28 @@ def update_manager_config(resource)
#Calculate used memory per service
memory_monitors = ["/* MEMORY PER SERVICE */"]
begin
enabled_services = node.default["redborder"]["services"].map { |service|
service[0] if service[1]
}
enabled_services.delete_if { |service| service == nil }
enabled_services.each do |service|
service_list = %w[ druid-broker druid-coordinator druid-historical druid-middlemanager druid-overlord druid-realtime http2k kafka n2klocd redborder-nmsp redborder-postgresql webui zookeeper f2k ]
if service_list.include? service
serv = service.gsub("-", "_")
memory_monitors.push({ "name" => "memory_total_#{serv}", "unit" => "kB", "integer" => 1, "send" => 0,
"system" => "sudo /usr/lib/redborder/bin/rb_mem.sh -n #{service} 2>/dev/null" } )
memory_monitors.push({ "name" => "memory_#{serv}", "op" => "100*(memory_total_#{serv})/memory_total", "unit" => "%"} )
node.default[:redborder][:monitor][:count] = node.default[:redborder][:monitor][:count] + 2
enabled_services = node.default["redborder"]["services"]
service_list = %w[druid-broker druid-coordinator druid-historical druid-middlemanager druid-overlord druid-realtime http2k kafka n2klocd redborder-nmsp redborder-postgresql webui zookeeper f2k]

#In case user modifies a service
overwritten_services = node.attributes["redborder"]["services"]
overwritten_services.each do |service, value|
if value == false
enabled_services.delete(service)
elsif value == true && service_list.include?(service)
enabled_services[service] = true
end
end

enabled_services.select! { |k,v| v==true && service_list.include?(k) }

enabled_services.keys.each do |service|
serv = service.gsub("-", "_")
memory_monitors.push({ "name" => "memory_total_#{serv}", "unit" => "kB", "integer" => 1, "send" => 0,
"system" => "sudo /usr/lib/redborder/bin/rb_mem.sh -n #{service} 2>/dev/null" })
memory_monitors.push({ "name" => "memory_#{serv}", "op" => "100*(memory_total_#{serv})/memory_total", "unit" => "%" })
node.default[:redborder][:monitor][:count] += 2
end
rescue
puts "Can't access to redborder service list, skipping memory services monitorization"
end
Expand Down Expand Up @@ -174,6 +182,6 @@ def update_manager_config(resource)
node.default["redborder"]["monitor"]["config"][:sensors].push(manager_sensor)

end

end
end
end

0 comments on commit 50f88d2

Please sign in to comment.