Skip to content

Instantly share code, notes, and snippets.

@paulpet
Created March 30, 2017 01:16
Show Gist options
  • Save paulpet/62f8fb9c59c04d0b152832148366ac4d to your computer and use it in GitHub Desktop.
Save paulpet/62f8fb9c59c04d0b152832148366ac4d to your computer and use it in GitHub Desktop.
sensu postmark queue check script
#!/opt/sensu/embedded/bin/ruby
require 'rubygems'
require 'postmark'
require 'json'
require 'sensu-plugin/check/cli'
class CheckPostmark < Sensu::Plugin::Check::CLI
option :warn,
:short => '-w WARN (default 10)',
:proc => proc {|a| a.to_i },
:default => 10
option :crit,
:short => '-c CRIT (default 20)',
:proc => proc {|a| a.to_i },
:default => 20
def run
api_token = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
client = Postmark::ApiClient.new(api_token)
queued = client.get_messages(status: 'queued', count: 500, offset: 0).count
unknown "Invalid queue count (cannot be greater than 500)" if config[:crit] > 500 or config[:warn] > 500
message "Postmark outbound queue size is #{queued}"
critical if queued >= config[:crit]
warning if queued >= config[:warn]
ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment