Created
March 30, 2017 01:16
-
-
Save paulpet/62f8fb9c59c04d0b152832148366ac4d to your computer and use it in GitHub Desktop.
sensu postmark queue check script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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