Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dns.querytime.rb
if ENV['MACKEREL_AGENT_PLUGIN_META'] == '1'
require 'json'
meta = {
:graphs => {
'dns.querytime' => {
:label => 'time',
:unit => 'integer',
:metrics => [
{
:name => 'kasuga',
:label => 'kasuga'
}, {
:name => 'tsugu',
:label => 'tsugu'
}
]
}
}
}
puts '# mackerel-agent-plugin'
puts meta.to_json
exit 0
end
def q(to)
name = 'dynamodb.ap-northeast-1.amazonaws.com'
`dig "@#{to}" "#{name}" | grep "Query time" | cut -d ' ' -f4`.chomp
end
puts [ 'dns.querytime.tsugu', q('10.8.192.42'), Time.now.to_i ].join("\t")
puts [ 'dns.querytime.kasuga', q('10.8.208.42'), Time.now.to_i ].join("\t")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment