Skip to content

Instantly share code, notes, and snippets.

@nna774
Last active March 22, 2021 12:28
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 nna774/c81f42f1721a590e45e0e5591c42f484 to your computer and use it in GitHub Desktop.
Save nna774/c81f42f1721a590e45e0e5591c42f484 to your computer and use it in GitHub Desktop.
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