Skip to content

Instantly share code, notes, and snippets.

@fujin
Created September 26, 2008 23:19
Show Gist options
  • Save fujin/13232 to your computer and use it in GitHub Desktop.
Save fujin/13232 to your computer and use it in GitHub Desktop.
# iclassify
total_memory = attrib?("memorysize")
if total_memory
if total_memory =~ /MB$/
total_memory.gsub!(/ MB/, '')
total_memory = total_memory.to_f
else
total_memory.gsub!(/ GB/, '')
total_memory = total_memory.to_f * 1024
end
buffer_pool_size = total_memory * 0.75
buffer_pool_size = buffer_pool_size.to_i
add_attrib("innodb_buffer_pool_size", buffer_pool_size.to_s + "M") unless attrib?("innodb_buffer_po
ol_size")
end
# facter
def get_buffer_pool_size
total_memory = Facter.value(:memorysize)
if total_memory
if total_memory =~ /MB$/
total_memory.gsub!(/ MB/, '')
total_memory = total_memory.to_f
else
total_memory.gsub!(/ GB/, '')
total_memory = total_memory.to_f * 1024
end
buffer_pool_size = total_memory * 0.75
buffer_pool_size = buffer_pool_size.to_i
buffer_pool_size.to_s + "M"
end
end
Facter.add("innodb_buffer_pool_size") do
setcode do
get_buffer_pool_size
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment