Skip to content

Instantly share code, notes, and snippets.

@alivx
Created November 11, 2021 20:35
Show Gist options
  • Save alivx/4de31bafad43e5e60b81bf4a5fb6ab0f to your computer and use it in GitHub Desktop.
Save alivx/4de31bafad43e5e60b81bf4a5fb6ab0f to your computer and use it in GitHub Desktop.
Monit slack ruby script
"ruby -e ""
require 'net/https'
require 'json'
uri = URI.parse('https://hooks.slack.com/services/xx/xx/xx')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'})
request.body = { \""channel\"" => \""#general\"", \""username\"" => \""mmonit\"", \""text\"" => \""[#{ENV['MONIT_HOST']}] #{ENV['MONIT_SERVICE']} - #{ENV['MONIT_DESCRIPTION']}\"" }.to_json
response = http.request(request)
puts response.body
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment