Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import Memory usage of Apache processes into Datadog
require 'rubygems'
require 'statsd'
statsd = Statsd.new
while true do
ps = `ps -C apache2 -o rss --no-header`
memory = ps.split("\n")
memory = memory.collect{|mem| mem.strip}
memory.each do |mem|
statsd.histogram('apache.rss_memory', mem)
end
puts "Sleeping for 10 seconds"
sleep(10)
end
{
"viz": "timeseries",
"requests": [
{
"q": "max:apache.rss_memory.max{*}",
"style": {
"width": "thin",
"type": "dashed"
}
},
{
"q": "max:apache.rss_memory.median{*}",
"style": {
"width": "normal"
}
},
{
"q": "max:apache.rss_memory.95percentile{*}",
"style": {
"width": "normal",
"type": "solid"
}
}
],
"events": [],
"markers": [
{
"type": "error dashed",
"value": "y = 262144",
"label": "Current limit - 256MB"
},
{
"type": "warning dashed",
"value": "y = 196608",
"label": "Proposed limit - 192MB"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment