Skip to content

Instantly share code, notes, and snippets.

@darron
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darron/dd99233e767b02b0bbd5 to your computer and use it in GitHub Desktop.
Save darron/dd99233e767b02b0bbd5 to your computer and use it in GitHub Desktop.
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