Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/17260 wrong configuration monitor services #12

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading