Skip to content

Instantly share code, notes, and snippets.

@nurtext
Last active March 8, 2016 13:03
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 nurtext/c13288a722e34a3523b0 to your computer and use it in GitHub Desktop.
Save nurtext/c13288a722e34a3523b0 to your computer and use it in GitHub Desktop.
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