Skip to content

Instantly share code, notes, and snippets.

@nurtext nurtext/monit.conf Secret
Last active Mar 8, 2016

Embed
What would you like to do?
Slack-Integration für Monit
check system localhost
if memory usage > 75% for 5 cycles then exec /usr/local/bin/monit_slack.rb else if succeeded then exec /usr/local/bin/monit_slack.rb
#!/usr/bin/ruby
require "net/https"
require "json"
webhook = ""
channel = ""
username = ""
webhook = URI.parse(webhook)
http = Net::HTTP.new(webhook.host, webhook.port)
http.use_ssl = true
request = Net::HTTP::Post.new(webhook.request_uri, {"Content-Type" => "application/json"})
request.body = {
"channel" => channel,
"username" => username,
"text" => "[#{ENV['MONIT_HOST']}] #{ENV['MONIT_SERVICE']} - #{ENV['MONIT_DESCRIPTION']}"
}.to_json
http.request(request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.